Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component = require("component")
- event = require("event")
- keypad = component.os_keypad
- datacard = component.data
- cardreader = component.os_magreader
- keypad.setEventName("keypad")
- keypad.setDisplay("Enter PIN", 1)
- keypad.setVolume(0.25);
- keypad.getVolume();
- customButtons = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0","Cancle"}
- customButtonColor = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
- keypad.setKey(customButtons, customButtonColor)
- local _eventName = "magCardRead"
- cardreader.setEventName(_eventName)
- function OnRead(_,_,playername,cardData,UUID,isLocked,_)
- local kppin = ""
- repeat
- eventName, address, button, button_label = event.pull("keypad")
- print("key pressed: " .. button)
- if button == "Cancle" then
- break
- end
- kppin = kppin .. button
- keypad.setDisplay(kppin, 1)
- until #kppin == 8
- if button == "Cancle" then
- return
- end
- suc = datacard:decrypt(cardData,"&F)J@NcRfTjWnZr4",kppin..kppin)
- if suc == playername then
- keypad.setDisplay("ACCESS GRANTED", 1)
- else
- keypad.setDisplay("ACCESS DENIED TRY AGAIN", 1)
- os.sleep(2.5)
- OnRead(_,_,playername,cardData,UUID,isLocked,_)
- end
- end
- event.listen("magCardRead", OnRead)
- event.pull("interrupted")
- --event.ignore("magCardRead", OnRead)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement