Jump to content
  • 0

Anti-Flood


zroT

Question

3 answers to this question

Recommended Posts

http://forum.sa-mp.com/showthread.php?t=80210&highlight=anti+flood

#include <a_samp>

// * Settings for the anti-flood
// I recommend using these settings if you want to protect the server from flood attacks.
// If you want to deal with annoying spammers, lower the thresold a bit and set the mode to 2 (kick).

#define RATE_INC (500) // The sensitivity per message, no need to modify.
#define RATE_MAX (2500) // When the flood rate reaches this value the action below will be taken

// * Action to take when the flood rate reached the thresold
// 1 - Ban
// 2 - Kick
// 3 - Give a warning (not recommended)

#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;
}

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

	return 1;
}

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;
}

Data viitoare cauta.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Similar Content

    • By Tican Daniel Andrei
      Salutare, am venit cu o cerință ceva mai "imposibilă" din punctul ăsta de vedere. Am văzut recent pe o comunitate de SA:MP că aveau un fel de Script care bloca modurile Cleo (.cs) și fișierele .exe selectate de către serverul respectiv și pur și simplu lăsau jucătorii cu modpack descărcat de unde aveau ei pagina lor de moduri, lucrul ăsta s-ar putea face din script sau e ceva mai avansat și mai complicat ? 
      Dacă s-ar putea face astfel de script,mi-ați putea spune personal printr-un mesaj privat cât ar costa complexitatea unui script de genul acesta? Mulțumesc și seară plăcută vă doresc! 
    • By Quang Minh
      Is there any way to prevent cleo wallhack and nametag?
      I tried hiding my name but it didn't work
    • By VenoMarius
      ../modules/anti-cheats.pwn(1199) : error 017: undefined symbol "SetPlayerTimerEx_"
      ../modules/anti-cheats.pwn(1913) : error 017: undefined symbol "SetPlayerTimerEx_"
      ../modules/anti-cheats.pwn(3462) : error 017: undefined symbol "SetPlayerTimerEx_"
      ../modules/anticheats.pwn(18) : error 017: undefined symbol "FKicked"
      ../modules/anticheats.pwn(18) : warning 215: expression has no effect
      ../modules/anticheats.pwn(18) : error 001: expected token: ";", but found "]"
      ../modules/anticheats.pwn(18) : error 029: invalid expression, assumed zero
      ../modules/anticheats.pwn(18) : fatal error 107: too many error messages on one line
      Compilation aborted.
      Pawn compiler 3.10.8              Copyright (c) 1997-2006, ITB CompuPhase
       
      includes:
      #include "../modules/anti-cheats.pwn"
      #include "../modules/anticheats.pwn"
       
    • By VenoMarius
      Am o problema
      in anti troll .pwn scrie asa:
      /*
      OnPlayerCarTroll(playerid, vehicleid, trolledid, trolltype);
      Type 1: Teleporting between vehicles (can give cheaters chance to control other's players) (also lag cheat detected here).
      Type 2: Control other player's cars or spin/rotate (Done by checking the player's actual vehicle).
      Type 3: Fast kick/rotate or teleporting inside drivers. (detectd by position change)
      Type 4: Teleporting inside a vehicle illegally as a driver (without PutPlayerInVehicle or OnPlayerEnterVehicle).
      Type 5: Teleporting inside a vehicle illegally as a passenger (without PutPlayerInVehicle or OnPlayerEnterVehicle).
      Type 6: Remote kick a player by tping a vehicle inside of him. (Too fast the server reads it as an unoccupied vehicle).
      */
      si nu stiu ce sa fac
       eu il am asa :
      public OnPlayerCarTroll(playerid, vehicleid, trolledid, trolltype)
      {
          new KickString[80], cheatername[MAX_PLAYER_NAME]; // Kicking message and cheater's name
          GetPlayerName(playerid, cheatername, sizeof(cheatername));//Saving cheater's name in a string
       
          if(trolledid != INVALID_PLAYER_ID)// If the trolled person is valid
          {
              SendClientMessage(trolledid, -1, "You were trolled but the cheater was taken care of");//Inform him
              format(KickString, sizeof(KickString), "Server has kicked %s , reason: Trolling #%d vehicle %d player %d", cheatername, trolltype, vehicleid, trolledid);//Kick with a reasonable message
          }
       
          else format(KickString, sizeof(KickString), "Server has kicked %s , reason: Trolling #%d vehicle %d", cheatername, trolltype, vehicleid);//If no one was trolled kick the troller normally
       
          SendClientMessageToAll(-1, KickString);//Sending the finalized string
          Kick(playerid);//Kicking the cheater
       
          return 1;
      }
      si imi da error.
      Va rog
      Ma poate ajuta cnv ?
      :((
    • By nobilzeusAdv
      anti-cheatul contine: anti-repair vehicle, anti-explode vehicle, anti-flame vehicle, anti-trow vehicle (atunci cand se trag masinile de pe server catre jucatorul cu hack), anti-lagger vehicle (atunci cand mai multe masini sunt puse in acelasi loc si face lag)
      pret: 10 euro
      anticheat-ul este la sfarsit:
       
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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. For more details you can also review our Terms of Use and Privacy Policy.