|
Okay... Here's another decent trick:
If you have a lot more options on your server, but don't want to end up with twenty differant set of varialbes... I'll show you some Binary Convertor and how it could help. For you who doesn't know binary, I'll explain shortly: Binary is a number composed of 0's and 1's...
1111 = 1 + 2 + 4 + 8 = 15
So basically, if you have number 15, and want to put it in binary, you'd have "1111" as number. How would this be useful?
Lets say you have 10 possible on and off options, but don't want a string to look like:
option=1,0,1,0,0,1,0,1,1,1
you could have it in a nice interger that hackers would have a hard time guessing..
Convert BINARY to DIGIT
(incoming: put "binary" string as a binary list ^ As with option)
function bintodig(){
for (i=0;i<sarraylen(binary);i++){
value = strtofloat(#I(binary,i));
number = (value == 1) ? number + 2^i : number;
}
}
(outcoming: variable "number")
--
(incoming: put variable "number" in)
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;
}
}
(output: String List "Binary")
... There...
Basically, if you want to test that, you could do this:
if (playerchats){
number = #v(strtofloat(#c));
digtobin();
message #s(binary);
}
^ if you say "15", it'll give you 1,1,1,1. If you say 16, it'll give you 0,0,0,0,1. And so on... This could shorten your script, however it could also never be placed anywhere at all.
Hope this helps someone... :P
- Rance Vicious |