EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Settimer variables (https://www.eqemulator.org/forums/showthread.php?t=34822)

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 =)

trevius 02-02-2012 04:00 AM

Take a closer look at your scripts you posted. Even the one you posted that you said works, would not actually work.

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.");
        }
}

You need to check for the same timer name in EVENT_TIMER that you set the timer as in EVENT_SPAWN.

Other than that, your 2 random timer scripts look fine.

Luccian 02-02-2012 06:25 AM

Looks like you were right Trev. I thought I had the timers set correctly the first time but appears I was wrong. I appreciate the help pointing out my very obvious problem with the script =P
Plugin works great, random number selection great, all around good experiences with this. Thanks again.


All times are GMT -4. The time now is 05:24 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.