AntiBotAttack/Ddos script for SAMP

Write your "How To" regarding anything you are comfortable with and you feel it will help the forum members.

NOTE :: All threads started here will appear only after the approval from Administrator
Post Reply
Maddi_Jane
Posts: 12
Joined: Tue Jan 24, 2012 3:46 am

AntiBotAttack/Ddos script for SAMP

Post by Maddi_Jane » Tue Jan 24, 2012 5:34 am

AntiBotAttack/Ddos:To prevent your server from being Ddosed by noob people.
This script is made by Amit_B.not me.im just sharing with you guys.so copy this code into your pawno.and compiled :)


pawno code:
// Bots Security Script v1.0B by Amit_B
#include "a_samp.inc"
new var[MAX_PLAYERS] = {-1,...}, warns[MAX_PLAYERS] = {0,...}, bool:npc[MAX_PLAYERS] = {false,...}, MAX_PLAYERS_ = MAX_PLAYERS;
public OnFilterScriptInit()
{
SendRconCommand("reloadbans");
print("Bots Security Script v1.0B loaded");
return 1;
}
public OnPlayerConnect(playerid)
{
if(CountIP(GetIP(playerid)) >= 6) return ****(playerid), 0;
MAX_PLAYERS_ = playerid > MAX_PLAYERS_ ? playerid : GetHighestID(),
npc[playerid] = bool:IsPlayerNPC(playerid),
var[playerid] = SetTimerEx("BSS",2500,false,"i",playerid),
warns[playerid] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
MAX_PLAYERS_ = GetHighestID(playerid);
if(npc[playerid]) npc[playerid] = false;
if(var[playerid] != -1)
{
KillTimer(var[playerid]);
var[playerid] = -1;
}
warns[playerid] = 0;
return 1;
}
stock CountIP(ip[])
{
new c = 0;
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !strcmp(GetIP(i),ip)) c++;
return c;
}
forward BSS(playerid);
public BSS(playerid)
{
new i = GetPlayerPing(playerid);
if(i <= 0 || i >= 50000)
{
if(warns[playerid] >= 1) ****(playerid);
else warns[playerid]++, var[playerid] = SetTimerEx("BSS",1500,false,"i",playerid);
}
return 0;
}
stock GetIP(playerid)
{
new ip[16];
GetPlayerIp(playerid,ip,sizeof(ip));
return ip;
}
stock ****(playerid)
{
new ip[32];
GetPlayerIp(playerid,ip,sizeof(ip));
for(new i = 0, p = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !npc[i])
{
p = GetPlayerPing(i);
if(i == playerid || !strcmp(ip,GetIP(i)) || p <= 0 || p >= 50000)
{
BanEx(i,"Bot");
if(var[i] != -1)
{
KillTimer(var[i]);
var[i] = -1;
}
}
}
format(ip,sizeof(ip),"banip %s",ip);
return SendRconCommand(ip);
}
stock GetHighestID(exceptof = INVALID_PLAYER_ID)
{
new h = 0;
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && i != exceptof && i > h) h = i;
return h;
}



Post Reply