I prefer using a global system for buff 'credit'.
Code:
sub EVENT_SPAWN
{
quest::settimer(1,1);
}
sub EVENT_SAY
{
my $cost = 500;
my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
if ($text =~ /hail/i)
{
quest::say("If you want some [buffs] say the keyword.. They will cost $cost plat.");
$npc->SetAppearance(0);
quest::settimer(1,10);
}
elsif ($text =~ /buffs/i)
{
if ($credit < $cost)
{
quest::say("No can do sir. You need ".($cost - $credit)." more plat!");
}
else
{
quest::selfcast(2112);
quest::selfcast(2517);
quest::selfcast(8199);
quest::selfcast(1939);
quest::selfcast(2517);
if ($cost > 0)
{
$credit -= $cost;
quest::setglobal('buffcredit', "$credit", 5, 'F');
quest::say("Thanks $name! You lost $cost and now have $credit.");
}
}
}
}
sub EVENT_ITEM
{
my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
if ($platinum > 0)
{
$credit += $platinum;
quest::setglobal('buffcredit', "$credit", 5, 'F');
quest::say("Thanks $name! You now have $credit in credit!");
}
else
{
plugin::return_items(\%itemcount);
}
}
sub EVENT_TIMER
{
if($timer eq "1")
{
$npc->SetAppearance(1);
quest::stoptimer(1);
quest::settimer(1,5);
}
}