Jump to content

[PAWNO] System Anti-Flood


Bogdanw0w
 Share

Recommended Posts

Salutare dragi prieteni, am revenit cu un system Anti-Flood, in ce consta acest Anti-Flood?

Pai, daca scrii %s, %d, %a intr-un dialog, serverul tau o sa pice cateva minute, eu am picat un server astefel si a stat peste 30 de minute inchis, dar aceasta problema sa poate rezolva cu un restart dar eu zic ca acest Anti-Flood o sa va ajute foarte mult.

 

Script :

#include

#define RATE_INC (500)
#define RATE_MAX (2500)

#define THRESOLD_ACTION 1

enum LIST_ANTIFLOOD
{
lastCheck,
floodRate
}

new AntiFlood_Data[MAX_PLAYERS][list_ANTIFLOOD];

public OnFilterScriptInit()
{
for ( new playerid; playerid < MAX_PLAYERS; playerid++ )
{
if ( IsPlayerConnected( playerid ) )
AntiFlood_InitPlayer( playerid );
}

return 1;
}

public OnFilterScriptExit()
{
return 1;
}

public OnPlayerConnect( playerid )
{
AntiFlood_InitPlayer( playerid );

return 1;
}

public OnPlayerDisconnect( playerid )
{
return 1;
}

public OnPlayerText( playerid, text[] )
{
assert( AntiFlood_Check( playerid ) );

return 1;
}

public OnPlayerCommandText( playerid, cmdtext[] )
{
assert( AntiFlood_Check( playerid ) );
return 0;
}

forward OnPlayerTeamPrivmsg( playerid, text[] );
public OnPlayerTeamPrivmsg( playerid, text[] )
{
assert( AntiFlood_Check( playerid ) );

return 1;
}

public OnPlayerDeath( playerid, killerid, reason )
{
assert( AntiFlood_Check( playerid ) );

return 1;
}

AntiFlood_Check( playerid, bool:inc=true )
{
AntiFlood_Data[playerid][floodRate] += inc ? RATE_INC : 0;
AntiFlood_Data[playerid][floodRate] = AntiFlood_Data[playerid][floodRate] - ( GetTickCount() - AntiFlood_Data[playerid][lastCheck] );
AntiFlood_Data[playerid][lastCheck] = GetTickCount();
AntiFlood_Data[playerid][floodRate] = AntiFlood_Data[playerid][floodRate] < 0 ? 0 : AntiFlood_Data[playerid][floodRate];

if ( AntiFlood_Data[playerid][floodRate] >= RATE_MAX )
{
#if THRESOLD_ACTION == 1
new msg[64], name[MAX_PLAYER_NAME];

GetPlayerName( playerid, name, sizeof( name ) );

format( msg, sizeof( msg ), ">> %s has been banned for flooding.", name );

SendClientMessageToAll( 0xEE9911FF, msg );

Ban( playerid );
#elseif THRESOLD_ACTION == 2
new msg[64], name[MAX_PLAYER_NAME];

GetPlayerName( playerid, name, sizeof( name ) );

format( msg, sizeof( msg ), ">> %s has been kicked for flooding.", name );

SendClientMessageToAll( 0xEE9911FF, msg );

Kick( playerid );
#else
SendClientMessage( playerid, 0xC00000FF, "Stop flooding." );
#endif

return false;
}

return true;
}

AntiFlood_InitPlayer( playerid )
{
AntiFlood_Data[playerid][lastCheck] = GetTickCount();
AntiFlood_Data[playerid][floodRate] = 0;
}

 

 

PS : Pot sa postez GAMEMODE-uri aici?

Edited by KingBogdan
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.