09.05.2012, 22:06
Ola galera eu queria tipo que so permitice 2 ips iguais no servidor e se entrar com mais de 2 ele da ban no player
Abraзos
Abraзos
// maxips FS limits the number of players connecting from a
// single IP address.
#include <a_samp>
#define MAX_CONNECTIONS_FROM_IP 2 // aqui configura o maximo de Ips iguais.
//---------------------------------------------
public OnFilterScriptInit()
{
printf("\n*** Player IP limiting FS (maxips) Loaded. Max connections from 1 IP = %d\n",MAX_CONNECTIONS_FROM_IP);
}
//---------------------------------------------
// GetNumberOfPlayersOnThisIP
// Returns the number of players connecting from the
// provided IP address
stock GetNumberOfPlayersOnThisIP(test_ip[])
{
new against_ip[32+1];
new x = 0;
new ip_count = 0;
for(x=0; x<MAX_PLAYERS; x++) {
if(IsPlayerConnected(x)) {
GetPlayerIp(x,against_ip,32);
if(!strcmp(against_ip,test_ip)) ip_count++;
}
}
return ip_count;
}
//---------------------------------------------
public OnPlayerConnect(playerid)
{
new connecting_ip[32+1];
GetPlayerIp(playerid,connecting_ip,32);
new num_players_on_ip = GetNumberOfPlayersOnThisIP(connecting_ip);
if(num_players_on_ip > MAX_CONNECTIONS_FROM_IP) {
printf("MAXIPs: Connecting player(%d) exceeded %d IP connections from %s.", playerid, MAX_CONNECTIONS_FROM_IP, connecting_ip);
Ban(playerid); // como disse Aqui podera mudar para kick ou deixar ban mesmo ^^
return 1;
}
return 0;
}
//---------------------------------------------
#include <a_samp>
CountPlayersWithIP(ip[])
{
new
count,
player_ip[16];
for(new i; i != GetMaxPlayers(); ++i)
{
if(IsPlayerConnected(i))
{
GetPlayerIp(i, player_ip, sizeof player_ip);
count += (!strcmp(player_ip, ip, true)) ? 1 : 0;
}
}
return count;
}
public OnPlayerConnect(playerid)
{
new
count_ip,
player_ip[16];
GetPlayerIp(playerid, player_ip, sizeof player_ip);
count_ip = CountPlayersWithIP(player_ip);
if(count_ip > 2)
{
return Ban(playerid);
}
return 1;
}
public OnPlayerConnect(playerid)
{
new connecting_ip[32+1];
GetPlayerIp(playerid,connecting_ip,32);
new num_players_on_ip = GetNumberOfPlayersOnThisIP(connecting_ip);
if(num_players_on_ip > MAX_CONNECTIONS_FROM_IP)
{
printf("MAXIPs: Player conectado(%d) exedeu %d IP em ao mesmo tempo de %s.", playerid, MAX_CONNECTIONS_FROM_IP, connecting_ip);
Kick(playerid); SendClientMessageToAll(COR_CEU, "Suspeito de BOT");
return 1;
}
Nгo testei meu cуdigo, mas teste-o.
pawn Код:
|