skript help

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Chocorramo

Member
May 27, 2024
1
0
1
19
I want to make a script that when a player writes in the chat [inv] a message is displayed in which the other players can click and see their inventory, is it possible?

for the moment i have this:

# Evento que detecta cuando un jugador envía un mensaje en el chat
on chat:
if message contains "[inv]":
cancel event
send formatted "<tooltip:Click><cmd:/showinv>Click para ver el inventario<r>" to player


# Comando para abrir el inventario de un jugador en un cofre
command /showinv [<text>]:
trigger:
# Guarda el jugador especificado (o el jugador que ejecutó el comando) en una variable
if arg-1 is set:
set player named arg-1
else:
set {_player} to player
# Crea un cofre y copia el inventario del jugador dentro de él
open chest with 6 rows named "%{_player}%\'s Inventory" to {_player}
 
Formatted Code:
Code:
on chat:
if message contains "[inv]":
cancel event
send formatted "<tooltip:Click><cmd:/showinv>Click para ver el inventario<r>" to player

# Comando para abrir el inventario de un jugador en un cofre
command /showinv [<text>]:
trigger:
# Guarda el jugador especificado (o el jugador que ejecutó el comando) en una variable
if arg-1 is set:
set player named arg-1
else:
set {_player} to player
# Crea un cofre y copia el inventario del jugador dentro de él
open chest with 6 rows named "%{_player}%\'s Inventory" to {_player}
 
1. You need to put tabs behind it all
2. send formatted... does not exist, just do send...
3. instead of [<text>], use [<offline player>], you can now remove "set player named arg-1"
4. setting {_player} to the player means your setting it to the command sender. Remove it.
Fixed Code:
Code:
on chat:
    if message contains "[inv]":
        #not sure if this line works
        brodcast "<tooltip:Click><cmd:/showinv %player%>%player%'s inventory"

command /showinv [<offline player>]:
    trigger:
        if arg-1 is not set:
            send "/showinv <player>" to player
        else:
            set metadata tag "inv_gui" of player to chest inventory with 6 rows named "%arg-1%'s Inventory"
            set slot 0 of metadata tag "inv_gui" of player to barrier named "Put whatever you want here"   #this line will format the slots
            open (metadata tag "inv_gui" of player) to player
            
on inventory click:
    if event-inventory is (metadata tag "inv_gui" of player):
        cancel event
        if index of event-slot is 0:
            #do something....

I have not given you the code to view the invento ybut just fixed the code that was on screen
 
1. You need to put tabs behind it all
2. send formatted... does not exist, just do send...
3. instead of [<text>], use [<offline player>], you can now remove "set player named arg-1"
4. setting {_player} to the player means your setting it to the command sender. Remove it.
1. It's likely that copying over to skunity without using the CODE section broke their code, they never would've gotten this far without indentations.
2. Send formatted does, in fact, exist.
3. Does set player named arg-1 even exist? I feel like the proper syntax would be set arg-1 to (arg-1 parsed as offline player).
4. They want to set {_player} to the sender, because arg-1 is not set. They should simply change their <command:> in the formatted message to <command:/showinv %player%>