PDA

View Full Version : Problem encountered when several mobs are polling a global...


Ignorance
08-12-2011, 02:28 AM
Here is the error text I get when the server is run.

[Quest] Use of uninitialized value $qst999175::qglobals{"FightClubFreeportController"} in int at quests/freporte/LocalController.pl line 46.

Three NPCs from three different zones are polling qglobals{"FightClubFreeportController"} every 5 seconds.
One NPC reads the value fine; the other two don't.

They all run the same script, and here is line 46...
$controller = int($qglobals{FightClubFreeportController});

From what I can gather, whichever NPC spawns first somehow takes control of $qglobals{FightClubFreeportController}.

$qglobals{FightClubFreeportController} is defined, well before any of the accessing NPCs spawn, as...
quest::setglobal( "FightClubFreeportController", 1, 7, "F" );

Any thoughts are welcome.
I can drop the related scripts if requested.

joligario
08-12-2011, 05:09 AM
I don't think any NPC gains a lock on the global. The other two NPCs have quest globals enabled? Are you using the quotes in the other files or did your output just show that?

Ignorance
08-12-2011, 05:41 AM
Globals are enabled for the other mobs.
The quotes are just from the output; they are not in the file.

lerxst2112
08-12-2011, 08:29 AM
To see the globals that apply to a particular NPC you can target them and type #globalview

You can also look in the quest_globals table in your database to see them all. Anything that has charid, npcid, and zoneid all set to 0 should be accessible from anywhere. These are based on the flags you passed in when you created it.

joligario
08-12-2011, 08:36 AM
I don't see anything wrong with the 2 lines you posted. Possibly somewhere else in the script.

Ignorance
08-13-2011, 11:01 AM
@lerxst2112
I checked the quest_globals table and did find a couple weirdly set variables, likely from the first run of the script, so I deleted all the entries and booted the server again.
All quest_global entries now read 0 for npcid, zoneid and charid.
I no longer am getting the error, but still the problem persists.
Of the three mobs trying to read the variable, only one can.
The others don't actually see the variable as defined.
if( defined $qglobals{FightClubFreeportController} )
...
Works for the NPC in the zone that starts first, the zones afterwards see the variable as nonexistent.

joligario
08-13-2011, 12:41 PM
Do your NPCs have the same NPCID across zones?

Ignorance
08-13-2011, 10:24 PM
They do not share the same NPCID, that's something I was planning to try.
I'll give it a shot.

joligario
08-13-2011, 11:04 PM
Hehe. Actually, I was going to say that we've been running into cross-zone script problems when you use the same npc in the database for multiple zones.

Ignorance
08-14-2011, 11:23 AM
@joligario
Funny

I tried the scripts with all the NPCs sharing the same NPCID and the problem is still the same.

Ignorance
08-15-2011, 06:03 PM
Problem resolved.

I ended up having to make a variable for each mob.
Whats odd is that only one variable was effected.
I have others that are accessed in a similar manner, but have no issues.