31.10.2018, 09:18
Like nobody noticed he's formatting the timer's variable? Come on.
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:
format(str, sizeof(str), "%d", CountDownTimer);
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);
}
}