PDA

View Full Version : NPCS not updating?


KuJi
08-25-2006, 09:29 AM
Okay this has to be the MOST ANNOYING thing in the world.

I have a public function being called from a localnpc via findNPC() which works and all then it would message("") whatever the outcome is blah blah.

Well for some reason the message only will change if I say something, reconnect, or a player enters.


function onCreated()
{
setimg("block.png");
}

function onActionGrab()
{
findNPC("localnpc_g_kuji-testlvl_35088589_0").message("wtf");
}


The above code should work, but it doesn't. If I grab the block that changes the message, then say something it'll change.
nothing works

Maniaman
08-25-2006, 09:36 PM
I have noticed that npcs do not update clientside unless you reconnect for some odd reason.

Tolnaftate2004
08-25-2006, 09:46 PM
It may be that you're trying to overload the message function. Did you try naming the function something different?

KuJi
08-25-2006, 09:51 PM
Well this is totally a serverside npc - I tried making a regular function which called the message function which didnt do much. It seems that only message this happens too

KuJi
08-25-2006, 10:03 PM
Okay, my solution was to triggeraction to itself on the clientside to do displaying of msg whatever :o

Admins
08-26-2006, 01:47 PM
When you modify some other npc then it will not be updated, since it is inactive. Best way is to activate it afterwards by triggering it:


function onActionGrab() {
with (findNPC("localnpc_g_kuji-testlvl_35088589_0")) {
message("wtf");
trigger("update","");
}
}


Since might sound strange, but the npcserver is just not caring about inactive npcs, because the total number of npcs is often 100 times bigger than the number of active npcs, so checking all npcs for updates would slow down the server. It could be possible to let the npc activate itself though, will check sometime if that is possible.

KuJi
08-26-2006, 07:55 PM
When you modify some other npc then it will not be updated, since it is inactive. Best way is to activate it afterwards by triggering it:


function onActionGrab() {
with (findNPC("localnpc_g_kuji-testlvl_35088589_0")) {
message("wtf");
trigger("update","");
}
}


Since might sound strange, but the npcserver is just not caring about inactive npcs, because the total number of npcs is often 100 times bigger than the number of active npcs, so checking all npcs for updates would slow down the server. It could be possible to let the npc activate itself though, will check sometime if that is possible.

Yeah, my solution was to trigger an action to itself :o