I have pretty much lost all hope of figuring this out. Here's the code that I ended up with, try to figure it out if you can:
PHP Code:
function WeaponSelect() {
if((keydown(9) && !inws) || (mousescreenx < 70 && mousescreeny < 70 && mousedown)) {
disabledefmovement;
sleep 0.2;
setani idle,;
set inws;
setarray this.wlist,256;
this.p=0;
for (this.zfm=0;this.zfm<weaponscount;this.zfm++) {if (!startswith(-,#w(this.zfm))) this.wlist[this.p]==zfm;this.p++;}
}
if (inws) {
for(this.pi=0;selectedweapon!=this.wlist[this.pi];this.pi++) {;}
if(selectedweapon!=0)this.pi++;
showimg 1032,wpn2.png,13,74;
changeimgvis 1032,4;
showimg 1033,#W,13+7,74+43;
changeimgvis 1033,4;
showimg 1036,@ - #w,13+7+32+4+5,74+43+7;
changeimgvis 1036,4;
if(selectedweapon > 0) {
showimg 1034,#W(this.wlist[this.pi-1]),13+7,74+7;
changeimgcolors 1034,1,1,1,0.99;
changeimgvis 1034,4;
}else{hideimg 1034;}
if(selectedweapon < (weaponscount-1)) {
showimg 1035,#W(this.wlist[this.pi+1]),13+7,74+79;
changeimgcolors 1035,1,1,1,0.99;
changeimgvis 1035,4;
}else{hideimg 1035;}
if((keydown(5) || keydown(9)) || ((mousescreenx > 52 || mousescreeny > 185) && mousedown)) {
hideimg 1032;
hideimg 1033;
hideimg 1034;
hideimg 1035;
hideimg 1036;
enabledefmovement;
unset inws;
sleep 0.2;
}
if((keydown(0) || keydown(1)) || (mousescreenx > 20 && mousescreeny > 81 && mousescreenx < 52 && mousescreeny < 113 && mousedown)) {
for(this.zix=0;startswith(-,#w(selectedweapon-this.zix));this.zix++){;}
selectedweapon=selectedweapon-(this.zix+1);
sleep 0.1;
}
if((keydown(2) || keydown(3)) || (mousescreenx > 20 && mousescreeny > 153 && mousescreenx < 52 && mousescreeny < 185 && mousedown)) {
if(startswith(-,#w(selectedweapon+1))) {
selectedweapon=selectedweapon+2;
}else{
selectedweapon=selectedweapon+1;
}
sleep 0.1;
}
}
}