countdown error -
livests - 02.03.2012
hy my countdown timer not work then i write countdown it shows 3 2 1 1 1 go! go! a lot of times
Quote:
forward CountingDown(playerid, time);
if(strcmp(cmdtext,"/countdown",true) == 0)
{
SetTimerEx("CountingDown", 1000, true, "ii", playerid, 3);
}
public CountingDown(playerid, time)
{
if(time != 0)
{
new string[5];
format(string, sizeof(string), "%d", time);
GameTextForPlayer(playerid, string, 1200, 4);
SetTimerEx("CountingDown", 1000, true, "ii", playerid, time-1);
}
else
{
GameTextForPlayer(playerid, "~g~Go!", 2500, 3);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, -1, "Go!");
SetTimer("CountingDown", 1000, false);
}
return true;
}
|
AW: countdown error -
Drebin - 02.03.2012
pawn Код:
{
GameTextForPlayer(playerid, "~g~Go!", 2500, 3);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, -1, "Go!");
SetTimer("CountingDown", 1000, false);
}
Instead of SetTimer("CountingDown", 1000, false); you need to use KillTimer();
https://sampwiki.blast.hk/wiki/KillTimer
Re: countdown error -
Gooday - 02.03.2012
Add something like KillTimer("CountingDown", playerid) Not sure...
Re: countdown error -
livests - 02.03.2012
Quote:
Originally Posted by Gooday
Add something like KillTimer("CountingDown", playerid) Not sure...
|
D:\trucking\gamemodes\Trucking.pwn(5511) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: countdown error -
Konstantinos - 02.03.2012
Quote:
Originally Posted by Gooday
Add something like KillTimer("CountingDown", playerid) Not sure...
|
See wiki.
KillTimer
Also, I suggest you SetTimerEx, not SetTimer.
Re: countdown error -
livests - 02.03.2012
i already try
new timer;
public CountingDown(playerid, time)
{
if(time != 0)
{
new string[5];
format(string, sizeof(string), "%d", time);
GameTextForPlayer(playerid, string, 1200, 4);
timer = SetTimerEx("CountingDown", 1000, true, "ii", playerid, time-1);
}
else
{
GameTextForPlayer(playerid, "~g~Go!", 2500, 3);
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, -1, "Go!");
KillTimer(timer);
}
return true;
}
and
SetTimerEx("CountingDown", 1000, false, "ii", playerid, time-1);
SetTimerEx("CountingDown", false);
AW: countdown error -
Nero_3D - 02.03.2012
We dont need to store the timer if its not repeating
There are two ways to write countdowns,
first with an repeating timer and an player array
or just with delayed recursion, like that
pawn Код:
forward CountingDown(playerid, time);
public CountingDown(playerid, time) {
if(0 < time) {
new number[8];
valstr(number, time--, false);
GameTextForPlayer(playerid, number, 1200, 4);
SetTimerEx("CountingDown", 1000, false, "ii", playerid, time);
} else {
GameTextForPlayer(playerid, "~g~Go!", 2500, 3);
TogglePlayerControllable(playerid, true);
SendClientMessage(playerid, -1, "Go!");
}
}
pawn Код:
if(strcmp(cmdtext, "/countdown", true) == 0) {
CountingDown(playerid, 3);
}