Quote:
Originally Posted by Maceblade
This may be an odd request, but I was looking at creating an NPC that hands out a reward to the first 10 hails and then depops forever, however I have no idea how to write it.
The only way I know how to do it is to create 10 seperate npc id's all controlled by triggers, when #1 is hailed it depops and spawns #2 etc and once #10 is hailed he depops forever. The only issue is I have no way to keep one person from doing multiple hails unless I can have it check for the item in inventory first.
I guess I was just looking to see if someone had an easier way to do this.
|
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
