Quote:
Originally Posted by 0PiX0
No, although his script doesn't require a loop, he is looping it correctly. In arrays, the first element's index is 0, and the last element's index is array.size() - 1.
|
I didn't say he was looping it incorrectly, I just said it was rather strange compared to what he wanted to accomplish.
Anyway, it'd be much easier to just increment like this and perform some checks for this.i or whatever number he'll be using for the array [0] selector.
PHP Code:
//#CLIENTSIDE
function onCreated(){
this.i = 0;
}
function onKeyPressed(code, key){
if(key == "[" && this.i >= 0 && this.i < 3){
this.i++; // increment
player.chat = this.i; // print out for verification
}
else if(key == "/" && this.i > 0){ // don't decrement 0 to -1!
this.i--;
player.chat = this.i;
}
}
Then I guess you'd do something like: thiso.rights[this.i] (selectors, 0,1,2,3).