When firing a weapon put:
NPC Code:
setarray this.keydown,10;
for (i=0;i<10;i++)
this.keydown[i] = (i == 4) ? 1 : 0;
Then, in the timeout loop, put keys();
then, outside everything, put:
NPC Code:
function keys(){
for (i=0;i<10;i++)
this.keydown[i] = keydown(i) ? this.keydown[i] + 1 : 0;
}
NPC Code:
command = lindexof(#c,commands);
if (command == 0) playerhearts = playerfullhearts;
if (command == 1) playerhearts = 0;
if (command == 2) warpto localstartarea.nw,30,30;
NPC Code:
setstring commands,buy,add,remove,withdraw,deposit;
tokenize #c;
command = lindexof(#t(0),commands);
if (command < 1){ // User Commands
so-so;
} else { // Admin Commands
so-so;
}
\----\
Binary to Digit:
NPC Code:
function bintodig(){
for (i=0;i<sarraylen(binary);i++){
value = strtofloat(#I(binary,i));
number = (value == 1) ? number + 2^i : number;
}
}
Digit to Binary:
NPC Code:
function digtobin(){
num = number;
len = 0;
for (i=0;len == 0;i++)
len = num < 2^i ? i : 0;
setstring binary,;
for (i=(len-1);i>=0;i--){
value = number < 2^i ? 0 : 1;
insertstring binary,0,#v(value);
number = (number < 2^i) ? number : number - 2^i;
}
}
Want to Test it out?
NPC Code:
if (playerchats){
number = #v(strtofloat(#c));
digtobin();
message #s(binary);
}
function digtobin(){
num = number;
len = 0;
for (i=0;len == 0;i++)
len = num < 2^i ? i : 0;
setstring binary,;
for (i=(len-1);i>=0;i--){
value = number < 2^i ? 0 : 1;
insertstring binary,0,#v(value);
number = (number < 2^i) ? number : number - 2^i;
}
}
Well... Hope that helps.