Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   How can I make clientside findareanpcs work reliably? (https://forums.graalonline.com/forums/showthread.php?t=84643)

Tyhm 03-12-2009 07:32 PM

How can I make clientside findareanpcs work reliably?
 
1 Attachment(s)
(I had posted all this, then it fixed itself for a bit, now it's broken again.)

Problem: See picture. The player's weapon:

PHP Code:

     if(player.chat==""player.chat = (area_npcs.size() SPC "npcs in area (" temp.lowestx ", " temp.lowesty  ", " temp.highestx  ", " temp.highesty @")"); 

And the NPCs have a fairly predictable "message your location and timevar";
the trouble is they keep updating the message - even with the timevar - serverside and clientside, no problem - but after they've been idling against a wall for long enough (hard to pin down exactly how long it needs to be; could be a few minutes, could be until a player re-enters the map, could be until a player re-logs, whatever) they Fall Off the findareanpcs results table.

Until the player makes them move. Then they're back in the detection area.

So do I just have to make the zombies move around every so often? :-P

Tyhm 03-12-2009 07:44 PM

Patch:
message("Idle2 v<r "@1+tt@" ("@tx@", "@ty@")"SPC timevar);
x=int(x-1+random(0,2));
y=int(y-1+random(0,2));

Horrible, but it works. I'm open to better suggestions...

xXziroXx 03-13-2009 02:05 PM

Maybe you have sleepwhennoplayers set to true in serveroptions?

Tyhm 03-13-2009 02:23 PM

Hmm, nope, don't see that in there. Would that do that though?

Mostly it just bugs me that movement, or the lack thereof, would cause findareanpcs to screw up...it's like, server, the NPC's either in the area or it isn't, whether or not the NPC's moving shouldn't affect things...

cbk1994 03-13-2009 09:33 PM

Are they still in the 'npcs' array?

Tyhm 03-13-2009 09:54 PM

Maybe; is there a findnpcs (findallnpcs, findlevelnpcs, findgmapnpcs) command hidden somewhere? ;-D

xXziroXx 03-13-2009 10:04 PM

Quote:

Originally Posted by Tyhm (Post 1474018)
Maybe; is there a findnpcs (findallnpcs, findlevelnpcs, findgmapnpcs) command hidden somewhere? ;-D

Just as Chris said, the npcs array.

Tyhm 03-14-2009 02:43 AM

Thank you captain smarmypants, that's the same as an answer. I suppose then that I could say with(npcs) or for (npc:npcs) and it's a protected variable which always contains an array of all NPCs on the server in perpetuity? Or should I be doing an old fashioned for(temp.i=0;temp.i<npcscount;temp.i++) if(npcs[i].x... ?

cbk1994 03-14-2009 09:15 AM

Quote:

Originally Posted by Tyhm (Post 1474153)
Thank you captain smarmypants, that's the same as an answer. I suppose then that I could say with(npcs) or for (npc:npcs) and it's a protected variable which always contains an array of all NPCs on the server in perpetuity? Or should I be doing an old fashioned for(temp.i=0;temp.i<npcscount;temp.i++) if(npcs[i].x... ?

'npcs' is an array of all the NPCs in your current level. Similar to the 'players' array.

PHP Code:

for (temp.npc npcs) {
  echo(
"I found an NPC at (" npc."," SPC npc.") with an image of" SPC npc.image "!");
  
npc.trigger("Poke"player.account);
  
npc.var = "foo";



Tyhm 03-14-2009 10:43 AM

Well shoot, I wish I'd known that a month ago, I coulda saved a lot of headache; I already run a specific scan on the NPCs in the area to make sure they're lined up with the player, above and beyond the findareanpcs' check to make sure they're in the right general box...

Works a bloody treat. Still ain't thrilled that findareanpcs is unreliable...but I'll live.

xXziroXx 03-14-2009 11:58 AM

Quote:

Originally Posted by Tyhm (Post 1474280)
findareanpcs is unreliable

It really shouldn't be, I use it for quite a lot and it hasn't failed me a single time...

salesman 03-14-2009 04:30 PM

Yea, I'm using it on a rather large scale and it's working perfectly...

xXziroXx 03-19-2009 02:04 AM

I just remembered reading this a while back, might be of help.


Quote:

Originally Posted by Stefan (Post 1447541)
If the npc is inactive or doesn't have a script, remember to wake it up when you add or modify data: a simple trigger("update", "") or similar will solve the problem.

Inactive npcs are not saved. It's the same problem when changing x or y of an inactive npc, you need to activate the npc so that the modifications are sent to the players.


Tyhm 03-19-2009 03:32 AM

Ahh. Good to know, thanks. I'm using the npc array and it's working swimmingly...which is good, because it'd be rather difficult to update an npc that wasn't saved anywhere at all ever...:-P


All times are GMT +2. The time now is 08:59 AM.

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