Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2009, 02:45 PM
Richardo
Banned
 
Join Date: Oct 2003
Location: Mattmecks Basement
Posts: 546
Default qglobals

I am trying to understand Global Variables. Would this work? If not, why?

Code:
sub EVENT_SAY
my $conversation = $qglobals{remember_conv};
{
if($text=~/hail/i && $conversation = "0")
{
quest::setglobal("remember_conv", $conversation, 5, "F");
quest::say("I will remember you, next time you hail me!");
}
if($text=~/hail/i && $conversation = "1");
{
quest::say("We have talked before!");
}
}
Reply With Quote
  #2  
Old 01-21-2009, 02:52 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

Make sure you checked the setting for quest globals for the npc in npc_types
Reply With Quote
  #3  
Old 01-21-2009, 02:53 PM
Richardo
Banned
 
Join Date: Oct 2003
Location: Mattmecks Basement
Posts: 546
Default

Ah, the npc needs qglobals enabled on them? I see. So as far as that, I got the syntax correct?
Reply With Quote
  #4  
Old 01-21-2009, 03:00 PM
Andrew80k
Dragon
 
Join Date: Feb 2007
Posts: 659
Default

Quote:
Originally Posted by Richardo View Post
Ah, the npc needs qglobals enabled on them? I see. So as far as that, I got the syntax correct?
Close. Make sure you have "==" or "eq" (in the case of string comparison) in your if statements. Which you would probably figure out as soon as you ran it.
Reply With Quote
  #5  
Old 01-21-2009, 03:13 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

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 {
  if($text=~/hail/i && !defined $qglobals{conversation}){
quest::setglobal("conversation", 1, 0, "F");
quest::say("I will remember you, next time you hail me!");
 }
  elsif($text=~/hail/i && defined $qglobals{conversation}){
quest::say("We have talked before!");
 }
}
Reply With Quote
  #6  
Old 01-22-2009, 06:17 PM
Richardo
Banned
 
Join Date: Oct 2003
Location: Mattmecks Basement
Posts: 546
Default

Quote:
Originally Posted by Andrew80k View Post
Close. Make sure you have "==" or "eq" (in the case of string comparison) in your if statements. Which you would probably figure out as soon as you ran it.
Yeah I understand general things like that. == for intergers eq for strings. Thanks for your help guys!
Reply With Quote
  #7  
Old 01-22-2009, 07:22 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

Quote:
Originally Posted by Richardo View Post
Ah, the npc needs qglobals enabled on them? I see. So as far as that, I got the syntax correct?
We never had to do this at first (would work anyways), but now we do, so it's always the first thing I forget when I do quests.
Reply With Quote
  #8  
Old 01-24-2009, 07:49 PM
Richardo
Banned
 
Join Date: Oct 2003
Location: Mattmecks Basement
Posts: 546
Default

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?
Reply With Quote
  #9  
Old 01-24-2009, 08:03 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Yep,

Code:
quest::setglobal("name",1,2,"M10");
will be available to the NPC who called it, from the zone they called it in, and to all players for 10 minutes. The second number is the option and what calls this behavior. Here are the proper values, taken from the wiki:

Code:
-----------------------------------------
|  value |  npcid  |  player |   zone   |
-----------------------------------------
|   0    |  this   |   this  |   this   |
|   1    |  all    |   this  |   this   |
|   2    |  this   |   all   |   this   |
|   3    |  all    |   all   |   this   |
|   4    |  this   |   this  |   all    |
|   5    |  all    |   this  |   all    | 
|   6    |  this   |   all   |   all    |
|   7    |  all    |   all   |   all    |
-----------------------------------------
Reply With Quote
  #10  
Old 01-25-2009, 03:12 PM
Richardo
Banned
 
Join Date: Oct 2003
Location: Mattmecks Basement
Posts: 546
Default

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.

Last edited by Richardo; 01-25-2009 at 11:37 PM..
Reply With Quote
  #11  
Old 01-25-2009, 03:50 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

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 {
if($text=~/hail/i && !defined $qglobals{var1}){ //Global is not defined, talk to them.
quest::say("HI 2 u.");
quest::setglobal("var1",1,2,"H25");
}
if($text=~/hail/i && defined $qglobals{var1}){ //Global is defined with a value of 1, don't talk to them.
quest::say("I wont talk to u now!");
 }
}
sub EVENT_SPAWN {
quest::delglobal("var1"); //We want the NPC to be hailed when he pops.
}
A bit off topic, but in case you're wondering, if you need to check a global for a value other than 0 or 1 you'd do a:

Code:
if($text=~/hail/i && defined $qglobals{var1} && $qglobals{var1} == 2){

Last edited by cavedude; 01-25-2009 at 11:56 PM..
Reply With Quote
  #12  
Old 01-26-2009, 12:10 PM
Richardo
Banned
 
Join Date: Oct 2003
Location: Mattmecks Basement
Posts: 546
Default

But will this make it so no one else can hail the mob either?
Reply With Quote
  #13  
Old 01-26-2009, 01:16 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

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.
Reply With Quote
  #14  
Old 01-26-2009, 05:41 PM
Richardo
Banned
 
Join Date: Oct 2003
Location: Mattmecks Basement
Posts: 546
Default

Ahhh! I get it now. Thanks for pointing that out to me....
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:00 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3