Keycard skript (again)

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

TheMangoCrew

Member
Nov 15, 2020
11
0
1
27
I asked this before, but I didn't specify how I imagined it. So, you have an iron door, and a button besides it. You press the button with the keycard equal or higher than the level of the card reader, and it opens. If the keycard's level is lower than what the card reader (button) accepts, it closes the iron door instantly, and displays something like "You need level <number> to open this!" or something. I hope someone can help me. I appreciate all people helping.
 
Code:
command /setcardreader [<number>]:
    permission: keycard.admin
    permission message: &cYou don't have permission to execute this command.
    trigger:
        if arg-1 is set:
            if arg-1 is 1:
                if player's target block is stone button:
                    set metadata value "crlvl1" of target block to true
                    send "&aSuccess!" to player
            if arg-1 is 2:
                if player's target block is stone button:
                    set metadata value "crlvl2" of target block to true
                    send "&aSuccess!" to player
        else:
            send "&cSpecify card reader level."
           
command /removecardreader:
    permission: keycard.admin
    permission message: &cYou don't have permission to execute this command.
    trigger:
        if player's target block is stone button:
            clear metadata value "crlvl1" of target block
            clear metadata value "crlvl2" of target block
            send "&aSuccess!" to player  


           
on right click on stone button:
    if metadata value "crlvl1" of event-block is true:
        set {_card} to knowledge book
        set name of {_card} to "&cKeyCard &7(lvl 1)"
        set {_card2} to knowledge book
        set name of {_card2} to "&cKeyCard &7(lvl 2)"
        if player's held item is {_card} or {_card2}:
            send "&aAccess granted!" to player
        else:
            cancel event
            send "&cAccess denied! &7You need a level 1 keycard or higher."
           
    if metadata value "crlvl2" of event-block is true:
        set {_card2} to knowledge book
        set name of {_card2} to "&cKeyCard &7(lvl 2)"
        if player's held item is {_card2}:
            send "&aAccess granted!" to player
        else:
            cancel event
            send "&cAccess denied! &7You need a level 2 keycard."

To set it up you have to look at a stone button and do /setcardreader (card level accepted 1 | 2). To remove a card reader look at the it and do /removecardreader. To get a card do /give (your name) knowledge_book 1, then name the book "&cKeyCard &7(lvl 1)"
 
i recommend using coordinates and not metadata because it would be reset once you restart the server
 
Code:
command /setcardreader [<number>]:
    permission: keycard.admin
    permission message: &cYou don't have permission to execute this command.
    trigger:
        if arg-1 is set:
            if arg-1 is 1:
                if player's target block is stone button:
                    set metadata value "crlvl1" of target block to true
                    send "&aSuccess!" to player
            if arg-1 is 2:
                if player's target block is stone button:
                    set metadata value "crlvl2" of target block to true
                    send "&aSuccess!" to player
        else:
            send "&cSpecify card reader level."
          
command /removecardreader:
    permission: keycard.admin
    permission message: &cYou don't have permission to execute this command.
    trigger:
        if player's target block is stone button:
            clear metadata value "crlvl1" of target block
            clear metadata value "crlvl2" of target block
            send "&aSuccess!" to player 


          
on right click on stone button:
    if metadata value "crlvl1" of event-block is true:
        set {_card} to knowledge book
        set name of {_card} to "&cKeyCard &7(lvl 1)"
        set {_card2} to knowledge book
        set name of {_card2} to "&cKeyCard &7(lvl 2)"
        if player's held item is {_card} or {_card2}:
            send "&aAccess granted!" to player
        else:
            cancel event
            send "&cAccess denied! &7You need a level 1 keycard or higher."
          
    if metadata value "crlvl2" of event-block is true:
        set {_card2} to knowledge book
        set name of {_card2} to "&cKeyCard &7(lvl 2)"
        if player's held item is {_card2}:
            send "&aAccess granted!" to player
        else:
            cancel event
            send "&cAccess denied! &7You need a level 2 keycard."

To set it up you have to look at a stone button and do /setcardreader (card level accepted 1 | 2). To remove a card reader look at the it and do /removecardreader. To get a card do /give (your name) knowledge_book 1, then name the book "&cKeyCard &7(lvl 1)"

Can't there be a way that it makes it for multiple buttons (for example: oak is level 1, spruce is level 2 etc.) and it is automatic, so you don't have to type a command every time (so it sets every button on the server to a card reader without question)?
 
Code:
on right click on oak button:
    set {_card} to knowledge book
    set name of {_card} to "&cKeyCard &7(lvl 1)"
    set {_card2} to knowledge book
    set name of {_card2} to "&cKeyCard &7(lvl 2)"
    if player's held item is {_card} or {_card2}:
        send "&aAccess granted!" to player
    else:
        cancel event
        send "&cAccess denied! &7You need a level 1 keycard or higher."
          
on right click on spruce button:
    set {_card2} to knowledge book
    set name of {_card2} to "&cKeyCard &7(lvl 2)"
    if player's held item is {_card2}:
        send "&aAccess granted!" to player
    else:
        cancel event
        send "&cAccess denied! &7You need a level 2 keycard."
 
Status
Not open for further replies.