It seems to be the case with both the V5 and V6 client that findnpcbyid(); is not working upon, or within a split second of entering or re-entering a level.
Lets say I have multiple NPCs containing:
PHP Code:
//#CLIENTSIDE
function onCreated(){
if(!(this.id in this.level.items)){
this.level.items.add(this.id);
}
}
And within another NPC I have:
PHP Code:
function onPlayerTouchsMe(){
for(temp.i : this.level.items){
temp.n = findnpcbyid(temp.i);
this.doSomething(temp.n);
}
}
If I were to somehow touch this NPC within a slight moment of re-entering the level, findnpcbyid(); fails to return the npc object. I'm pretty sure the problem is with findnpcbyid(); as all the id values within the array are fine.
Could this possibly be fixed within the new client?