09-23-2007, 07:55 AM
[move]Didnt made ma self but for u [/move]
Simple script to kick players who "excessively" driveby, teamkill, helikill, spawnkill, and spam.
Used on Novocaine server (not currently). The number of infractions and time frame for each protection are configurable via defines as well as enabling and disabling each protection individually.
It works fine on linux. I heard a rumor about GetTickCount() not working correctly on Windows...
Brief explanation of settings:
Code:
#define DRIVEBY_PROTECTION 1 // Driveby protection is enabled. 1 = on, 0 = off
#define DRIVEBY_MAX_KILLS 5 // The number of driveby kills a user must accumulate within the time limit (DRIVEBY_TIMELIMIT)
#define DRIVEBY_TIMELIMIT 600 // The number of seconds during which the MAX_KILLS quota must be reached for a kick to be triggered
UPDATE (7/7/07): Setting the *_MAX_KILLS and *_TIMELIMIT to 1 will kick the player on the first infraction.
/*******************************************************************************
Player Protections (Driveby, teamkill, helikill, spawnkill, chat spam)
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 1
#define HELIKILL_MAX_KILLS 5
#define HELIKILL_TIMELIMIT 600 // 10 MINUTES
#define DRIVEBY_PROTECTION 1
#define DRIVEBY_MAX_KILLS 5
#define DRIVEBY_TIMELIMIT 600 // 10 MINUTES
#define TEAMKILL_PROTECTION 1
#define TEAMKILL_MAX_KILLS 5
#define TEAMKILL_TIMELIMIT 600 // 10 MINUTES
#define SPAWNKILL_PROTECTION 1
#define SPAWNKILL_MAX_KILLS 4
#define SPAWNKILL_TIMELIMIT 40 // 40 SECONDS
#define SPAM_PROTECTION 1
#define SPAM_MAX_MSGS 4
#define SPAM_TIMELIMIT 8 // 8 SECONDS
forward Float:GetDistanceBetweenPlayers(p1,p2);
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];
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;
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,"*** Stop drivebying - Next one is a kick");
}
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 has been kicked (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;
}
stock Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float
1,Float:x2,Float:y2,Float
2;
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;
}
Simple script to kick players who "excessively" driveby, teamkill, helikill, spawnkill, and spam.
Used on Novocaine server (not currently). The number of infractions and time frame for each protection are configurable via defines as well as enabling and disabling each protection individually.
It works fine on linux. I heard a rumor about GetTickCount() not working correctly on Windows...
Brief explanation of settings:
Code:
#define DRIVEBY_PROTECTION 1 // Driveby protection is enabled. 1 = on, 0 = off
#define DRIVEBY_MAX_KILLS 5 // The number of driveby kills a user must accumulate within the time limit (DRIVEBY_TIMELIMIT)
#define DRIVEBY_TIMELIMIT 600 // The number of seconds during which the MAX_KILLS quota must be reached for a kick to be triggered
UPDATE (7/7/07): Setting the *_MAX_KILLS and *_TIMELIMIT to 1 will kick the player on the first infraction.
/*******************************************************************************
Player Protections (Driveby, teamkill, helikill, spawnkill, chat spam)
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 1
#define HELIKILL_MAX_KILLS 5
#define HELIKILL_TIMELIMIT 600 // 10 MINUTES
#define DRIVEBY_PROTECTION 1
#define DRIVEBY_MAX_KILLS 5
#define DRIVEBY_TIMELIMIT 600 // 10 MINUTES
#define TEAMKILL_PROTECTION 1
#define TEAMKILL_MAX_KILLS 5
#define TEAMKILL_TIMELIMIT 600 // 10 MINUTES
#define SPAWNKILL_PROTECTION 1
#define SPAWNKILL_MAX_KILLS 4
#define SPAWNKILL_TIMELIMIT 40 // 40 SECONDS
#define SPAM_PROTECTION 1
#define SPAM_MAX_MSGS 4
#define SPAM_TIMELIMIT 8 // 8 SECONDS
forward Float:GetDistanceBetweenPlayers(p1,p2);
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];
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;
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,"*** Stop drivebying - Next one is a kick");
}
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 has been kicked (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;
}
stock Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float
1,Float:x2,Float:y2,Float
2;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;
}