This probably isnt the best way...but...
NPC Code:
//#CLIENTSIDE
if (created || initialized) { // Main block
setstring this.key,a; // Key that can be hit twice [needs different script for arrow keys]
this.time = .3; // Time before the pressed thing expires.
timeout = .05; // Start our loop!
}
if (timeout) { // Self explanitory...
timeout = .05; // Timeout loop
if (this.presstime > 0) { // See how long since you pressed the key
this.presstime -= .05; // Take time out of the variable
} else {
this.presstime = 0; // Make sure we dont have negative time
if (this.pressnumber > 0) this.pressnumber = 0; // Timed out
}
if (keydown2(keycode(#s(this.key)),true)) { // Check if our key is pressed
if (this.keydown == false) { // Only work if the key is not held down
this.keydown = true; // Tell the script the key is held down
if (this.pressnumber == 0) { // Do stuff if number is this blah blah
this.pressnumber = 1; // set the pressed index to 1
this.presstime = this.time; // Time before key pressed resets
} else {
this.pressnumber=0; // Reset press index
this.presstime = 0; // Reset press time
doactions(); // Output
}
}
} else {
this.keydown = false; // Say its not being held down anymore
}
}
function doactions() { // Code for what happens when you hit a key twice.
setplayerprop #c,I hit a key twice! I'm a genious!; // omg kid, you rock!
}
Heres something I thought might help...I don't know if this works, I didn't test it.
Edit:
Tested it and fixed bugs.