View Single Post
  #7  
Old 10-31-2013, 10:34 PM
HnathBST
Sarnak
 
Join Date: Feb 2007
Location: Sunset Home
Posts: 71
Default

Quote:
Originally Posted by Akkadius View Post
Something like this should work:

Code:
sub EVENT_SAY{
	if(!defined($qglobals{"TenTimeEvent"})){ $client->SetGlobal("TenTimeEvent", "10", 7, 'F'); }
	my $CountToZero = (10 - $qglobals{"TenTimeEvent"});
	if($text=~/hail/i){ quest::say("The fuck you want?"); $client->Message(15, quest::saylink("Make me a sammich", 1)); }
	if($text=~/sammich/i){ 
		if($qglobals{"TenTimeEvent"} > 0){
			quest::say("WHAT?! Fine... But I will only do it " . $CountToZero . " more time(s)..."); 
			$npc->SetGlobal("TenTimeEvent", ($qglobals{"TenTimeEvent"} - 1) , 7, 'F');
		}else{
			quest::say("Sorry man, I told you I wouldn't make you a sammich anymore...");
		}
	}
}
You need to have qglobals enabled on the npc (Set to 1) and it is set at a global scope, meaning any NPC can grab this qglobal variable if you tried to fetch it.

He sets it once and when the value of the qglobal has been subtracted to 0, he no longer will make a sammich
I think you have $CountToZero incorrect. If the Qglobal is set to 10, $CountToZero = 10 - 10 = 0. So the NPC would say "I'm only doing it 0 more times". Unless my logic is wrong.

I would say:
Code:
sub EVENT_SAY{
	if(!defined($qglobals{"TenTimeEvent"})){ $client->SetGlobal("TenTimeEvent", "10", 7, 'F'); }
	
	if($text=~/hail/i){ quest::say("The fuck you want?"); $client->Message(15, quest::saylink("Make me a sammich", 1)); }
	if($text=~/sammich/i){ 
		if($qglobals{"TenTimeEvent"} > 0){
			quest::say("WHAT?! Fine... But I will only do it " . ( $qglobals{"TenTimeEvent"} - 1). " more time(s)..."); 
			$npc->SetGlobal("TenTimeEvent", ($qglobals{"TenTimeEvent"} - 1) , 7, 'F');
		}else{
			quest::say("Sorry man, I told you I wouldn't make you a sammich anymore...");
		}
	}
}
That eliminates the $CountToZero variable that was only used once for text anyway.
Reply With Quote