06.04.2019, 14:42
Anti Rapid Fire
PHP Code:
#include <a_samp>
static const Rapid_Amount[17] =
{
10, 7, 5, 5, 10, 10, 25, 15, 15, 15, 25, 3, 4, 0, 0, 0, 75
};
static p_bullets_wep[MAX_PLAYERS] = {0,...};
static p_bullets_timer[MAX_PLAYERS] = {-1,...};
static p_bullets[MAX_PLAYERS] = {0,...};
public OnPlayerConnect(playerid)
{
p_bullets_wep[playerid] = 0;
p_bullets[playerid] = 0;
p_bullets_timer[playerid] = SetTimerEx("RAPID_TIMER", 1000, true, "d", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
p_bullets_wep[playerid] = 0;
p_bullets[playerid] = 0;
KillTimer(p_bullets_timer[playerid]);
p_bullets_timer[playerid] = -1;
return 1;
}
forward RAPID_TIMER(playerid);
public RAPID_TIMER(playerid)
{
new str[48], name[24];
if(p_bullets[playerid] >= Rapid_Amount[p_bullets_wep[playerid]-22])
{
GetPlayerName(playerid, name, 24);
format(str, 48, "%s kicked for rapid fire", name);
SendClientMessageToAll(0xFF0000FF, str);
Kick(playerid); //the hacker wont see the message, if you want the hacker to see the message delay the kick.
}
p_bullets[playerid] = 0;
return 1;
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
p_bullets_wep[playerid] = weaponid;
p_bullets[playerid] ++;
return 1;
}