Solved Gen skript owner not working

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

MrSnowy

New Member
Sep 7, 2021
9
0
1
23
I made a gen skript that works fine and added that only the owner of that gen can upgrade/remove it but it doesn't work, there are no errors in the skript.

I have attached the full skript, and put the part I think is not working in the thread.
I have set the {owner} to player and then checked if the owner is set and if it's not player.

When I destroy/upgrade the gen it works fine, but when another player destroys it it doesn't stop him and let him break the gen.



Code:
command /wheatgen:
    permission: op
    permission message: "&4You are not allowed to do that!"
    trigger:
        give player hay block named "&eWheat Gen"
   
command /pumpkingen:
    permission: op
    permission message: "&4You are not allowed to do that!"
    trigger:
        give player pumpkin named "&6Pumpkin Gen"
   
command /coalgen:
    permission: op
    permission message: "&4You are not allowed to do that!"
    trigger:
        give player coal block named "&8Coal Gen"
   
command /irongen:
    permission: op
    permission message: "&4You are not allowed to do that!"
    trigger:
        give player iron block named "&fIron Gen"
   
command /goldgen:
    permission: op
    permission message: "&4You are not allowed to do that!"
    trigger:
        give player gold block named "&6Gold Gen"
   
command /gencapreset [<player>]:
    permission: op
    permission message: "&4You can't execute this command!"
    trigger:
        if arg-1 is set:
            if arg-1 is a player:
                send "&bYou have reset %arg-1% &bgenacp" to player
                set {gens::%arg-1's uuid%} to 0
   
command /gens:
    trigger:
        send "&bYou have placed %{gens::%player's uuid%}% &bgens!" to player

on place of hay block:
    if name of player's held item contains "&eWheat Gen":
        if {gens::%player's uuid%} < 10:
            set {owner} to player
            add 1 to {gens::%player's uuid%}
            add location of event-block to {placed::gens::%player's uuid%::*}
            send action bar "&bYou placed a wheat gen!" to player
        else:
            cancel event
            send action bar "&cYou have reached the max gens you can place!" to player
   
on left click on hay block:
    if {placed::gens::%player's uuid%::*} contains location of event-block:
        if player is sneaking:
            if {owner} is set:
                if {owner} is not player:
                    cancel event
                    send action bar "&cYou are not the owner of this gen!" to player
                else:
                    cancel event
                    set event-block to air
                    remove 1 from {gens::%player's uuid%}
                    remove location of event-block from {placed::gens::%player's uuid%::*}
                    send action bar "&cYou broke a wheat gen!" to player
                    give player hay block named "&eWheat Gen"
        else:
            cancel event
            send action bar "&bTo break a gen you need to be shifting." to player
       
on right click on hay block:
    if {placed::gens::%player's uuid%::*} contains location of event-block:
        if player is sneaking:
            if {owner} is set:
                if {owner} is not player:
                    send action bar "&cYou are not the owner of this gen!" to player
                else:
                    wait 10 ticks
                    set event-block to pumpkin
                    send action bar "&bYou upgraded a gen!" to player
 

Attachments

  • Gen skript.txt
    7.8 KB · Views: 156
Last edited:
It's okay!
Just click the plus and click code to insert your code.
[doublepost=1631033131,1631033082][/doublepost]Also can you send your errors so I can see what's wrong?
 
It's okay!
Just click the plus and click code to insert your code.
[doublepost=1631033131,1631033082][/doublepost]Also can you send your errors so I can see what's wrong?
I have no errors in the skript, it just doesn't work
 
you know that {owner} is a global variable and is not specific at all?
I fixed it myself I debugged and I realised it's about that it's checking for the placed gens of the player's uuid if {placed::gens::%player's uuid%::*} contains location of event-block:.
[doublepost=1631112526,1631112480][/doublepost]How do I close this post?
 
Status
Not open for further replies.