[Help] Countdown -
ApolloScripter - 30.11.2018
So, i got this command, the admin write and make a event automatically, and i puted a timer and GameTextForPlayer to do a countdown, but, the GameText show in game a countdown for up, it shows: -1, -2, -3, -4, -5 rather than 5, 4, 3, 2, 1, Besides that, the GameText dont hide after event begins, someone know why?
Command that create the event:
PHP код:
ACMD:criarevento[1](playerid, params[])
{
inserttime = params[0]/1000;
if(sscanf(params, "i", params[0]))
return Msg(playerid, NovoA, "[ > ] Uso correto: /evento [tempo] (1000 = 1 Segundo)");
SetTimer("IniciarEvento", params[0], false);
timer = SetTimer("Countdownregressive", 1000, true);
return 1;
}
Fowards:
PHP код:
forward IniciarEvento();
public IniciarEvento()
{
KillTimer(timer);
inserttime = 0;
}
PHP код:
forward Countdownregressive();
public Countdownregressive()
{
inserttime--;
new string[240];
format(string, sizeof(string), "~y~O Evento sera iniciado em: ~g~%d~n~~y~Guarde seus ITENS!", inserttime);
for(new i = 0; i < MAX_PLAYERS; i++)
return GameTextForPlayer(i, string, 1000, 5);
}
there are other things throughout the code, however they are irrelevant to this, the error is in the count I think.
Re: [Help] Countdown -
akib - 01.12.2018
does this count like this?
if inserttime = 5
gametext = 5,4,3,2,1,0,-1,-2,-3...?
if yes then u have to add condition on Countdownregressive
condition is, if inserttime = 0 kill the timer
Re: [Help] Countdown -
Jefff - 01.12.2018
Maybe here is problem? xd
inserttime = params[0]/1000;
this part is also cool
return GameTextForPlayer(i, string, 1000, 5); only id 0 will see this
Re: [Help] Countdown -
ApolloScripter - 01.12.2018
I changed some things, assuming the inserttime is 20, so the count should be like (20, 19, 18, 17, 16...), but not, the count still are uping (1, 2, 3,4) to the 20.
PHP код:
public Countdownregressive()
{
inserttime = inserttime - 1;
new string[240];
format(string, sizeof(string), "~y~Evento em: ~g~%d~y~ segundos", inserttime);
for(new i = 0; i < MAX_PLAYERS; i++)
GameTextForPlayer(i, string, 1000, 5);
return 1;
}
Re: [Help] Countdown -
ApolloScripter - 01.12.2018
Someone know why?
Re: [Help] Countdown -
UFF - 01.12.2018
try this
pawn Код:
ACMD:criarevento[1](playerid, params[])
{
if(sscanf(params, "i", params[0]))
return Msg(playerid, NovoA, "[ > ] Uso correto: /evento [tempo] (1000 = 1 Segundo)");
inserttime = params[0]/1000;
timer = SetTimer("Countdownregressive", 1000, true);
return 1;
}
forward Countdownregressive();
public Countdownregressive()
{
inserttime--;
if(inserttime == 0)
{
KillTimer(timer);
inserttime = 0;
}
else
{
new string[240];
format(string, sizeof(string), "~y~O Evento sera iniciado em: ~g~%d~n~~y~Guarde seus ITENS!", inserttime);
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)
{ GameTextForPlayer(i, string, 1000, 5); }
}
return 1;
}