Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- SA-MP FloodControl Include
- Copyright © 2012 RoacH`
- */
- #if defined _FloodControl_Included
- #error Flood Control is already defined.
- #endinput
- #endif
- #define _FloodControl_Included
- #if !defined _samp_included
- #error Please include a_samp before Flood Control.
- #endif
- #pragma library "FloodControl"
- enum {
- FLOOD_CONTROL_DEATH,
- FLOOD_CONTROL_BOOT,
- FLOOD_CONTROL_VEHICLES,
- FLOOD_CONTROL_COMMAND,
- FLOOD_CONTROL_CHAT
- };
- forward OnPlayerFloodControl(playerid, config);
- static
- flood_stamp[MAX_PLAYERS]
- ;
- public OnPlayerDeath(playerid, killerid, reason) {
- if(killerid != INVALID_PLAYER_ID) {
- if(playerid == killerid) {
- if(funcidx("OnPlayerFloodControl")) {
- CallLocalFunction("OnPlayerFloodControl", "ii", playerid, FLOOD_CONTROL_DEATH);
- }
- }
- if(gettime() - GetPVarInt(playerid, "#lastdeath") < 1) {
- if(funcidx("OnPlayerFloodControl")) {
- CallLocalFunction("OnPlayerFloodControl", "ii", playerid, FLOOD_CONTROL_DEATH);
- }
- return 0;
- }
- SetPVarInt(playerid, "#lastdeath", gettime());
- }
- if(funcidx("flood_controlOnPlayerDeath") != -1) {
- return CallLocalFunction("flood_controlOnPlayerDeath", "iii", playerid, killerid, reason);
- }
- return true;
- }
- #if defined _ALS_OnPlayerDeath
- #undef OnPlayerDeath
- #else
- #define _ALS_OnPlayerDeath
- #endif
- #define OnPlayerDeath flood_controlOnPlayerDeath
- forward flood_controlOnPlayerDeath(playerid, killerid, reason);
- public OnPlayerUpdate(playerid) {
- new
- iVehicle = GetPlayerVehicleID(playerid)
- ;
- if(GetPlayerVehicleSeat(playerid) != 0) {
- if(GetPVarInt(playerid, "#ultimoveiculo") != iVehicle) {
- SetPVarInt(playerid, "#ultimoveiculo", iVehicle);
- if(GetVehicleModel(iVehicle)) {
- @ChangeVehicles(playerid, PLAYER_STATE_DRIVER, iVehicle);
- }
- }
- }
- if(funcidx("flood_controlOnPlayerUpdate") != -1) {
- return CallLocalFunction("flood_controlOnPlayerUpdate", "i", playerid);
- }
- return true;
- }
- #if defined _ALS_OnPlayerUpdate
- #undef OnPlayerUpdate
- #else
- #define _ALS_OnPlayerUpdate
- #endif
- #define OnPlayerUpdate flood_controlOnPlayerUpdate
- forward flood_controlOnPlayerUpdate(playerid);
- forward @ChangeVehicles(playerid, newstate, vehicleid);
- public @ChangeVehicles(playerid, newstate, vehicleid) {
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER && GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) {
- if((gettime() - GetPVarInt(playerid, "#getarTime")) < 2) {
- if(funcidx("OnPlayerFloodControl")) {
- CallLocalFunction("OnPlayerFloodControl", "ii", playerid, FLOOD_CONTROL_VEHICLES);
- }
- }
- SetPVarInt(playerid, "#getarTime", gettime());
- }
- return true;
- }
- forward OnPlayerFloodChat@Command(playerid, config, iCount, iTime);
- public OnPlayerFloodChat@Command(playerid, config, iCount, iTime) {
- if((gettime() - GetPVarInt(playerid, "#lasttext")) < iTime && flood_stamp[playerid] > iCount) {
- if(funcidx("OnPlayerFloodControl")) {
- CallLocalFunction("OnPlayerFloodControl", "ii", playerid, config);
- }
- }
- SetPVarInt(playerid, "#lasttext", gettime());
- flood_stamp[playerid] ++;
- return true;
- }
- public OnPlayerConnect(playerid) {
- static
- PlayerIp[16],
- LastIPConnected[16],
- flood_boot
- ;
- GetPlayerIp(playerid, PlayerIp, sizeof(PlayerIp));
- GetPlayerIp(playerid, LastIPConnected, sizeof(LastIPConnected));
- if(strcmp(PlayerIp, LastIPConnected, true) == 0 && gettime() - GetPVarInt(playerid, "#lastip") <= 2) {
- flood_boot ++;
- if(flood_boot >= 5) {
- if(funcidx("OnPlayerFloodControl")) {
- CallLocalFunction("OnPlayerFloodControl", "ii", playerid, FLOOD_CONTROL_BOOT);
- }
- }
- }
- else flood_boot = 0;
- flood_stamp[playerid] = 0;
- SetPVarInt(playerid, "#lastip", gettime());
- if(funcidx("flood_controlOnPlayerConnect") != -1) {
- return CallLocalFunction("flood_controlOnPlayerConnect", "i", playerid);
- }
- return true;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect flood_controlOnPlayerConnect
- forward flood_controlOnPlayerConnect(playerid);
Advertisement
Add Comment
Please, Sign In to add comment