SA-MP Forums Archive
/getip command for all online players? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /getip command for all online players? (/showthread.php?tid=599870)



/getip command for all online players? - Rodri99 - 31.01.2016

How can i make a command that check all players IPs online in my server, and find the players that has the /getip IP_EXAMPLE ?

Ex.

/getip 184.43.54.245
Info: 184.43.54.245 is Max (ID:3)


Regards,
Rodri.


Re: /getip command for all online players? - Sascha - 31.01.2016

That should do
(didn't test to compile)
Код:
COMMAND:getip(playerid, params[])
{
	new ip[20], rst = -1;
	for(new i=0, j=GetPlayerPoolSize(); i<=j; i++)
	{
		if(IsPlayerConnected(i))
		{
			GetPlayerIp(i, ip, sizeof(ip));
			if(!strcmp(ip, params, true))
			{
			    rst = i;
			    break;
			}
		}
	}
	if(rst == -1) return SendClientMessage(playerid, -1, "No player found");
	new string[100];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(rst, name, sizeof(name));
	formt(string, sizeof(string), "%s(%d) has the IP: %s", name, rst, params);
	SendClientMessage(playerid, -1, string);
	return 1;
}