| Luccian | 
			02-01-2012 01:03 PM | 
		 
		 
		 
		
			Settimer variables   
		
		
		Good Morning, 
I am working on a small script to add a little flavor to a zone I have been working on for a server. So far it works with a set timer, however when I realized all the NPCs would be swinging their picks in unison I decided it may be best to implement some sort of variable. Sadly my attempts to seems to have broken the loop somehow. Would someone mind giving this a good once over and maybe point out what could be wrong?
 
This one works-
 
	Code: 
	
 sub EVENT_SPAWN 
{ 
        quest::settimer("woodcut",1); 
} 
sub EVENT_TIMER 
{ 
        if ($timer eq "mine") 
        { 
                # Random Animations: 2h slash and 1h slash 
                my $anivar1=quest::ChooseRandom(3,5); 
                quest::doanim($anivar1); 
                quest::settimer("woodcut",3); 
        } 
} 
sub EVENT_SAY  
{ 
        if($text=~/Hail/) 
        { 
                quest::emote("appears to be dripping in sweat as they chip away at large chunks of ore and crystal"); 
                quest::say("I don't mean to be rude but go away. There is enough work to do here without some outsider wasting our precious daylight."); 
        } 
} 
 I tried with just a simple quest::ChooseRandom but it didnt work, but looked like-
 
	Code: 
	
 sub EVENT_SPAWN 
{ 
        quest::settimer("woodcut",1); 
} 
sub EVENT_TIMER 
{ 
        if ($timer eq "mine") 
        { 
                # Random Animations: 2h slash and 1h slash 
                my $anivar1=quest::ChooseRandom(3,5); 
                quest::doanim($anivar1); 
                # Random Timer value between 1 and 5 seconds 
                my $randomnum=quest::ChooseRandom(1,2,3,4,5); 
                quest::settimer("woodcut",$randomnum); 
        } 
} 
sub EVENT_SAY  
{ 
        if($text=~/Hail/) 
        { 
                quest::emote("appears to be dripping in sweat as they chip away at large chunks of ore and crystal"); 
                quest::say("I don't mean to be rude but go away. There is enough work to do here without some outsider wasting our precious daylight."); 
        } 
} 
 I also tried to download and use the RandomRange plugin I saw used in another script, however I either didnt use it properly or the syntax is wrong. In any case it is here-
 
	Code: 
	
 sub EVENT_SPAWN 
{ 
        quest::settimer("woodcut",1); 
} 
sub EVENT_TIMER 
{ 
        if ($timer eq "mine") 
        { 
                # Random Animations: 2h slash and 1h slash 
                my $anivar1=quest::ChooseRandom(3,5); 
                quest::doanim($anivar1); 
                # Random Timer value between 1 and 5 seconds 
                my $randomnum=plugin::RandomRange(1,5); 
                quest::settimer("woodcut",$randomnum); 
        } 
} 
sub EVENT_SAY  
{ 
        if($text=~/Hail/) 
        { 
                quest::emote("appears to be dripping in sweat as they chip away at large chunks of ore and crystal"); 
                quest::say("I don't mean to be rude but go away. There is enough work to do here without some outsider wasting our precious daylight."); 
        } 
} 
 *Note* The plugin is saved as "RandomRange" in my plugins folder, in case someone were to ask.
 
I appreciate the help folks =)  
	 |