[AJUDA] CoutDown (contagem regressiva)
#1

Olб queria saber como faзo um coutdown

Код:
public RobCityHall(playerid)
{
    new string[128];
    if(IsPlayerInRangeOfPoint(playerid, 2, 358.5919,184.2908,1008.3828))
    {
        if(RobbingTime[playerid] > 0)
        {
            RobbingTime[playerid] --;
            GameTextForPlayer(playerid, "~w~Remain in the ~r~Pickup ~w~until the time ends!", 1000,4);
        }
Queria tirar esse gametextforplayer e por um coutdown (60 segs)

Por favor alguem pode me ajudar?

Grato desde jб
Reply
#2

Aai amigo peguei um fs que eu tinha aqui agora й so vocк adapta-lo a seu jeito.
pawn Код:
#include <a_samp>



#define BOMBATEMPO 4    // O Tempo que levarб para a bomba explodir (em segundos).
#define ARMARTEMPO 0     // O Tempo que levarб para armar a bomba (em segundos).



#define Amarelo 0xFFFF00AA


new MS[MAX_PLAYERS];
new Segundos[MAX_PLAYERS];
new Minutos[MAX_PLAYERS];
new bombplanttime;
new bombtime;
new PlantouBomba[MAX_PLAYERS];

new Text:Contagem;

forward BombTime(playerid);
forward BombPlantTime(playerid);

//-----------------------------------------------------------------------------------------------------------------//

public OnFilterScriptInit()
{
    Contagem = TextDrawCreate(51.000000, 316.000000, "00:00:00");
    TextDrawBackgroundColor(Contagem, 255);
    TextDrawFont(Contagem, 2);
    TextDrawLetterSize(Contagem, 0.500000, 2.199999);
    TextDrawColor(Contagem, -1);
    TextDrawSetOutline(Contagem, 1);
    TextDrawSetProportional(Contagem, 1);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{

    if(strcmp(cmdtext, "/contar", true) == 0)
    {
        if(PlantouBomba[playerid] == 1) return SendClientMessage(playerid, Amarelo, "Vocк iniciou a contagem. ");

        else
        {
            bombplanttime = SetTimerEx("BombPlantTime", ARMARTEMPO*1000, 0, "d", playerid);
            PlantouBomba[playerid] = 1;
            TextDrawShowForPlayer(playerid, Contagem);
            return 1;
        }
    }

    return 0;
}


public BombPlantTime(playerid)
{
    TogglePlayerControllable(playerid, 1);
    bombtime = SetTimerEx("BombTime", 9, 1, "d", playerid);
    MS[playerid] = 99;
    Segundos[playerid] = BOMBATEMPO;
    TextDrawShowForAll(Text:Contagem);
    KillTimer(bombplanttime);
    return 1;

}

public BombTime(playerid)
{
    MS[playerid]--;
    if(MS[playerid] == 0)
    {
        MS[playerid] = 99;
        Segundos[playerid]--;


    }

    if(Segundos[playerid] > 60)
    {
        new Segundos2 = Segundos[playerid] - 60;
        Segundos[playerid] = Segundos2;
        Minutos[playerid]++;
    }

    if(Segundos[playerid] == 0 && Minutos[playerid] > 0)
    {
        Segundos[playerid] = 59;
        Minutos[playerid]--;
    }

    if(Segundos[playerid] == 0 && MS[playerid] == 1)
    {
        PlantouBomba[playerid] = 0;
        TextDrawHideForAll(Text:Contagem);
        GameTextForAll("~g~~h~Vai Vai Vai",2500,3);

        KillTimer(bombtime);
    }

    if(Segundos[playerid] < 10)
    {
        new count[10];
        format(count, sizeof(count), "00:0%i:%i", Segundos[playerid], MS[playerid]);
        TextDrawSetString(Contagem, count);
    }

    if(Segundos[playerid] >= 10)
    {
        new count[10];
        format(count, sizeof(count), "00:%i:%i", Segundos[playerid], MS[playerid]);
        TextDrawSetString(Contagem, count);
    }

    if(Minutos[playerid] < 10 && Segundos[playerid] < 10)
    {
        new count[10];
        format(count, sizeof(count), "0%i:0%i:%i",Minutos[playerid], Segundos[playerid], MS[playerid]);
        TextDrawSetString(Contagem, count);
    }

    if(Minutos[playerid] < 10 && Segundos[playerid] > 9)
    {
        new count[10];
        format(count, sizeof(count), "0%i:%i:%i",Minutos[playerid], Segundos[playerid], MS[playerid]);
        TextDrawSetString(Contagem, count);
    }

    if(Minutos[playerid] >= 10 && Segundos[playerid] > 9)
    {
        new count[10];
        format(count, sizeof(count), "%i:%i:%i",Minutos[playerid], Segundos[playerid], MS[playerid]);
        TextDrawSetString(Contagem, count);
    }

    if(Minutos[playerid] >= 10 && Segundos[playerid] < 10)
    {
        new count[10];
        format(count, sizeof(count), "%i:0%i:%i",Minutos[playerid], Segundos[playerid], MS[playerid]);
        TextDrawSetString(Contagem, count);
    }

    return 1;
}
Reply
#3

n teria um metodo melhor e mais facil de fazer?
Reply
#4

pawn Код:
new cont;
forward Contagem();

public Contagem()
{
    new string[128];
    if(cont > 60){cont = 0; return SendClientMessageToAll(0xA9C4E4FF, "Contagem terminada.");}
    if(cont < 60)
    {
        cont++;
        SetTimer("Contagem", 1000, 0);
        format(string, sizeof(string), "~w~%d", cont);
        GameTextForAll(string, 1000, 4);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)