Whats wrong?
#1

pawn Код:
CMD:explode(playerid, params[])
{
    if(PlayerInfo[playerid][Padmin] >=2)
    {
        if(Mxc[playerid] <=MAX_CMD)
        {
            new id, string[128], string2[128], Float:X, Float:Y, Float:Z;
            if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /explode <id>");
            if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot use this command on yourself.");
            if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
            GetPlayerPos(id, X, Y, Z);
            CreateExplosion(X, Y, Z, 0, 5);
            format(string, sizeof(string), "You have been blown up by %s", PlayerName(playerid));
            format(string2, sizeof(string), "You have blown up %s", PlayerName(id));
            SendClientMessage(playerid, COLOR_GREEN, string2);
            SendClientMessage(id, COLOR_RED, string);
            Mxc[playerid] += 1;
            return 1;
        }
    }
    else if(PlayerInfo[playerid][Padmin] < 2)
    {
        SendClientMessage(playerid, COLOR_RED, "You are not admin.");
        return 1;
    }
    else if(Mxc[playerid] > MAX_CMD)
    {
        SendClientMessage(playerid, COLOR_RED, "Please stop spamming. You cannot use this command for another  3 seconds");
        SetTimer("cmdcool", 3000, false);
        return 1;
    }
    return 1;
}
forward cmdcool(playerid);
public cmdcool(playerid)
{
    Mxc[playerid] =0;
    return 1;
}
whats wrong with the cmd and timer? once i used my max uses (4) it then doesnt show the stop spamming message and i cant use it again (when i try using again it returns no message and does nothing)
Reply
#2

What about using other metode ?

like
pawn Код:
if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount()) return SendClientMessage(playerid,COLOR_RED,"Please Wait Before Using This Command Again");
   SetPVarInt(playerid,"CMDABUSE",GetTickCount()+15000); // every 15 secs
Reply
#3

Ive never used SetPVarInt and GetTickCount :/ could u explain more ?

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 39 seconds.
Reply
#4

pawn Код:
CMD:explode(playerid, params[])
{
    if(PlayerInfo[playerid][Padmin] >=2)
    {
        if(Mxc[playerid] <=MAX_CMD)
        {
            new id, string[128], string2[128], Float:X, Float:Y, Float:Z;
            if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /explode <id>");
            if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot use this command on yourself.");
            if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
            if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount()) return SendClientMessage(playerid,COLOR_RED,"Please Wait Before Using This Command Again");
            SetPVarInt(playerid,"CMDABUSE",GetTickCount()+3000); // every 3 secs
            GetPlayerPos(id, X, Y, Z);
            CreateExplosion(X, Y, Z, 0, 5);
            format(string, sizeof(string), "You have been blown up by %s", PlayerName(playerid));
            format(string2, sizeof(string), "You have blown up %s", PlayerName(id));
            SendClientMessage(playerid, COLOR_GREEN, string2);
            SendClientMessage(id, COLOR_RED, string);
            Mxc[playerid] += 1;
            return 1;
        }
    }
    else if(PlayerInfo[playerid][Padmin] < 2)
    {
        SendClientMessage(playerid, COLOR_RED, "You are not admin.");
        return 1;
    }
    return 1;
}

Well, it's better than creating timers for every single command.
Reply
#5

Ok i get now anyway i wasnt rly looking at ur comments lol
Reply
#6

One question, how does it know that only can use 4 times
Reply
#7

it has the same bug as i had
Reply
#8

Here goes....
pawn Код:
new uses[MAX_PLAYERS];
CMD:explode(playerid, params[])
{
    if(PlayerInfo[playerid][Padmin] < 2) return SendClientMessage(playerid,-1,#level not enought);
    if(uses[playerid] > 3) return SendClientMessage(playerid,-1,#max usage is 4 times, you can't use it again);
    if(GetPVarInt(playerid,#countdown) > gettime()) return SendClientMessage(playerid,-1,#you must wait 30 seconds before use it again);
    new id, string[128],Float:X, Float:Y, Float:Z;
    if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_GREEN, "USAGE: /explode <id>");
    if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot use this command on yourself.");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
    GetPlayerPos(id, X, Y, Z);
    CreateExplosion(X, Y, Z, 0, 5);
    format(string, sizeof(string), "You have been blown up by %s", PlayerName(playerid));
    SendClientMessage(playerid, COLOR_GREEN, string);
    format(string, sizeof(string), "You have blown up %s", PlayerName(id));
    SendClientMessage(id, COLOR_RED, string);
    SetPVarInt(playerid,#countdown,gettime() + 30);
    uses[playerid]++;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)