Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   NPCs incorrect information (alter npc load order?) (https://forums.graalonline.com/forums/showthread.php?t=83086)

RozenMaiden 12-10-2008 12:02 AM

NPCs incorrect information (alter npc load order?)
 
Hi,

so I currently have a little problem.

I have an npc that scans for a special type of other npcs in the npcs array of the level at onCreated(); now that worked fine, but now i'm scanning for 2 special types and a problem came up: it scans too early.

I wouldn't like to use sleep or something like that to delay the scan. Because if it scans at onCreated atleast one of the second-special-type npcs hasnt set its attribs (nick, etc) yet and thus isnt recognized as that special-type-npc by the main npc. Now my question is it possible to delay the loading of an npc? Like let it load and call onCreated() after all other npcs are loaded?

Tigairius 12-10-2008 12:19 AM

You can delay the loading of the rest of the NPC by doing this I guess
PHP Code:

//#CLIENTSIDE
function onCreated() {
  while (
temp.wait 10) {
    
temp.wait++;
    
sleep(0.05);
  }
  [
Other Stuff Here]


But it would probably be better practice to do it this way:
PHP Code:

function onCreated() {
  
scheduleEvent(1"NewCreated"NULL);
}

function 
onNewCreated() {
  [
Other Stuff Here]



RozenMaiden 12-10-2008 12:40 AM

Yeah I know that, but I'd like a way that makes sure all other npcs have loaded. Is there something like that?

Tigairius 12-10-2008 12:57 AM

Quote:

Originally Posted by RozenMaiden (Post 1448236)
Yeah I know that, but I'd like a way that makes sure all other npcs have loaded. Is there something like that?

Shouldn't take more than 0.05 seconds for all of the NPCs to load.

RozenMaiden 12-10-2008 02:57 PM

Hm guess i'll just delay it by 1 sec then, ty

another problem:

i have a problem with an npc. it's called by another npc but it doesnt do anything before i grab it? O_o

someone told me it may be that the npc may be "inactive" (as graal thinks it does nothing). how do i work around that

Crow 12-10-2008 05:34 PM

Quote:

Originally Posted by RozenMaiden (Post 1448336)
Hm guess i'll just delay it by 1 sec then, ty

another problem:

i have a problem with an npc. it's called by another npc but it doesnt do anything before i grab it? O_o

someone told me it may be that the npc may be "inactive" (as graal thinks it does nothing). how do i work around that

Try this:
PHP Code:

npc.trigger("update"nil); 


RozenMaiden 12-10-2008 05:35 PM

uh well, do i only have to do that one time or everytime i do an update?


All times are GMT +2. The time now is 12:26 PM.

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