Solved Error

  • 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!

Status
Not open for further replies.

ForPlay_HD

Member
Aug 23, 2018
11
0
1
24
Hello guys!
I've tried to make a skript plugin for tokens and coins.
You can win tokens and coins at crates, then you receive them with command /reward

.
But something is wrong in my code
When player types /reward and select "Coin-uri" or "Token-uri" the system doesn't send player message if he isn't holding an item or he doesn't has it...
And when player is holding the correct item named "Coin" or "Token" the system doesn't give him reward...

Code:

command /reward:
trigger:
open virtual chest with size 1 named "Alege" to player
make gui slot 3 of player with sunflower named "&6Coin-uri" to close
make gui slot 5 of player with sunflower named "&6Token-uri" to close


on inventory click:
if inventory name of player is "Alege":
if clicked slot is 3:
if name of player's tool is "&6&lCoin":
subtract 1 sunflower named "&6&lCoin" from player's inventory
add 1 to {coins.%player%}
send "[&6!&f] Ai primit &61x coins&f!" to player
stop
else:
send "[&c*&f] Nu ai un item numit &6&lCoin&f sau nu il ti in mana!" to player
stop
if clicked slot is 5:
if name of player's tool is "&6&lToken":
subtract 1 sunflower named "&6&lToken" from player's inventory
add 1 to {tokens.%player%}
send "[&6!&f] Ai primit &61x tokens&f!" to player
stop
else:
send "[&c*&f] Nu ai un item numit &6&lToken&f sau nu il ti in mana!" to player
stop

Sorry for my english xD
thanks.
 
Last edited:
Its really hard to tell with the way you have pasted your code. Could you please edit and put it into a code block?
Click the little plus above where you type (beside the picture and film strip) then click code... when the window pops up paste your code in there
 
Its really hard to tell with the way you have pasted your code. Could you please edit and put it into a code block?
Click the little plus above where you type (beside the picture and film strip) then click code... when the window pops up paste your code in there

code_language.skript:
command /reward:
    trigger:
        open virtual chest with size 1 named "Alege" to player
        make gui slot 3 of player with sunflower named "&6Coin-uri" to close
        make gui slot 5 of player with sunflower named "&6Token-uri" to close


on inventory click:
    if inventory name of player is "Alege":
        if clicked slot is 3:
            if name of player's tool is "&6&lCoin":
                subtract 1 sunflower named "&6&lCoin" from player's inventory
                add 1 to {coins.%player%}
                send "[&6!&f] Ai primit &61x coins&f!" to player
                stop
            else:
                send "[&c*&f] Nu ai un item numit &6&lCoin&f sau nu il ti in mana!" to player
                stop   
        clicked slot is 5:
            if name of player's tool is "&6&lToken":
                subtract 1 sunflower named "&6&lToken" from player's inventory
                add 1 to {tokens.%player%}
                send "[&6!&f] Ai primit &61x tokens&f!" to player
                stop
            else:
                send "[&c*&f] Nu ai un item numit &6&lToken&f sau nu il ti in mana!" to player
                stop
 
" if name of player's tool is "&6&lCoin":" refers to the item in their hand... if its not in their hand, it won't recognize it
" subtract 1 sunflower named "&6&lCoin" from player's inventory" use remove instead of subtract
 
" if name of player's tool is "&6&lCoin":" refers to the item in their hand... if its not in their hand, it won't recognize it
" subtract 1 sunflower named "&6&lCoin" from player's inventory" use remove instead of subtract

Yeah, but if the player is holding an item named "&6&lCoin" and use /reward nothing happens...
 
Status
Not open for further replies.