Help with a keypad code script?
eleisha93
12 Jun 2014, 09:12Hi,
Just a quick question regarding one of my scripts for my keypad. This is the code:
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
PrintCentered ("ACCESS DENIED")
PrintCentered ("You notice a strange sound, like a machine being powered on.")
Ask ("Try Again?") {
if (result) {
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
PrintCentered ("ACCESS DENIED. SECURITY NOTIFIED")
PrintCentered ("You notice the wall above the door opens and a machine gun emerges. It is pointed at you.")
Ask ("Try Again?") {
if (result) {
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
PrintCentered ("ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP")
PrintCentered ("An alarm sounds. The machine gun starts up. There is no way you can escape in time.")
PrintCentered ("YOU ARE NOW DEAD")
finish
}
}
}
else {
SwitchOff (Office Door Keypad)
msg ("You step away from the keypad")
}
}
}
}
}
else {
SwitchOff (Office Door Keypad)
msg ("You step away from the keypad")
}
}
}
}
It is working fine, however the only problem I have is when the player steps away from the keypad and uses it again the scripts starts again. What I was wanting to do is when you use the keypad 3 times, no matter if you stop using it and start again, or use it 3 times in a row (which is working) you die. The issue I am having is that you can bypass this by entering and exiting the keypad and it keeps starting from the start. I wanted to make it so if you step out and step back into the keypad then second or third time the script would start on the second or third script I had created. eg these points:
2. PrintCentered ("ACCESS DENIED. SECURITY NOTIFIED")
PrintCentered ("You notice the wall above the door opens and a machine gun emerges. It is pointed at you.")
3. PrintCentered ("ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP")
PrintCentered ("An alarm sounds. The machine gun starts up. There is no way you can escape in time.")
PrintCentered ("YOU ARE NOW DEAD")
finish
Any help would be much appreciated in solving this issue.
Just a quick question regarding one of my scripts for my keypad. This is the code:
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
PrintCentered ("ACCESS DENIED")
PrintCentered ("You notice a strange sound, like a machine being powered on.")
Ask ("Try Again?") {
if (result) {
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
PrintCentered ("ACCESS DENIED. SECURITY NOTIFIED")
PrintCentered ("You notice the wall above the door opens and a machine gun emerges. It is pointed at you.")
Ask ("Try Again?") {
if (result) {
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
PrintCentered ("ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP")
PrintCentered ("An alarm sounds. The machine gun starts up. There is no way you can escape in time.")
PrintCentered ("YOU ARE NOW DEAD")
finish
}
}
}
else {
SwitchOff (Office Door Keypad)
msg ("You step away from the keypad")
}
}
}
}
}
else {
SwitchOff (Office Door Keypad)
msg ("You step away from the keypad")
}
}
}
}
It is working fine, however the only problem I have is when the player steps away from the keypad and uses it again the scripts starts again. What I was wanting to do is when you use the keypad 3 times, no matter if you stop using it and start again, or use it 3 times in a row (which is working) you die. The issue I am having is that you can bypass this by entering and exiting the keypad and it keeps starting from the start. I wanted to make it so if you step out and step back into the keypad then second or third time the script would start on the second or third script I had created. eg these points:
2. PrintCentered ("ACCESS DENIED. SECURITY NOTIFIED")
PrintCentered ("You notice the wall above the door opens and a machine gun emerges. It is pointed at you.")
3. PrintCentered ("ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP")
PrintCentered ("An alarm sounds. The machine gun starts up. There is no way you can escape in time.")
PrintCentered ("YOU ARE NOW DEAD")
finish
Any help would be much appreciated in solving this issue.

Pertex
12 Jun 2014, 14:12I would do it this way:
adding a use script to the keypad which can be used 3 times. here is a picture of it:

and here the code of the script:
adding a use script to the keypad which can be used 3 times. here is a picture of it:

and here the code of the script:
if (not HasAttribute(game, "keypadused")) {
game.keypadused = 0
}
PrintCentered ("PLEASE ENTER SECURITY CODE")
get input {
if (result="4863") {
UnlockExit (office exit)
PrintCentered ("PASSWORD ACCEPTED, ACCESS GRANTED,")
PrintCentered ("OFFICE DOOR UNLOCKED")
}
else {
game.keypadused = game.keypadused+1
if (3>game.keypadused) {
PrintCentered ("ACCESS DENIED")
PrintCentered ("You notice a strange sound, like a machine being powered on.")
}
else {
PrintCentered ("ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP. ACCESS DENIED. BEEEEEEEEP")
PrintCentered ("An alarm sounds. The machine gun starts up. There is no way you can escape in time.")
PrintCentered ("YOU ARE NOW DEAD")
finish
}
}
}