NPC Code:
function destroyBoxes() {
if(strtofloat(#I(clientr.boxes,0))>=1 && mousedown && leftmousebutton && !noclose) {
for(this.i=1;this.i<=strtofloat(#I(clientr.boxes,0 ));this.i++) {
if(mousescreenx in |strtofloat(#I(clientr.boxes,this.i*2-1))+189,strtofloat(#I(clientr.boxes,this.i*2-1))+198| && mousescreeny in |strtofloat(#I(clientr.boxes,this.i*2))+3,strtoflo at(#I(clientr.boxes,this.i*2))+16|) {
set noclose;
deletestring clientr.boxes,strtofloat(#I(clientr.boxes,this.i*2-1));
deletestring clientr.boxes,strtofloat(#I(clientr.boxes,this.i*2-1));
replacestring clientr.boxes,0,#v(strtofloat(#I(clientr.boxes,0))-1);
unset noclose;
}
}
}
}
Can anyone suggest what this code needs, besides cleaning up? Currently, it'll only work (to delete a box object) if there is something at the x,y coordinates specified, and even then it'll only delete the end box. Anyone have an idea? Also, the strings are a necessity, as the script is multi-level.