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 02-05-2010, 05:03 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default Quest Globals

I wish i had some more info to give but I really don't so just hoping some one else maybe is experiencing this..

My Buff Bot used to take plat for players , and give them a credit depending on how much plat they gave.. But for some reason some times a player will hand money to the thing and it will totally forget that the player had given it anything..

Player handed the thing 5,000 plat , and then buffed ok but when he came back it said you have 0 credit..

When i went to check the database it clearly showed the player had 4950 (since he had buffed already the first time) But the NPC said no you have no credit..

This NPC is 5+ years old on my server and is Time Honored has never whacked out up until recently so not sure whats going on..

King
Reply With Quote
  #2  
Old 02-05-2010, 05:15 PM
pfyon's Avatar
pfyon
Discordant
 
Join Date: Mar 2009
Location: Ottawa
Posts: 495
Default

If you post the relevant quest script, it might help diagnose the problem.
Reply With Quote
  #3  
Old 02-05-2010, 05:53 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Most likely you are using the old way to access qglobals. You should be checking them by doing something like $qglobals{myglobalname} instead of just $myglobalname. Using the new way should work 100% of the time.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 02-05-2010, 06:25 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

Here is the Quest

Code:
#!/usr/bin/perl
 
# Level => (Cost, Buff set)
# Hash is iterated over, and as soon as player level is >= to hash level,
# cost is applied
my %pbuffs =
(
	65 => { cost => 1000, set => 'high' },
	55 => { cost => 500,  set => 'general' },
	45 => { cost => 450,  set => 'general' },
	30 => { cost => 300,  set => 'general' },
	20 => { cost => 150,  set => 'general' },
	0  => { cost => 0,    set => 'general' }
);

# Buff sets. Referenced by pbuffs
my %buffset =
(
	general => [2112, 2517, 8199, 1939, 2517],
	high    => [2112, 2517, 278,  13,   5257, 5396, 1939]
);

# Returns pbuff value for level
# Args: level
sub getpb
{
	my $level = shift;

	foreach $key (reverse sort keys %pbuffs)
	{
		if ($level >= $key)
		{
			return $pbuffs{$key};
		}
	}
}

# Returns buff cost for level
# Args: level
sub getbuffcost
{
	return getpb(shift)->{'cost'};
}

# Casts buffs given a name
# Args: array of spells
sub castspells
{
	foreach $spell (@_)
	{
		quest::selfcast($spell);
	}
}

# Returns buff set for level
sub getbuffset
{
	return @{$buffset{getpb(shift)->{'set'}}};
}

sub EVENT_SPAWN
{
quest::settimer(1,1);
}

sub EVENT_SAY 
{
	my $saylink1 = quest::saylink("buffs");
	my $saylink2 = quest::saylink("pay");
	my $cost = getbuffcost($ulevel);
	my @buffs = getbuffset($ulevel);
	my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
if (defined $qglobals{hkchinese})
{
	if ($text =~ /hail/i)
	{
		quest::say("Ru guo nin xu yao yi xie buff [$saylink1], gao shu wo, dang ran, nin ke
neng xu yao fu dian dai jia [$saylink2].");
		$npc->SetAppearance(0);
		quest::settimer(1,10);
	}
	elsif ($text =~ /buffs/i)
	{
		if ($credit < $cost)
		{
			quest::say("Xiao gui, ni xiang pian guo wo ma? mei na me rong yi! ni xu yao zhi shao"
				. ($cost - $credit) . " PP.");
		}
		else
		{
			castspells(@buffs);
 
			# Only record and say this stuff if there was a cost
			if ($cost > 0)
			{
				$credit -= $cost;
				quest::setglobal('buffcredit', "$credit", 5, 'F');
				quest::say("Xie xie nin, $name! zai wo zhe li, nin hai sheng xia $credit PP ke yi 
buff.");
			}
		}
	}
	elsif ($text =~ /pay/i)
	{
		if ($cost > 0)
		{
			quest::say("Rang wo kan kan, $race.. nin zui shao xu yao $cost PP, bu neng zai 
jiang jia le.");
			quest::say("Nin hai you $credit PP zai wo zhe li, ru guo nin da suan zai cun yi
xie,"
				. " zhi jie ba PP gei wo jiu ke yi le");
		}
		else
		{
			quest::say("Nin kan shang qu xiang ge nian qing ren, $name. mian fei!");
		}
	}
}
else
{
 
	if ($text =~ /hail/i)
	{
		quest::say("If you want some [$saylink1] just let me know.  Of course you may have to [$saylink2].");
		$npc->SetAppearance(0);
		quest::settimer(1,10);
	}
	elsif ($text =~ /buffs/i)
	{
		if ($credit < $cost)
		{
			quest::say("Phuh!  Are you trying to cheat me?  You need "
				. ($cost - $credit) . " more plat!");
		}
		else
		{
			castspells(@buffs);
 
			# Only record and say this stuff if there was a cost
			if ($cost > 0)
			{
				$credit -= $cost;
				quest::setglobal('buffcredit', "$credit", 5, 'F');
				quest::say("Thanks $name!  You have $credit left in credit.");
			}
		}
	}
	elsif ($text =~ /pay/i)
	{
		if ($cost > 0)
		{
			quest::say("Let's see, $race.. For you? A lowly $cost plat!");
			quest::say("You have $credit plat in credit.  If you want more credit,"
				. " just hand me some plat!");
		}
		else
		{
			quest::say("You look like a nice young $race, $name.  No charge for you!");
		}
	}
}
}
sub EVENT_ITEM
{
	my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
 if (defined $qglobals{hkchinese})
{
	if ($platinum > 0)
	{
		$credit += $platinum;
		quest::setglobal('buffcredit', "$credit", 5, 'F');
		quest::say("Xie xie $name! nin xian zai you $credit PP zai wo zhe li!");
	}
	else 
		{
		plugin::return_items(\%itemcount);
    		}
 }
else
{
	if ($platinum > 0)
	{
		$credit += $platinum;
		quest::setglobal('buffcredit', "$credit", 5, 'F');
		quest::say("Thank You $name! You now have $credit PP credit");
	}
	else 
		{
		plugin::return_items(\%itemcount);
    		}
}
}
Reply With Quote
  #5  
Old 02-05-2010, 06:52 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Hmm, from what I can tell, that looks ok to me. The only thing that stands out is that you use single quotes instead of double quotes for setting the name of your qglobals. I dunno what affect that might have, but I always use double quotes around the name of the qglobal.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #6  
Old 02-05-2010, 09:34 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Ar you sure you have qglobals enabled for this npc? This script runs fine on my machine. Only thing I had to do was remove some extra line breaks (possible format error when posting).
Reply With Quote
  #7  
Old 02-06-2010, 02:08 PM
KingMort
Banned
 
Join Date: Sep 2006
Posts: 841
Default

Oh yeah like I said it's an extremely old system dating back 5+ years anyway I have a theory could it be the fact that my quest globals table has 45,762 total entries in it?? Would this be causing a problem due to the sheer size of the table or what do you guys think
Reply With Quote
  #8  
Old 02-07-2010, 05:03 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

I doubt it. Mine has like 41k entries in it without issues.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #9  
Old 02-07-2010, 03:40 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

63,575 beat you both! :P
Reply With Quote
Reply


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 06:45 PM.


 

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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3