[FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam)
#35

Copy, paste in pawno and compile

Code:
/*******************************************************************************
 Player Protections (Driveby, teamkill, helikill, spawnkill, chat spam, ping)
 Created 2007 - HAMM3R
 -
 Driveby detection elements adapted from code by Serafim
 -
 Modify it, erase it, explode it with a nuclear warhead... I don't care.
*******************************************************************************/

#include <a_samp>

// ADJUST THESE TO MODIFY EACH PROTECTION'S SETTINGS
#define HELIKILL_PROTECTION 0
#define HELIKILL_MAX_KILLS 2
#define HELIKILL_TIMELIMIT 600 // 10 MINUTES

#define DRIVEBY_PROTECTION 1
#define DRIVEBY_MAX_KILLS 2
#define DRIVEBY_TIMELIMIT 600 // 10 MINUTES

#define TEAMKILL_PROTECTION 0
#define TEAMKILL_MAX_KILLS 5
#define TEAMKILL_TIMELIMIT 600 // 10 MINUTES

#define SPAWNKILL_PROTECTION 0
#define SPAWNKILL_MAX_KILLS 4
#define SPAWNKILL_TIMELIMIT 40 // 40 SECONDS

#define SPAM_PROTECTION 1
#define SPAM_MAX_MSGS 5
#define SPAM_TIMELIMIT 8 // 8 SECONDS

#define PING_PROTECTION 0
#define PING_MAX_EXCEEDS 5 // Do NOT set this to 1 - Pings are very high when a player first joins
#define PING_TIMELIMIT 60 // 1 MINUTE
#define PING_MAX_PING 2000 // 250ms PING

forward Float:GetDistanceBetweenPlayers(p1,p2);
forward PingProtection();

new gSpamCount[MAX_PLAYERS][2];
new gTeamkillCount[MAX_PLAYERS][2];
new gHelikillCount[MAX_PLAYERS][2];
new gSpawnkillCount[MAX_PLAYERS][MAX_PLAYERS][2];
new gDrivebyCount[MAX_PLAYERS][2];
new gPingCount[MAX_PLAYERS][2];

public OnFilterScriptInit()
{
	#if PING_PROTECTION
		SetTimer("PingProtection", 5000, 1);
	#endif
	return 1;
}

public OnPlayerConnect(playerid)
{
	gTeamkillCount[playerid][0] = 0;
	gTeamkillCount[playerid][1] = 0;
	gHelikillCount[playerid][0] = 0;
	gHelikillCount[playerid][1] = 0;
	gDrivebyCount[playerid][0] = 0;
	gDrivebyCount[playerid][1] = 0;
	gSpamCount[playerid][0] = 0;
	gSpamCount[playerid][1] = 0;
	gPingCount[playerid][0] = 0;
	gPingCount[playerid][1] = 0;

	for(new x=0; x<MAX_PLAYERS; x++) {
	  gSpawnkillCount[playerid][x][0] = 0;
	  gSpawnkillCount[playerid][x][1] = 0;
	}
	return 1;
}

public OnPlayerText(playerid, text[])
{
	#if SPAM_PROTECTION
		SpamProtection(playerid);
	#endif
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	if(reason == 50) {
		#if HELIKILL_PROTECTION
	  	HelikillProtection(killerid);
		#endif
	}
	if(GetPlayerTeam(killerid) == GetPlayerTeam(playerid)) {
		#if TEAMKILL_PROTECTION
	  	TeamkillProtection(killerid);
		#endif
	}
	if(!IsPlayerInAnyVehicle(playerid) && GetPlayerState(killerid) == PLAYER_STATE_DRIVER &&
		(reason == WEAPON_TEC9 || reason == WEAPON_UZI || reason == WEAPON_MP5) &&
		GetDistanceBetweenPlayers(playerid,killerid) < 100) {
		#if DRIVEBY_PROTECTION
	  	DrivebyProtection(killerid);
		#endif
	}
	#if SPAWNKILL_PROTECTION
  		SpawnkillProtection(killerid,playerid);
	#endif

	return 1;
}

stock TeamkillProtection(killerid)
{
	new string[64];
	if(gTeamkillCount[killerid][0] == 0) { gTeamkillCount[killerid][1] = TimeStamp(); }

  gTeamkillCount[killerid][0]++;
	if(TimeStamp() - gTeamkillCount[killerid][1] > DRIVEBY_TIMELIMIT) {
		gTeamkillCount[killerid][0] = 1;
		gTeamkillCount[killerid][1] = TimeStamp();
	}
	else if(gTeamkillCount[killerid][0] == DRIVEBY_MAX_KILLS) {
		format(string,sizeof(string),"*** %s has been kicked (Excessive teamkilling)",GetName(killerid));
		SendClientMessageToAll(0xC8BEBEAA,string);
		Kick(killerid);
	}
	else if(gTeamkillCount[killerid][0] == DRIVEBY_MAX_KILLS-1) {
	  SendClientMessage(killerid,0xC8BEBEAA,"*** Stop teamkilling - Next one is a kick");
 	}
	return 1;
}

stock HelikillProtection(killerid)
{
	new string[64];
	if(gHelikillCount[killerid][0] == 0) { gHelikillCount[killerid][1] = TimeStamp(); }

  gHelikillCount[killerid][0]++;
	if(TimeStamp() - gHelikillCount[killerid][1] > HELIKILL_TIMELIMIT) {
		gHelikillCount[killerid][0] = 1;
		gHelikillCount[killerid][1] = TimeStamp();
	}
	else if(gHelikillCount[killerid][0] == HELIKILL_MAX_KILLS) {
		format(string,sizeof(string),"*** %s has been kicked (Excessive helikilling)",GetName(killerid));
		SendClientMessageToAll(0xC8BEBEAA,string);
		Kick(killerid);
	}
	else if(gHelikillCount[killerid][0] == HELIKILL_MAX_KILLS-1) {
	  SendClientMessage(killerid,0xC8BEBEAA,"*** Stop helikilling - Next one is a kick");
	}
	return 1;
}

stock DrivebyProtection(killerid)
{
	new string[64];
	if(gDrivebyCount[killerid][0] == 0) { gDrivebyCount[killerid][1] = TimeStamp(); }

  gDrivebyCount[killerid][0]++;
	if(TimeStamp() - gDrivebyCount[killerid][1] > DRIVEBY_TIMELIMIT) {
	  gDrivebyCount[killerid][1] = TimeStamp();
		gDrivebyCount[killerid][0] = 1;
	}
	else if(gDrivebyCount[killerid][0] == DRIVEBY_MAX_KILLS) {
		format(string,sizeof(string),"*** %s has been kicked (Excessive drivebying)",GetName(killerid));
		SendClientMessageToAll(0xC8BEBEAA,string);
		Kick(killerid);
	}
	else if(gDrivebyCount[killerid][0] == DRIVEBY_MAX_KILLS-1) {
	  SendClientMessage(killerid,0xC8BEBEAA,"*** Pбra com o drivebying - Prуxima vez serб kick ou BAN !!!");
	}
	return 1;
}

stock SpawnkillProtection(killerid, playerid)
{
	new string[64];
	if(gSpawnkillCount[killerid][playerid][0] == 0) { gSpawnkillCount[killerid][playerid][1] = TimeStamp(); }

  gSpawnkillCount[killerid][playerid][0]++;
	if(TimeStamp() - gSpawnkillCount[killerid][playerid][1] > SPAWNKILL_TIMELIMIT) {
		gSpawnkillCount[killerid][playerid][0] = 1;
		gSpawnkillCount[killerid][playerid][1] = TimeStamp();
	}
	else if(gSpawnkillCount[killerid][playerid][0] == SPAWNKILL_MAX_KILLS) {
		format(string,sizeof(string),"*** %s has been kicked (Spawnkilling)",GetName(killerid));
		SendClientMessageToAll(0xC8BEBEAA,string);
		Kick(killerid);
	}
	else if(gSpawnkillCount[killerid][playerid][0] == SPAWNKILL_MAX_KILLS-1) {
	  SendClientMessage(killerid,0xC8BEBEAA,"*** Stop spawnkilling - Next one is a kick");
	}
 	return 1;
}

stock SpamProtection(playerid)
{
	new string[64];
	if(gSpamCount[playerid][0] == 0) { gSpamCount[playerid][1] = TimeStamp(); }

  gSpamCount[playerid][0]++;
	if(TimeStamp() - gSpamCount[playerid][1] > SPAM_TIMELIMIT) {
		gSpamCount[playerid][0] = 1;
		gSpamCount[playerid][1] = TimeStamp();
	}
	else if(gSpamCount[playerid][0] == SPAM_MAX_MSGS) {
		format(string,sizeof(string),"*** %s foi expluso por Flood/Spam (Protection)",GetName(playerid));
		SendClientMessageToAll(0xC8BEBEAA,string);
		Kick(playerid);
	}
	// Best not to help them figure out the time limits
	/*else if(gSpamCount[playerid][0] == SPAM_MAX_MSGS-1) {
	  SendClientMessage(playerid,0xC8BEBEAA,"*** Stop spamming - Next one is a kick");
	}*/
 	return 1;
}

public PingProtection()
{
	new string[64];
	for(new x=0; x<MAX_PLAYERS; x++) {
	  if(GetPlayerPing(x) > PING_MAX_PING) {

			if(gPingCount[x][0] == 0) { gPingCount[x][1] = TimeStamp(); }

  		gPingCount[x][0]++;
			if(TimeStamp() - gPingCount[x][1] > PING_TIMELIMIT) {
	  		gPingCount[x][1] = TimeStamp();
				gPingCount[x][0] = 1;
			}
			else if(gPingCount[x][0] == PING_MAX_EXCEEDS) {
				format(string,sizeof(string),"*** %s desliga os downloads (Ping Exceeds %dms)",GetName(x), PING_MAX_PING);
				SendClientMessageToAll(0xC8BEBEAA,string);
				Kick(x);
			}
		}
	}
	return 1;
}

stock Float:GetDistanceBetweenPlayers(p1,p2)
{
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;

	if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
		return -1.00;
	}
	GetPlayerPos(p1,x1,y1,z1);
	GetPlayerPos(p2,x2,y2,z2);
	return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}

stock GetName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,sizeof(name));

	return name;
}

stock TimeStamp()
{
	new time = GetTickCount() / 1000;
	return time;
}
Reply


Messages In This Thread
[FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by [NoV]HAMM3R - 07.07.2007, 05:43
Re: [FS|0.2] Basic Protections (DB, TK, Heli, Spawnkill, Spam) - by Maikel - 07.07.2007, 06:18
Re: [FS|0.2] Basic Protections (DB, TK, Heli, Spawnkill, Spam) - by Duelos SA - 07.07.2007, 06:20
Re: [FS|0.2] Basic Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]HAMM3R - 07.07.2007, 06:27
Re: [FS|0.2] Basic Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]dzvera - 07.07.2007, 06:36
Re: [FS|0.2] Basic Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]HAMM3R - 07.07.2007, 06:39
Re: [FS|0.2] Basic Protections (DB, TK, Heli, Spawnkill, Spam) - by Warriors_Tornado - 07.07.2007, 08:45
Re: [FS|0.2] Basic Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]HAMM3R - 07.07.2007, 08:51
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by [SMB]Bip - 07.07.2007, 09:11
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by Warriors_Tornado - 07.07.2007, 09:29
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]HAMM3R - 07.07.2007, 09:41
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]HAMM3R - 07.07.2007, 09:43
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by Warriors_Tornado - 07.07.2007, 09:58
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by MaTrIx4057 - 07.07.2007, 10:04
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]HAMM3R - 07.07.2007, 23:42
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by Duelos SA - 09.07.2007, 03:04
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by Warriors_Tornado - 09.07.2007, 14:32
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Spam) - by [NoV]HAMM3R - 09.07.2007, 19:09
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by [NoV]HAMM3R - 09.07.2007, 19:53
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Warriors_Tornado - 09.07.2007, 20:27
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by [NoV]HAMM3R - 09.07.2007, 21:10
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Duelos SA - 10.07.2007, 01:33
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Duelos SA - 10.07.2007, 22:16
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Fire_in_the_hole - 03.02.2008, 16:13
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by cmg4life - 03.02.2008, 16:47
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by croherzegovina - 08.02.2008, 13:07
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Fire_in_the_hole - 09.02.2008, 18:47
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by lepompier - 12.05.2008, 09:21
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by [BG]MR.C - 12.05.2008, 10:52
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by lepompier - 12.05.2008, 11:01
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by OrlGiNS - 20.06.2008, 22:48
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by ThePro - 21.06.2008, 00:02
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by OrlGiNS - 21.06.2008, 12:54
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Vyorel - 09.09.2008, 07:29
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Duelos SA - 09.12.2008, 19:50
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by GORE - 27.12.2008, 12:02
Re: [FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by Danut - 25.01.2009, 08:34
[FS|0.2] Player Protections (DB, TK, Heli, Spawnkill, Ping, Spam) - by [NoV]LaZ - 25.01.2009, 10:04

Forum Jump:


Users browsing this thread: 5 Guest(s)