Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   getting level npcs problem (https://forums.graalonline.com/forums/showthread.php?t=134269954)

Kirko 05-07-2015 06:55 PM

getting level npcs problem
 
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
PHP Code:

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:

PHP Code:

  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

Quote:

Originally Posted by Kirko (Post 1736059)
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.


All times are GMT +2. The time now is 02:32 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.