Lock Door on place

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

CringeBoy

Active Member
May 20, 2021
65
0
6
Romania
Can I get some help with a door lock skript? Like if you place a door to automatically lock it so you are the only person that can open the door. Then have commands to add player to the door and also remove him from the door.
 
try
Code:
on place of any door:
  set {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%} to player

on break of any door:
  if {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%} is player:
    delete {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%}
  else:
    send "Only the owner can break this door"

on right click on any door:
  if {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%} is not player:
    if {door::member::%x-coordinate of event-block%::%x-coordinate of event-block%} does not contain player:
      cancel event
      send "You cant open this door"

command /addmember [<offline player>]:
  trigger:
    if {door::%x-coordinate of target block%::%x-coordinate of target block%} is player:
      if {door::member::%x-coordinate of target block%::%x-coordinate of target block%} does not contain arg-1:
        add arg-1 to {door::member::%x-coordinate of target block%::%x-coordinate of target block%}
        send "%arg-1% can now open this door"
      else:
        remove arg-1 from {door::member::%x-coordinate of target block%::%x-coordinate of target block%}
        send "%arg-1% can no longer open this door"
    else:
      send "This isn't your door"
 
try
Code:
on place of any door:
  set {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%} to player

on break of any door:
  if {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%} is player:
    delete {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%}
  else:
    send "Only the owner can break this door"

on right click on any door:
  if {door::owner::%x-coordinate of event-block%::%x-coordinate of event-block%} is not player:
    if {door::member::%x-coordinate of event-block%::%x-coordinate of event-block%} does not contain player:
      cancel event
      send "You cant open this door"

command /addmember [<offline player>]:
  trigger:
    if {door::%x-coordinate of target block%::%x-coordinate of target block%} is player:
      if {door::member::%x-coordinate of target block%::%x-coordinate of target block%} does not contain arg-1:
        add arg-1 to {door::member::%x-coordinate of target block%::%x-coordinate of target block%}
        send "%arg-1% can now open this door"
      else:
        remove arg-1 from {door::member::%x-coordinate of target block%::%x-coordinate of target block%}
        send "%arg-1% can no longer open this door"
    else:
      send "This isn't your door"
The /addmember command says This isn't your door even that I am the owner of the door, and also players can break the door from the top of the door.
 
Oh I noticed a spelling mistake
[doublepost=1622129845,1622129774][/doublepost]
Code:
on place of any door:
  set {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%} to player
 
on break of any door:
  if {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%} is player:
    delete {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%}
    delete {door::member::%x-coordinate of event-block%::%z-coordinate of event-block%}
  else:
    cancel event
    send "Only the owner can break this door"
 
on right click on any door:
  if {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%} is not player:
    if {door::member::%x-coordinate of event-block%::%z-coordinate of event-block%} does not contain player:
      cancel event
      send "You cant open this door"
 
command /addmember [<offline player>]:
  trigger:
    if {door::%x-coordinate of target block%::%z-coordinate of target block%} is player:
      if {door::member::%x-coordinate of target block%::%z-coordinate of target block%} does not contain arg-1:
        add arg-1 to {door::member::%x-coordinate of target block%::%z-coordinate of target block%}
        send "%arg-1% can now open this door"
      else:
        remove arg-1 from {door::member::%x-coordinate of target block%::%z-coordinate of target block%}
        send "%arg-1% can no longer open this door"
    else:
      send "This isn't your door"

report if it isn't working
 
Last edited:
It still says that this isn't your door and also players can open/break the door from the top half of the door
 
For me its working fine, besides the addmember command
[doublepost=1622153689,1622153485][/doublepost]fixed
Code:
on place of any door:
    set {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%} to player
 
on break of any door:
    if {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%} is player:
        delete {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%}
        delete {door::member::%x-coordinate of event-block%::%z-coordinate of event-block%::*}
    else:
        cancel event
        send "Only the owner can break this door"
 
on right click on any door:
    if {door::owner::%x-coordinate of event-block%::%z-coordinate of event-block%} is not player:
        if {door::member::%x-coordinate of event-block%::%z-coordinate of event-block%::*} does not contain player:
            cancel event
            send "You cant open this door"
 
command /addmember [<offline player>]:
    trigger:
        if {door::owner::%x-coordinate of target block%::%z-coordinate of target block%} is player:
            if {door::member::%x-coordinate of target block%::%z-coordinate of target block%::*} does not contain arg-1:
                add arg-1 to {door::member::%x-coordinate of target block%::%z-coordinate of target block%::*}
                send "%arg-1% can now open this door"
            else:
                remove arg-1 from {door::member::%x-coordinate of target block%::%z-coordinate of target block%::*}
                send "%arg-1% can no longer open this door"
        else:
            send "This isn't your door"
 
I still can open doors from the top half, is it because I am on 1.12.2?
[doublepost=1622209372,1622209280][/doublepost]Also yes, the addmember command works.
[doublepost=1622209414][/doublepost]I need an addon or something?
 
Status
Not open for further replies.