Help making a timer to check weapons every 30 seconds
#1

So i got some code that works but it needs a timer to be successful so to speak

So heres the code, im not too sure on timers and i do not understand the wiki page about timers to well

heres the bit of code i need a timer around any help? and if so do you know hwo to put a timer globally so it times every single function etc in the script?

Quote:

public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerWeapon(killerid) == 36)
{
BanEx(killerid, "Weapon Hacks: Rocket Launcher");
}
if(GetPlayerWeapon(killerid) == 3
{
BanEx(killerid, "Weapon Hacks: MiniGun");
}
if(GetPlayerWeapon(killerid) == 39)
{
BanEx(killerid, "Weapon Hacks: Satchel");
}
if(GetPlayerWeapon(killerid) == 40)
{
BanEx(killerid, "Weapon Hacks: Detonator");
}
if(GetPlayerWeapon(killerid) == 37)
{
BanEx(killerid, "Weapon Hacks: Flamethrower");
}
if(GetPlayerWeapon(killerid) == 16)
{
BanEx(killerid, "Weapon Hacks: Grenade");
}
if(GetPlayerWeapon(killerid) == 4)
{
BanEx(killerid, "Weapon Hacks: Knife");
}
if(GetPlayerWeapon(killerid) == 17)
{
BanEx(killerid, "Weapon Hacks: TearGas");
}
if(GetPlayerWeapon(killerid) == 7)
{
BanEx(killerid, "Weapon Hacks");
}
if(GetPlayerWeapon(killerid) == 15)
{
BanEx(killerid, "Weapon Hacks");
}
if(GetPlayerWeapon(killerid) == 42)
{
BanEx(killerid, "Weapon Hacks");
}

return 1;
}

Reply
#2

you mean like this timer?:
put on player connect:
Quote:

SetTimer("Weapon_Timer", 5000, true);

then... put:
Код:
public Weapon_Timer(playerid)
{
if(GetPlayerWeapon(playerid) == 36)
{
BanEx(playerid, "Weapon Hacks: Rocket Launcher");
}
}
in every place in your script but not in any public...
__________________________________________________ READ THIS!!!:
i gave you an exemple of the RocketLuncher... just do the same with all the other weapons as you did in OnPlayerDeath but here and with playerid and not killerid... hope i helped!
Reply
#3

You do not need any timer as you're calling it on OnPlayerDeath.
Reply
#4

Well i need help with this aswell, the money bit needs a timer and also it wont let anyone take money out of the bank and resets everyones money in the server to 0

Quote:

definesssss


#define GivePlayerMoneyEx(%0,%1) SetPVarInt(%0,"Money",GetPlayerMoneyEx(%0)+%1),Giv ePlayerMoney()
#define ResetPlayerMoneyEx(%0) SetPVarInt(%0,"Money",0),ResetPlayerMoney(%0)
#define GetPlayerMoneyEx(%0) GetPVarInt(%0,"Money")

Quote:

public OnPlayerUpdate(playerid)
{
if(GetPlayerMoneyEx(playerid) != GetPlayerMoney(playerid))
{
new const old_money = GetPlayerMoneyEx(playerid);
ResetPlayerMoneyEx(playerid), GivePlayerMoneyEx(playerid, old_money);
}
return 1;
}

Reply
#5

In OnPlayerDeath callback reason is the id of the weapon used to kill the player.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID) // Someone killed the player.
    {
        switch(reason)
        {
            case 36: BanEx(killerid, "Weapon Hacks: Rocket Launcher");
            case 38: BanEx(killerid, "Weapon Hacks: MiniGun");
            // etc
        }
    }
    return 1;
}
READ THIS: There are cheating tools which make it possible to "fake kill" players, which means cheaters can ban anyone on your server if you're really using this code.
Reply
#6

bump for post 4 please? help with the info in post 4
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)