06.09.2015, 09:51
(
Последний раз редактировалось Rodri99; 06.09.2015 в 10:33.
)
CLOSED.
stock GetIPs(playerid)
{
new allip[33],
playersip[33],
count = 0;
GetPlayerIp(playerid,playersip,sizeof(playersip));
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i) && i != playerid)
{
GetPlayerIp(i,allip,sizeof(allip));
if(strcmp(allip, playersip, true) == 0) count++;
}
}
return count;
}
public OnPlayerConnect(playerid)
{
new IPs = GetIPs(playerid);
if(IPs >= 2 && !IsPlayerNPC(playerid))
{
SendClientMessage(playerid, -1,"Error: You are already connected in game with the same Internet Protocol!");
Kick(playerid);
}
return 0;
}
#define MAX_IP_LIMIT 2
public OnPlayerConnect(playerid)
{
KickIP(playerid);
return 1;
}
KickIP(playerid, limit = MAX_IP_LIMIT, bool:kickall = false)
{
if(!IsPlayerConnected(playerid)) return 0;
new cnt = 1, kickip[16], playerip[16];
GetPlayerIp(playerid, kickip, sizeof(kickip));
if(kickall)
{
new playerstokick[MAX_PLAYERS];
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i) || i == playerid) continue;
GetPlayerIp(i, playerip, sizeof(playerip));
if(!strcmp(playerip, kickip, true)) playerstokick[(cnt++ - 1)] = i;
}
if(cnt <= limit) return 0;
for(new i = 0; i < cnt; i++)
{
SetTimerEx("KickPlayer", 200, false, "i", playerstokick[i]);
//SendClientMessage(playerid, -1, "Error: You have exceeded the IP limit!");
}
}
else
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i) || i == playerid) continue;
GetPlayerIp(i, playerip, sizeof(playerip));
if(!strcmp(playerip, kickip, true)) cnt++;
}
if(cnt <= limit) return 0;
SetTimerEx("KickPlayer", 200, false, "i", playerid);
//SendClientMessage(playerid, -1, "Error: You have already reached the IP limit!");
}
return cnt;
}
forward KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);
#define MAX_IP_LIMIT 2
KickIP(playerid, limit = MAX_IP_LIMIT, bool:kickall = false)
public OnPlayerConnect(playerid)
{
KickIP(playerid);
return 1;
}
public OnPlayerConnect(playerid)
{
KickIP(playerid, .kickall = true);
return 1;
}