| 
 qglobals I am trying to understand Global Variables. Would this work? If not, why? Code: sub EVENT_SAY | 
| 
 Make sure you checked the setting for quest globals for the npc in npc_types | 
| 
 Ah, the npc needs qglobals enabled on them? I see. So as far as that, I got the syntax correct? | 
| 
 Quote: 
 | 
| 
 No need to assign a variable to the global, since the global is a variable. This would work better for you, and won't throw up warnings in the logs: Code: sub EVENT_SAY { | 
| 
 Quote: 
 | 
| 
 Quote: 
 | 
| 
 Do you guys know if it's possible to make a quest to where once an npc is hailed, no one else can talk to him until the global variable expires? | 
| 
 Yep, Code: quest::setglobal("name",1,2,"M10");Code: ----------------------------------------- | 
| 
 Is there way to make something like this.. But I want it so no one can get the first message once someone has hailed him. sub EVENT_SAY { if($text=~/hail/i && $var1 = 1) { quest::say("HI 2 u."); quest::setglobal("var1",1,2,"H25"); } if($text=~/hail/i && $var1 = 0) } quest::say("I wont talk to u now!"); } } sub EVENT_SPAWN { quest::delglobal("var1"); } ##this is so the npc can be hailed once he respawns. | 
| 
 You were real close. When dealing with globals, I do recommend using defined or !defined to avoid filling the log up with warnings. If you use a standard global == 1 check, and the global doesn't exist in the DB, it'll spam your log with warnings since the variable is undefined. Also, the hash version of globals: $globals{name} is preferred, as the non-hash version: $name==1 is depreciated. It also makes it easier to determine what is a user defined variable and what is a global by looking at the file.  Code: sub EVENT_SAY {Code: if($text=~/hail/i && defined $qglobals{var1} && $qglobals{var1} == 2){ | 
| 
 But will this make it so no one else can hail the mob either? | 
| 
 Yes, because option 2 for globals makes the global available to all players. If a global exists that the player has access to, they will always use it. Whether they were the one who created it or not originally is irrelevant in this case. | 
| 
 Ahhh! I get it now. Thanks for pointing that out to me.... | 
| All times are GMT -4. The time now is 05:16 AM. | 
	Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.