Solved Prevent drop of item

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

iAngry

Member
Jul 12, 2018
3
1
0
114
I'm trying to prevent players from dropping on the floor and storing their spawned item (/i stone) in chests. I've tried different ways to prevent it but I can't find a way.
This is what I have now.

code_language.skript:
command /i stone:
    permission: spawn.item
    permission message: &dPrincess &6King &4Empress Emperor &bHave access to /item
    aliases: /item stone
    trigger:
        message "&6Giving &c64 &6of &cstone"
        give player 64 stone named "Stone" with lore "&6Spawned by &c%player%"
 
code_language.skript:
on drop:
    line 1 of lore of event-item is “lorehere”
    cancel event
code_language.skript:
on inventory click:
    line 1 of lore of clicked slot is “lorehere”
    cancel event
 
This is what I would do:
code_language.skript:
on drop:
    event-item is a stone named "stone":
        line 1 of lore of event-item is "&6Spawned by &c%player%":
            cancel event
For the inventory, as I'm still a little noob and I never did that, I think PatoFrango code for that will work well. [His post above this you're reading now]
 
Thank you for the help but it gives me errors
code_language.skript:
command /i stone:
    permission: spawn.item
    permission message: "&dPrincess &6King &4Empress Emperor &bHave access to /item"
    aliases: /item stone
    trigger:
        message "&6Giving &c64 &6of &cstone"
        give player 64 stone named "&rStone" with lore "&6Spawned Item"
on inventory click:
    line 1 of lore of clicked slot is “&6Spawned Item”
    cancel event
on drop:
    line 1 of lore of event-item is “&6Spawned Item”
    cancel event
It gives me the error
code_language.skript:
[10:44:28 ERROR]: Can't compare a text with '“&6Spawned Item”' (give.sk, line 9: line 1 of lore of clicked slot is “&6Spawned Item”')
[10:44:28 ERROR]: Can't compare a text with '“&6Spawned Item”' (give.sk, line 12: line 1 of lore of event-item is “&6Spawned Item”')
[doublepost=1531465506,1531442750][/doublepost]Nevermind. I fixed it, thank you for helping.
This fixed it.
code_language.skript:
on drop:
    if event-item is Stone named "&rStone" with lore "&6Spawned By &c%player%":
        cancel event
        wait 3 ticks
        send "&6You can't drop spawned items"
 
  • Like
Reactions: PatoFrango
The wait there is pointless, there's no need to randomly wait before sending the message.
 
Status
Not open for further replies.