SA-MP Forums Archive
Whats wrong? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Whats wrong? (/showthread.php?tid=367909)



Whats wrong? - thefatshizms - 11.08.2012

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)


Re: Whats wrong? - Djole1337 - 11.08.2012

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



Re: Whats wrong? - thefatshizms - 11.08.2012

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.



Re: Whats wrong? - Djole1337 - 11.08.2012

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.


Re: Whats wrong? - thefatshizms - 11.08.2012

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


Re: Whats wrong? - thefatshizms - 11.08.2012

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


Re: Whats wrong? - thefatshizms - 11.08.2012

it has the same bug as i had


Re: Whats wrong? - leonardo1434 - 11.08.2012

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;
}