04.12.2011, 10:16
Preciso de um anti multi conexгo sabe, onde sу pode conectar 1 IP por pc, estгo me atacando com bots, mas nгo й aquelas merda de CON nгo, й bot que eles muda o nick e tal... me ajudem .. obrigado
new playerip[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
GetPlayerIp(playerid, playerip[playerid], 16);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(playerip[i] != 0 && playerip[i] == playerip[playerid])
{
Kick(i);
Kick(playerid);
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
playerip[playerid] = 0;
return 1;
}
Isso deve resolver seu problema (O codigo vai kickar os dois players que tiverem ips iguais quando houver a conexгo e lembrando que nгo manda nenhuma mensagem quando ocorre o kick. Se vocк quiser adicione a mensagem.):
Код:
new playerip[MAX_PLAYERS]; public OnPlayerConnect(playerid) { GetPlayerIp(playerid, playerip[playerid], 16); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(playerip[i] != 0 && playerip[i] == playerip[playerid]) { Kick(i); Kick(playerid); } } } return 1; } public OnPlayerDisconnect(playerid, reason) { playerip[playerid] = 0; return 1; } OBS: Eu fiz o codigo, mas nгo testei, eu acho que deve funcionar porem pode ser que nгo funcione ou de algum erro. Mas й mais ou menos isso e se tiver algum erro nгo deve ser dificil de arrumar. |
// maxips FS limits the number of players connecting from a
// single IP address.
#include <a_samp>
#define MAX_CONNECTIONS_FROM_IP 1
//---------------------------------------------
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);
Kick(playerid);
return 1;
}
return 0;
}
//---------------------------------------------