1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Claimdoor

Discussion in 'Skript' started by Maezukie, Aug 23, 2018.

Thread Status:
Not open for further replies.
  1. Maezukie

    Maezukie Member

    Joined:
    May 21, 2018
    Messages:
    13
    Likes Received:
    0
    how can I make it so that on a command you can claim a door so no one but the claimer can open it but if the claimer logs out the claimers door gets unclaimed?

     
  2. Best Answer:
    Post #4 by ShaneBee, Aug 23, 2018
  3. ShaneBee

    Supporter +

    Joined:
    Sep 7, 2017
    Messages:
    1,459
    Likes Received:
    96
    you could write a command to set a variable to true.
    Then if a player right clicks on a door, and the variable is true it would create a variable for the location of the door.

    Then use a click event for the door, checking whether or not there is a variable set at that location, and if the owner of the door is said player, if not, cancel the event, send a message.

    Then use the quit event to remove the variable
     
  4. Maezukie

    Maezukie Member

    Joined:
    May 21, 2018
    Messages:
    13
    Likes Received:
    0
    Im so lost
    Code (Skript):
    1.  
    2. command /CD:
    3.     aliases: claimdoor
    4.     trigger:
    5.         if target block is any door:
    6.             if {%target-block%} is not set:
    7.                 set {%target-block%} to "%player%"
    8.                 send "&ayou claimed the door"
    9.             else:
    10.                 send "&cdoor already claimed"
    11.         else:
    12.             send "&cNot a door"
    13.  
    14. on rightclick on any door:
    15.     if {%target-block%} is set:
    16.         if {%target-block%} is not "%player%":
    17.             cancel event
    18.             send "&cthis is not your door"
    19.         else:
    20.             uncancel event
    21.  
    22. on disconnect:
    23.     loop all doors:
    24.         if {%loop-value%} is %player%:
    25.             delete {%loop-value%}
    26.  
     
  5. ShaneBee

    Supporter +

    Joined:
    Sep 7, 2017
    Messages:
    1,459
    Likes Received:
    96
    i would change your variable:
    Code (Skript):
    1. from {%target-block%} to {lockeddoors::%target-block%}
    then in your disconnect event do this
    Code (Skript):
    1. on disconnect:
    2.     loop {lockeddoors::*}:
    3.         if loop-value is player:
    4.             delete {lockeddoors::%loop-index%}
     
  6. Maezukie

    Maezukie Member

    Joined:
    May 21, 2018
    Messages:
    13
    Likes Received:
    0
    Code (Skript):
    1. command /CD:
    2.     aliases: claimdoor
    3.     trigger:
    4.         if target block is any door:
    5.             if {lockeddoors::%target block%} is not set:
    6.                 set {lockeddoors::%target block%} to "%player%"
    7.                 send "&8[&aClaimdoor&8] &ayou claimed the door"
    8.             else:
    9.                 send "&8[&aClaimdoor&8] &cdoor already claimed"
    10.         else:
    11.             send "&8[&aClaimdoor&8] &cNot a door"
    12.  
    13. on rightclick on any door:
    14.     if {lockeddoors::%target block%} is set:
    15.         if {lockeddoors::%target block%} is not "%player%":
    16.             cancel event
    17.             send "&8[&aClaimdoor&8] &cthis is not your door"
    18.         else:
    19.             uncancel event
    20.  
    21. on disconnect:
    22.     loop {lockeddoors::*}:
    23.         if loop-value is player:
    24.             delete {lockeddoors::%loop-index%}
    25.  
    26. on load:
    27.     broadcast "&8[&aClaimdoor&8] &fReloaded"
    this works but people can claim multiple doors
     
  7. ShaneBee

    Supporter +

    Joined:
    Sep 7, 2017
    Messages:
    1,459
    Likes Received:
    96
    then add in a variable and if statement like this
    Code (Skript):
    1. if {lockeddoors::%player%} is not set:
    2.     set {lockeddoors::%player%} to true
    3. else:
    4.     send "You can only claim 1 door" to player
    5.     stop

    and when they logout add
    Code (Skript):
    1. delete {lockeddoors::%player%}
     
  8. Maezukie

    Maezukie Member

    Joined:
    May 21, 2018
    Messages:
    13
    Likes Received:
    0
    thanks it works
     
  9. ShaneBee

    Supporter +

    Joined:
    Sep 7, 2017
    Messages:
    1,459
    Likes Received:
    96
    YAY ... You are welcome :emoji_slight_smile:
     
Thread Status:
Not open for further replies.
Loading...