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.

Open iron door with a key

Discussion in 'Skript' started by iStopcontact, Nov 28, 2017.

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

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    107
    Likes Received:
    1
    Hey guys,

    I am working on a reallife server with in my skript i want to have keys for iron doors.

    That's not that hard but now i want to have just keys for diffrent doors.

    So for example a key for house1, and a key for house2 but they cant open each other.


    This is what i have in my skript:
    Code (Skript):
    1. on right click on iron door:
    2.     if tool of player is name tag:
    3.         if name of tool of player is "House1":
    4.             if name of targeted block is "House1Door":
    5.                 activate block
    6.                 wait 2 seconds
    7.                 deactivate block
    8.         else:
    9.             message "You don't have a key!"
    The part with "if name of targeted block is "House1Door" gives no errors but it isnt working.
    So can someone maybe help me with this?
     
  2. Wynnevir

    Wynnevir Well-Known Member

    Joined:
    Jul 9, 2017
    Messages:
    974
    Likes Received:
    57
    you can't save the name of a block once it's placed, but you can save it's location in a variable on place and check that against the target block.
     
  3. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    107
    Likes Received:
    1
    And what is the best way to code that?
     
  4. Wynnevir

    Wynnevir Well-Known Member

    Joined:
    Jul 9, 2017
    Messages:
    974
    Likes Received:
    57
    Just set the variable to the event-location using the on place event.
     
  5. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    107
    Likes Received:
    1
    Yhea but i need to set diffrent variables so just for each house one so i need to do it with another command i gues?
     
  6. Wynnevir

    Wynnevir Well-Known Member

    Joined:
    Jul 9, 2017
    Messages:
    974
    Likes Received:
    57
    ye, though you'd only need to do it once. Once you have the variables assigned you could get rid of the code that does the assigning.
     
  7. iStopcontact

    iStopcontact Member

    Joined:
    Feb 18, 2017
    Messages:
    107
    Likes Received:
    1
    Yhea but then i need to change the code every time i place a door haha
     
  8. Wynnevir

    Wynnevir Well-Known Member

    Joined:
    Jul 9, 2017
    Messages:
    974
    Likes Received:
    57
    True, but it'd be like a setup sort of thing you'd only have to do once. Better yet, you could add the locations to one list variable and just compare the target block location with the list. Just less variables to mess with there.

    That's the only way I can think of, like I said placed blocks don't hold names.
     
Thread Status:
Not open for further replies.
Loading...