SA-MP Forums Archive
Random Fires script = fail. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random Fires script = fail. (/showthread.php?tid=388154)



Random Fires script = fail. - Swyft™ - 27.10.2012

Under OnGameModeInit
pawn Код:
// Fire Explosions
    SetTimer("OnBurgerExplosion", 1000000, true);
for the other timers, and explosions
pawn Код:
public OnBurgerExplosion(playerid)
{
    format(szMessage, sizeof(szMessage), "DISPATCH: We need dispatch at Main Street, Burger Shot. Flames are blazing, careful!");
    SendToGroupType(4, COLOR_RED, szMessage);
    SendToGroupType(1, COLOR_RED, szMessage);
    OnBurgerExplosion98 = SetTimer("OnBurgerExplosion2", 3000, true);
    return 1;
}

public OnBurgerExplosion2(playerid)
{
    CreateExplosion(-174.3882,1065.7659,19.7422, 2, 50.0);
    CreateExplosion(-169.6261,1088.7214,19.7422, 2, 50.0);
    OnBurgerExplosionStop99 = SetTimer("OnBurgerExplosionStop", 300000, true);
    return 1;
}

public OnBurgerExplosionStop(playerid)
{
    KillTimer(OnBurgerExplosion98);
    KillTimer(OnBurgerExplosionStop99);
    return 1;
}
See, it all works the first time. but the times after it doesn't... Anyone have any ideas on how to fix it, I have a feeling that KillTimer is affecting it.. But idk

And if you help me, how would I add MORE and MORE random fires you know?


Re: Random Fires script = fail. - Swyft™ - 27.10.2012

BUMP!


Re: Random Fires script = fail. - Swyft™ - 27.10.2012

Hmm, can you guys please help?


Re: Random Fires script = fail. - Catalyst- - 27.10.2012

There was no need to have so many public functions.
The only one you need is this one:
pawn Код:
public OnBurgerExplosion(playerid)
{
    static explode;
    if(explode == 0) {
        format(szMessage, sizeof(szMessage), "DISPATCH: We need dispatch at Main Street, Burger Shot. Flames are blazing, careful!");
        SendToGroupType(4, COLOR_RED, szMessage);
        SendToGroupType(1, COLOR_RED, szMessage);
    }
    explode++;
    if(explode < 100)
        SetTimer("OnBurgerExplosion", 3000, false);
    else
        explode = 0;
    CreateExplosion(-174.3882,1065.7659,19.7422, 2, 50.0);
    CreateExplosion(-169.6261,1088.7214,19.7422, 2, 50.0);
    return 1;
}



Re: Random Fires script = fail. - Swyft™ - 27.10.2012

Thanks, so I don't need OnBurgerExplosionStop or OnBurgerExplosion2?


Re: Random Fires script = fail. - Catalyst- - 27.10.2012

No, you only need the one that I posted.


Re: Random Fires script = fail. - Swyft™ - 27.10.2012

And this will keep going every time the timer activates basically?


Re: Random Fires script = fail. - Catalyst- - 27.10.2012

Yeah, this will loop forever, just make sure to keep the timer under OnGameModeInit.
pawn Код:
SetTimer("OnBurgerExplosion", 1000000, true);