[AJUDA] Fazendo um timer com TextDraw
#1

Alguem pode me dizer quais sгo as funзхes para fazer um timer em textdraw?

Tipo, um timer de 00:10 dai comeзa a contar

00:10
00:09

etc...
Reply
#2

PHP код:
public OnGameModeInit()
{
    
// Cуdigos do textdraw
    
SetTimer("Timer",1000,true);
    return 
true;
}
forward Timer();
public 
Timer()
{
    new 
sStr[10],h[3];
    
gettime(h[0],h[1],h[2]);
    
format(sStr,sizeof(sStr),"%d:%d:%d",h[0],h[1],h[2]);
    
TextDrawSetString(textdrawid,sStr);
    return 
true;

Reply
#3

Valeu Felipe
Reply
#4

Lembre-se de criar a textdraw no OnGameModeInit e de mostrar/ocultar quando a contagem comeзar/terminar.
Reply
#5

Nгo testei.

pawn Код:
new Text:Contagem;
new TimerContagem;
new TempoDaContagem = 10;

public OnGameModeInit()
{
    Contagem = TextDrawCreate(300, 300, "_");
    TextDrawFont(Contagem , 1);
    TextDrawLetterSize(Contagem , 2, 14);
    TextDrawColor(Contagem , -1);
    TextDrawSetOutline(Contagem , 0);
    TextDrawSetProportional(Contagem , 1);
    TextDrawSetShadow(Contagem , 0);

    return true;
}

CMD:iniciarcontagem(playerid)
{
    SendClientMessage(playerid, -1, "Contagem de 10 segundos inciada!");
   
    TextDrawShowForAll(Contagem);
    TimerContagem = SetTimer("Timer", 1000, true);
    return 1;
}

forward Timer();
public Timer()
{
    TempoDaContagem --;
   
    new String[2];
    format(String,sizeof(String),"%d",TempoDaContagem);
    TextDrawSetString(Contagem, String);
   
    if(TempoDaContagem == 0)
    {
        TempoDaContagem = 10;
        KillTimer(TimerContagem);
        TextDrawHideForAll(Contagem);
    }
    return 1;
}
Mas й mais ou menos assim..
Reply
#6

Quote:
Originally Posted by s4kuL
Посмотреть сообщение
Nгo testei.

pawn Код:
new Text:Contagem;
new TimerContagem;
new TempoDaContagem = 10;

public OnGameModeInit()
{
    Contagem = TextDrawCreate(300, 300, "_");
    TextDrawFont(Contagem , 1);
    TextDrawLetterSize(Contagem , 2, 14);
    TextDrawColor(Contagem , -1);
    TextDrawSetOutline(Contagem , 0);
    TextDrawSetProportional(Contagem , 1);
    TextDrawSetShadow(Contagem , 0);

    return true;
}

CMD:iniciarcontagem(playerid)
{
    SendClientMessage(playerid, -1, "Contagem de 10 segundos inciada!");
   
    TextDrawShowForAll(Contagem);
    TimerContagem = SetTimer("Timer", 1000, true);
    return 1;
}

forward Timer();
public Timer()
{
    TempoDaContagem --;
   
    new String[2];
    format(String,sizeof(string),"%d",TempoDaContagem);
    TextDrawSetString(Contagem, String);
   
    if(TempoDaContagem == 0)
    {
        TempoDaContagem = 10;
        KillTimer(TimerContagem);
        TextDrawShowForAll(Contagem);
    }
    return 1;
}
Mas й mais ou menos assim..
й de 2011 '-' kkk..
Reply
#7

Quote:
Originally Posted by FalcaoNC
Посмотреть сообщение
й de 2011 '-' kkk..
Acabei de fazer o cуdigo aqui, como й de 2011?
Reply
#8

Quote:
Originally Posted by s4kuL
Посмотреть сообщение
Acabei de fazer o cуdigo aqui, como й de 2011?
Estou falando que quando o cara criou esse tуpico "22/07/2011, 04:15 PM"
Reply
#9

Quote:
Originally Posted by s4kuL
Посмотреть сообщение
Nгo testei.

pawn Код:
new Text:Contagem;
new TimerContagem;
new TempoDaContagem = 10;

public OnGameModeInit()
{
    Contagem = TextDrawCreate(300, 300, "_");
    TextDrawFont(Contagem , 1);
    TextDrawLetterSize(Contagem , 2, 14);
    TextDrawColor(Contagem , -1);
    TextDrawSetOutline(Contagem , 0);
    TextDrawSetProportional(Contagem , 1);
    TextDrawSetShadow(Contagem , 0);

    return true;
}

CMD:iniciarcontagem(playerid)
{
    SendClientMessage(playerid, -1, "Contagem de 10 segundos inciada!");
   
    TextDrawShowForAll(Contagem);
    TimerContagem = SetTimer("Timer", 1000, true);
    return 1;
}

forward Timer();
public Timer()
{
    TempoDaContagem --;
   
    new String[2];
    format(String,sizeof(string),"%d",TempoDaContagem);
    TextDrawSetString(Contagem, String);
   
    if(TempoDaContagem == 0)
    {
        TempoDaContagem = 10;
        KillTimer(TimerContagem);
        TextDrawHideForAll(Contagem);
    }
    return 1;
}
Mas й mais ou menos assim..
Tem um erro no seu forward.. na linha do format, colocou o string com letra minъscula..

PHP код:
    format(String,sizeof(String),"%d",TempoDaContagem); 
Reply
#10

Quote:
Originally Posted by CrowleyNWD
Посмотреть сообщение
Tem um erro no seu forward.. na linha do format, colocou o string com letra minъscula..

PHP код:
    format(String,sizeof(String),"%d",TempoDaContagem); 
vdd como descobriu?
ja sei vocк testou ele ne
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)