[Help] Countdown
#1

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](playeridparams[])
{
    
inserttime params[0]/1000;
    if(
sscanf(params"i"params[0]))
        return 
Msg(playeridNovoA"[ > ] Uso correto: /evento [tempo] (1000 = 1 Segundo)");
     
SetTimer("IniciarEvento"params[0], false);
     
timer SetTimer("Countdownregressive"1000true);
     return 
1;

Fowards:

PHP код:
forward IniciarEvento();
public 
IniciarEvento()
{
    
KillTimer(timer);
    
inserttime 0;

PHP код:
forward Countdownregressive();
public 
Countdownregressive()
{
    
inserttime--;
    new 
string[240];
    
format(stringsizeof(string), "~y~O Evento sera iniciado em: ~g~%d~n~~y~Guarde seus ITENS!"inserttime);
    for(new 
0MAX_PLAYERSi++)
    return 
GameTextForPlayer(istring10005);    

there are other things throughout the code, however they are irrelevant to this, the error is in the count I think.
Reply
#2

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
Reply
#3

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
Reply
#4

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(stringsizeof(string), "~y~Evento em: ~g~%d~y~ segundos"inserttime);
    for(new 
0MAX_PLAYERSi++)
    
GameTextForPlayer(istring10005);
    return 
1;

Reply
#5

Someone know why?
Reply
#6

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)