Timer
#7

Like nobody noticed he's formatting the timer's variable? Come on.

pawn Code:
format(str, sizeof(str), "%d", CountDownTimer);
The tutorial you got this code from is wrong, you should format countvar.

And you don't need 128 cells for just a decimal number, I've changed it to 6, I don't expect from someone to call a countdown for an hour or more, but feel free to increase it if you want.

Final code:

pawn Code:
#include <a_samp>

new countvar = 10;
new CountDownTimer;

public OnFilterScriptInit()
{
    CountDownTimer = SetTimer("CountDown", 1000, true);
    return 1;
}

forward CountDown();
public CountDown()
{
    countvar--;
    new str[6];
    if(countvar == 0)
    {
        KillTimer(CountDownTimer);
        countvar = 4;
    }
    else
    {
        format(str, sizeof(str), "%d", countvar);
        GameTextForAll(str, 1000, 1);
        // uncoment this if you want to test it without getting in game -- printf("%d", countvar);
    }
}
Reply


Messages In This Thread
Timer - by Heress - 31.10.2018, 08:46
Re: Timer - by DaniceMcHarley - 31.10.2018, 08:51
Re: Timer - by Heress - 31.10.2018, 08:57
Re: Timer - by ReD_HunTeR - 31.10.2018, 09:02
Re: Timer - by Heress - 31.10.2018, 09:03
Re: Timer - by IceBilizard - 31.10.2018, 09:03
Re: Timer - by TheToretto - 31.10.2018, 09:18
Re: Timer - by Heress - 31.10.2018, 09:26
Re: Timer - by TheToretto - 31.10.2018, 09:29
Re: Timer - by Heress - 31.10.2018, 09:44
Re: Timer - by TheToretto - 31.10.2018, 10:10
Re: Timer - by Heress - 31.10.2018, 10:45
Re: Timer - by Heress - 31.10.2018, 10:48
Re: Timer - by TheToretto - 31.10.2018, 11:01
Re: Timer - by Heress - 31.10.2018, 11:03

Forum Jump:


Users browsing this thread: 2 Guest(s)