This will run through all players and check what IP's each of them have, and if they have the same one, it prints.
Here is an example with teams:
Code:
public Action CmdIp(int client, int args)
{
Handle cliparr = CreateArray(MAXPLAYERS+1);
Handle clarr = CreateArray(MAXPLAYERS+1);
for (int i = 1;i<MaxClients+1;i++)
{
if (IsValidEntity(i))
{
if (IsClientConnected(i))
{
char curip[32];
GetClientIP(i,curip,sizeof(curip));
int finddupe = FindStringInArray(cliparr,curip);
if (finddupe == -1)
{
PushArrayString(cliparr,curip);
PushArrayCell(clarr,i);
}
else
{
int lastcl = GetArrayCell(clarr,finddupe);
if (GetClientTeam(i) != GetClientTeam(lastcl))
{
PrintToConsole(client,"%N and %N are on the same IP %s and they are on different teams.",i,lastcl,curip);
ChangeClientTeam(i,GetClientTeam(lastcl));
}
else PrintToConsole(client,"%N and %N are on the same IP %s and same team.",i,lastcl,curip);
}
}
}
}
PrintToConsole(client,"%i IPs checked.",GetArraySize(cliparr));
CloseHandle(clarr);
CloseHandle(cliparr);
return Plugin_Handled;
}
Having 6 bots, and 2 of them (Bot04 and Bot06) are on the other team, this is the output:
Code:
Bot02 and Bot01 are on the same IP 127.0.0.1 and same team.
Bot03 and Bot01 are on the same IP 127.0.0.1 and same team.
Bot04 and Bot01 are on the same IP 127.0.0.1 and they are on different teams.
"Bot04<5><__BOT__><Unassigned>" joined team "CT"
Bot05 and Bot01 are on the same IP 127.0.0.1 and same team.
Bot06 and Bot01 are on the same IP 127.0.0.1 and they are on different teams.
"Bot06<7><__BOT__><Unassigned>" joined team "CT"
1 IPs checked.
Then running again gives:
Bot02 and Bot01 are on the same IP 127.0.0.1 and same team.
Bot03 and Bot01 are on the same IP 127.0.0.1 and same team.
Bot04 and Bot01 are on the same IP 127.0.0.1 and same team.
Bot05 and Bot01 are on the same IP 127.0.0.1 and same team.
Bot06 and Bot01 are on the same IP 127.0.0.1 and same team.
The IP 127.0.0.1 is the loopback address, basically meaning that it is the server's address. If you are going to be running bots, you would probably want to exclude that IP from checks, or use (!IsFakeClient(i))
As of current, it just checks whichever team was found first in the array of players on the same team. So if Bot01 was on CT, the next checks would be whether or not Bot02 through 6 are on CT.
This will automatically add them to the team of the first found duplicate IP.