ok maybe i should post the whole script XD
maybe theres something wrong with with() or so
NPC Code:
function onCreated(){
this.cur_target=-1;
this.walkgani="hex-metalspider-walk";
this.idlegani="hex-metalspider-idle";
this.hitgani="hex-metalspider-attack";
showcharacter();
setCharAni(this.idlegani,"");
setTimer(0.05);
}
function onTimeout(){
//chat=playerscount;
if(playerscount>0){
if(this.cur_target==-1){
this.pindexes=getnearestplayers(x,y);
thiso.newdistance=10;
thiso.newtarget=-1;
thiso.baddy_x=x;
thiso.baddy_y=y;
for(i: this.pindexes){
with(players[i]){
this.ddb_dx=player.x-thiso.baddy_x;
this.ddb_dy=player.y-thiso.baddy_y;
this.dist=(this.ddb_dx*this.ddb_dx+this.ddb_dy*thi s.ddb_dy)^.5;
if(this.dist<thiso.newdistance){
thiso.newtarget=player.account;
thiso.newdistance=this.dist;
player.chat="targeted";
}
}
}
chat=thiso.newtarget;
if(thiso.newtarget!=-1)this.cur_target=thiso.newtarget;
chat=this.cur_target;
}else{
this.tmp_plr=findplayer(this.target);
if(this.tmp_plr.level==level){
}else{
this.target=-1;
this.tmp_plr=null;
}
}
setTimer(0.05);
}
}
function onPlayerEnters(){
setTimer(0.05);
}
function onPlayerChats(){
if(player.chat="/dbb")
destroy();
}
//#CLIENTSIDE
function onCreated(){
// chat="test";
}
well as i said, this three lines
NPC Code:
chat=thiso.newtarget;
if(thiso.newtarget!=-1)this.cur_target=thiso.newtarget;
chat=this.cur_target;
it says -1 (means this.cur_target is till -1)
NPC Code:
chat=thiso.newtarget;
if(thiso.newtarget!=-1)this.cur_target=thiso.newtarget;
// chat=this.cur_target;
there it says an acc (means thiso.newtarget must be a acc);