- /bomb - 5 second delay
#2

Quote:
Originally Posted by Darklom
Посмотреть сообщение
Well I've been working on my first ever script & from scratch and I've stumbled into a problem

pawn Код:
if(strcmp("/bomb", cmdtext, true, 10) == 0) {//Explosion
        if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid,_COLOR_GREY,"You need $2,500 for this!");
        if (gTeam[playerid] == TEAM_TERRORIST) {
        new Float:X,Float:Y,Float:Z;
        GetPlayerPos(playerid,X,Y,Z);
        CreateExplosion(X,Y,Z,6,40.0);
        SetPlayerHealth(playerid, 0.0);
        GivePlayerMoney(playerid, -500);
        GameTextForPlayer(playerid,"~r~SUPRISE BLOWUP!",2500,5);
        SendClientMessage(playerid, _COLOR_RED, "You commited suicide and lost an extra $500!");}
        return 1;
How would I go on and give it a 5 second delay before it is typed again to prevent abuse when they die and such, thanks in advance.
at the top of your script:
pawn Код:
new BombSpamPlayer[MAX_PLAYERS];
forward BombSpam(playerid);
Then place the callback:
pawn Код:
public BombSpam(playerid)
{
       if(BombSpamPlayer[playerid] == 1)
       {
             BombSpamPlayer[playerid] = 0;
             return 1;
        }
return 1;
}
Then modify your command:
pawn Код:
if(strcmp("/bomb", cmdtext, true, 10) == 0)
{
    if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid,_COLOR_GREY,"You need $2,500 for this!");
    if(BombSpamPlayer[playerid] == 1) return SendClientMessage(playerid,_COLOR_GREY, "You can use this command every 30 seconds!"); // Added this

        if (gTeam[playerid] == TEAM_TERRORIST)
        {
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(playerid,X,Y,Z);
            CreateExplosion(X,Y,Z,6,40.0);
            SetPlayerHealth(playerid, 0.0);
            GivePlayerMoney(playerid, -500);
            GameTextForPlayer(playerid,"~r~SUPRISE BLOWUP!",2500,5);
            SendClientMessage(playerid, _COLOR_RED, "You commited suicide and lost an extra $500!");
            BombSpamPlayer[playerid] = 1; // Added this
            SetTimerEx("BombSpam", 5000, 0, "i", playerid); // Added a timer for a player only. 5000 milliseconds is 5 seconds.
        }
        return 1;
}
Reply


Messages In This Thread
- /bomb - 5 second delay - by Darklom - 18.12.2010, 04:32
Re: - /bomb - 5 second delay - by Biesmen - 18.12.2010, 07:39
Re: - /bomb - 5 second delay - by Darklom - 18.12.2010, 17:48
Re: - /bomb - 5 second delay - by Yummy - 18.12.2010, 18:53

Forum Jump:


Users browsing this thread: 3 Guest(s)