[Ajuda] Comando Com tempo
#1

ola pessoal, eu tenho esse comando e usava , e do nada ele nao funciona mais , ele nao executa o comando so fala que o comando so pode ser usado a cada 2 min

pawn Код:
COMMAND:assistencia(playerid, params[])
{
    // Setup local variables
    new bool:AssistOnline = false, Msg[128], Name[24];
    if( GetPVarInt( playerid, "TempoComando" ) > GetTickCount() ) return SendClientMessage( playerid, -1, "Comando sу poder ser usado a cada 2 minutos." );
    SetPVarInt( playerid, "TempoComando", GetTickCount() + 120000 );
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/assistencia", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Get the player's name
        GetPlayerName(playerid, Name, sizeof(Name));
        // Preset the message that needs to be sent to assistance players
        format(Msg, 128, "{00FF00}O jogador {FFFF00}%s{00FF00} precisa de assistкncia mecвnica.", Name);

        // Check if there is at least one assistance player online
        for (new i; i < MAX_PLAYERS; i++)
        {
            // Check if this player is connected
            if (IsPlayerConnected(i))
            {
                // Check if this player is assistance class
                if (APlayerData[i][PlayerClass] == ClassAssistance)
                {
                    // Set the flag to indicate that at least one assistance player is online
                    AssistOnline = true;
                    // Send the assistance player a message to inform him who needs assistance
                    SendClientMessage(i, 0xFFFFFFFF, Msg);
                }
            }
        }

        // Check if there is at least one assistance player online
        if (AssistOnline == true)
        {
            // Set yourself as "AssistanceNeeded"
            APlayerData[playerid][AssistanceNeeded] = true;
            // Let the player know he called for assistance
            SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Vocк ja pediu ajuda.");
        }
        else // No assistance is online
        {
            // Check if the player is the driver of a vehicle
            if (GetPlayerVehicleSeat(playerid) == 0)
            {
                // Fully repair the vehicle (damage value and bodywork)
                RepairVehicle(GetPlayerVehicleID(playerid));
                // Also re-fuel the vehicle
                AVehicleData[GetPlayerVehicleID(playerid)][Fuel] = MaxFuel;
                // Let the player pay for the repairs and refuel (default $700)
                RewardPlayer(playerid, -700, 0);
                // Let the player know he spent $2000 for auto-repair because there were no assistance players online
                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Seu veнculo foi reparado e abastecido por R$700.");
                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Nгo hа mecвnico online.");
            }
        }
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
Reply
#2

remova isso

if( GetPVarInt( playerid, "TempoComando" ) > GetTickCount() ) return SendClientMessage( playerid, -1, "Comando sу poder ser usado a cada 2 minutos." );
SetPVarInt( playerid, "TempoComando", GetTickCount() + 120000 );
Reply
#3

Mais eu quero q continua a restriзгo , de usar a cada 2 min
Reply
#4

pawn Код:
new Tempos[MAX_PLAYERS];

// COLOQUE NO INICIO DENTRO DO CMD
if(Tempos[playerid] > gettime())
return SendClientMessage(playerid, -1, "{FFFF00}[ERRO] {009D4F}Aguarde 2 min para chama-lo novamente!");
Tempos[playerid] = gettime() + 60*2;
@EDIT

mande ip do server.
skype: joao.monteiro.2012
Reply
#5

pawn Код:
new TempoComando;
No code que desejar:

pawn Код:
if(TempoComando == 1)
{
       SendClientMessage(playerid,-1,"Nгo floode, espere 2 minutos");
       return 1;
}
Ainda no comando, no final dele:
pawn Код:
TempoComando = 1;
SetTimer("TTempoComando",1000*60*2,0);
Final do GM:

pawn Код:
public TTempoComando(){ TempoComando = 0; }
@EDIT O cara jб postou um tambйm nгo tinha visto, mals.
Reply
#6

pawn Код:
//TOPO DO GM
new bBloq[MAX_PLAYERS];
forward fBloq(playerid);

//FINAL DO GM
public fBloq(playerid){
  bBloq[playerid] = 0;
  return 1;
}

//NO COMANDO
 if(bBloq[playerid] == 1 ) return SendClientMessage(playerid,-1,"Vocк sу pode usar esse comando daqui 1 min!");
Reply
#7

Quote:
Originally Posted by ThiagoMK
Посмотреть сообщение
pawn Код:
//TOPO DO GM
new bBloq[MAX_PLAYERS];
forward fBloq(playerid);

//FINAL DO GM
public fBloq(playerid){
  bBloq[playerid] = 0;
  return 1;
}

//NO COMANDO
 if(bBloq[playerid] == 1 ) return SendClientMessage(playerid,-1,"Vocк sу pode usar esse comando daqui 1 min!");
Para que uma public ? kkk', somente ocupa espaзo
Reply
#8

Quote:
Originally Posted by 22
Посмотреть сообщение
pawn Код:
new TempoComando;
No code que desejar:

pawn Код:
if(TempoComando == 1)
{
       SendClientMessage(playerid,-1,"Nгo floode, espere 2 minutos");
       return 1;
}
Ainda no comando, no final dele:
pawn Код:
TempoComando = 1;
SetTimer("TTempoComando",1000*60*2,0);
Final do GM:

pawn Код:
public TTempoComando(){ RelatorioDinovo = 0; }
@EDIT O cara jб postou um tambйm nгo tinha visto, mals.
Seu cod atй estб bom, mas se algum player usar o comando, e se outro player usar, irб aparecer para esperar 2 min. entгo irб que ter MAX_PLAYERS.
Reply
#9

Tente esse:

pawn Код:
COMMAND:assistencia(playerid, params[])
{
    // Setup local variables
    new bool:AssistOnline = false, Msg[128], Name[24];
    if(gettime() - GetPVarInt(playerid, "TempoComando") < 120) return SendClientMessage( playerid, -1, "Comando sу poder ser usado a cada 2 minutos." );
    SetPVarInt(playerid, "TempoComando", gettime());
   
    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/assistencia", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Get the player's name
        GetPlayerName(playerid, Name, sizeof(Name));
        // Preset the message that needs to be sent to assistance players
        format(Msg, 128, "{00FF00}O jogador {FFFF00}%s{00FF00} precisa de assistкncia mecвnica.", Name);

        // Check if there is at least one assistance player online
        for (new i; i < MAX_PLAYERS; i++)
        {
            // Check if this player is connected
            if (IsPlayerConnected(i))
            {
                // Check if this player is assistance class
                if (APlayerData[i][PlayerClass] == ClassAssistance)
                {
                    // Set the flag to indicate that at least one assistance player is online
                    AssistOnline = true;
                    // Send the assistance player a message to inform him who needs assistance
                    SendClientMessage(i, 0xFFFFFFFF, Msg);
                }
            }
        }

        // Check if there is at least one assistance player online
        if (AssistOnline == true)
        {
            // Set yourself as "AssistanceNeeded"
            APlayerData[playerid][AssistanceNeeded] = true;
            // Let the player know he called for assistance
            SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Vocк ja pediu ajuda.");
        }
        else // No assistance is online
        {
            // Check if the player is the driver of a vehicle
            if (GetPlayerVehicleSeat(playerid) == 0)
            {
                // Fully repair the vehicle (damage value and bodywork)
                RepairVehicle(GetPlayerVehicleID(playerid));
                // Also re-fuel the vehicle
                AVehicleData[GetPlayerVehicleID(playerid)][Fuel] = MaxFuel;
                // Let the player pay for the repairs and refuel (default $700)
                RewardPlayer(playerid, -700, 0);
                // Let the player know he spent $2000 for auto-repair because there were no assistance players online
                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Seu veнculo foi reparado e abastecido por R$700.");
                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Nгo hа mecвnico online.");
            }
        }
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)