PDA

View Full Version : getting level npcs problem


Kirko
05-07-2015, 06:55 PM
I'm having trouble trying to get all the npcs in a single level. Right now I'm just trying to change the npcs chat. When ever I attempt to change their chat only two npcs in the level get found and their chat doesnt change until I grab them.

here is what im using to find the level npcs
function onActionServerSide(cmd){
switch(cmd){
case"start":
player.chat = "start";
temp.npcs = findlevel(params[1]).npcs;
for(temp.i:temp.npcs){
temp.i.chat = "testing 123";
player.chat = temp.i.x SPC temp.i.chat;
//waitfor("","idk",.5);
}
break;
}
}

Jakov_the_Jakovasaur
05-07-2015, 07:04 PM
hello!

several years ago the npc-server was updated so that variables within npcs only synchronise to players clients upon an event occurring

if you add:


temp.i.trigger("Update");


within the for loop (the event function does not have to actually exist, though i would personally change the npcs chat variable within the event just for clarity) it should force the chat to synchronise

Kirko
05-07-2015, 07:15 PM
Thank you, it worked but I still have the problem where only 2 npcs are affected. I have a total of 4 npcs in the level but only two of them get changed.

http://i.imgur.com/SJQWTly.png

Jakov_the_Jakovasaur
05-07-2015, 07:21 PM
Thank you, it worked but I still have the problem where only 2 npcs are affected. I have a total of 4 npcs in the level but only two of them get changed.

http://i.imgur.com/SJQWTly.png

do the other 2 npcs have any custom serverside code or a setshape?

npcs which dont have any code beyond default synchronisation variables are actually considered un-necessary by the npc-server, and are therefore automatically removed from level.npcs[] serverside (as these are usually only necessary clientside)

Kirko
05-07-2015, 07:32 PM
okay now it works perfect, thank you again!
I had some client side script in the two npcs and just deleted it since it wasn't needed.