Waiting time between shooting.
#1

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!
Reply
#2

can you show us the cannon script or command please?
Reply
#3

You can use SetTimer(); and SetTimerEx();
Reply
#4

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);
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)