SA-MP Forums Archive
Waiting time between shooting. - 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: Waiting time between shooting. (/showthread.php?tid=486557)



Waiting time between shooting. - Frank Biohazard - 09.01.2014

Hi, I made a cannon system. But I want to prevent people spamming the explosions, so I want a 5 seconds waiting time between each cannonshot.

I tried using a timer, but it does not work. Anyone can explain me how it works with a code?

Thanks!


Re: Waiting time between shooting. - Eth - 09.01.2014

can you show us the cannon script or command please?


Re: Waiting time between shooting. - MatriXgaMer - 09.01.2014

You can use SetTimer(); and SetTimerEx();


Re: Waiting time between shooting. - Cypress - 09.01.2014

pawn Код:
new CANNON_WAIT[MAX_PLAYERS];

// When going to shoot again you need to check

if (CANNON_WAIT[playerid] >= gettime())
    return SendClientMessage(playerid, -1, "Oh fuck, not so fast.");

// When shot set 5 seconds so when he is going to shot within 5s ^^^ prevent it.

CANNONT_WAIT[playerid] = (gettime() + 5);



Re: Waiting time between shooting. - Frank Biohazard - 09.01.2014

pawn Код:
else if(newkeys & KEY_FIRE)
    {
        new Float:x, Float:y, Float:z;
        if(PlayerInfo[playerid][pCaptain] == 1)
        {
            if(ControllingShip[playerid] == 1)
            {
                GetPlayerPos(playerid, x, y, z);
                CreateExplosion(x+100, y, z, 2, 10.0);
            }
        }
    }
Here you go.