[AJUDA] SetTimer
#1

Aew galera, como eu faзo pra colocar um comando pra ser usado apenas de 1 em 1 minuto?
E se o Player tentar usar o comando, enviar uma mensagem pra ele dizendo:
"Aguarde 1 minuto para respawnar a bola novamente"

Comando
pawn Code:
if (strcmp("/respawnbola", cmdtext, true, 6) == 0)
    {
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 2763.6863,-2005.3716,13.5620))
        {
        DestroyObject(Ball);
        Ball = CreateObject(2114, 2782.3027,-2019.0826,13.5547-0.8, 0, 0, 96);
        SendClientMessage(playerid, -1, "Vocк respawnou a bola de basket!");
                // Colocar o SetTimer aki :D
        }
        else
        {
        SendClientMessage(playerid, -1, "Vocк nгo estб perto da quadra");
            }
                return 1;
        }
Vlw ae, darei +REP!
Reply
#2

pawn Code:
//topo gm
new bool:blockcomando;
forward DesblockComando();

//no comando
if(blockcomando)return SendClientMessage(playerid,-1,"Aguarde 1 minuto para respawnar a bola novamente");
blockcomando = true;
SetTimer("DesblockComando",60000,false);
//fim gm
public DesblockComando()
{
 blockcomando = false;
 return 1;
}
Reply
#3

Opa , vou testar aki, ^^
@Edit: Vlw cara, funcionou Certinho
REP!
Reply
#4

pawn Code:
new TempoCMD[MAX_PLAYERS][1];//Topo

if(!strcmp("/respawnbola", cmdtext, true))
{
    if(GetTickCount() - TempoCMD[playerid][0] < 60000)
    {
        new string[47];
        format(string, sizeof(string), "Aguarde %d segundos para usar o CMD novamente!",60-(GetTickCount() - TempoCMD[playerid][0])/1000);
        SendClientMessage(playerid, -1, string);
        return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 2763.6863,-2005.3716,13.5620))
    {
        DestroyObject(Ball);
        Ball = CreateObject(2114, 2782.3027,-2019.0826,13.5547-0.8, 0, 0, 96);
        SendClientMessage(playerid, -1, "Vocк respawnou a bola de basket!");
        TempoCMD[playerid][0] = GetTickCount();
    }
    else
    {
        SendClientMessage(playerid, -1, "Vocк nгo estб perto da quadra");
    }
    return 1;
}
Reply
#5

Mais completo:
pawn Code:
//TOPO DO GM
new TimerBola;
new TempoBola[MAX_PLAYERS];
//FIM DO GM
forward LBola(playerid);
public LBola(playerid)
{
    if ((TempoBola[playerid]) >= 1)
    {
        TempoBola[playerid] --;
    }
    else if ((TempoBola[playerid]) <= 0)
    {
        SendClientMessage(playerid, 0xF68E00F6, "Vocк jб pode usar o Comando: /respawnbola novamente!");
        KillTimer(TimerBola);
        TempoBola[playerid] = 0;
    }
    return 1;
}
//ONPLAYERCOMMANDTEXT
    if (strcmp("/respawnbola", cmdtext, true, 6) == 0)
    {
        if ((TempoBola[playerid]) >= 1)
        {
            TempoBola[playerid] --;
            format(string, sizeof(string), "Faltam %d segundos para usar este Comando novamente.", TempoRelato[playerid]);
            SendClientMessage(playerid, COLOR_GREY, string);
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 2.0, 2763.6863,-2005.3716,13.5620))
        {
            TempoBola[playerid] = 60;
            TimerBola = SetTimerEx("LBola", 1000, true, "i", playerid);
            DestroyObject(Ball);
            Ball = CreateObject(2114, 2782.3027,-2019.0826,13.5547-0.8, 0, 0, 96);
            SendClientMessage(playerid, -1, "Vocк respawnou a bola de basket!");                // Colocar o SetTimer aki :D
        }
        else
        {
            SendClientMessage(playerid, -1, "Vocк nгo estб perto da quadra");
        }
        return 1;
     }
Reply
#6

pawn Code:
//TOPO DO GM
new Sbola[MAX_PLAYERS];

===================================
//OnPlayerCommandText

if (strcmp("/respawnbola", cmdtext, true, 6) == 0)
    {
    if(gettime() - Sbola[playerid] < 60) return SendClientMessage(playerid, -1, "Aguarde 1 minuto para respawnar a bola Novamente !");
    if(IsPlayerInRangeOfPoint(playerid, 2.0, 2763.6863,-2005.3716,13.5620))
        {
        DestroyObject(Ball);
        Ball = CreateObject(2114, 2782.3027,-2019.0826,13.5547-0.8, 0, 0, 96);
        SendClientMessage(playerid, -1, "Vocк respawnou a bola de basket!");
        Sbola[playerid] = gettime();

        }
        else
        {
        SendClientMessage(playerid, -1, "Vocк nгo estб perto da quadra");
            }
                return 1;
        }
Espero ter Ajudado !
Reply
#7

Nossa kkkkk, vlw, vo dar REP pra todos que eu conseguir
Pronto, dei REP pra todods kk
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)