SA-MP Forums Archive
Check IP - 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: Check IP (/showthread.php?tid=417509)



Check IP - SiggaSvana - 21.02.2013

Hello.
Is someone out there with a big heart that can script for me a command that shows IP?

Like: /ip NAMEOFPLAYER and it shows his IP. Must be name, not id.

I use zcmd.

Thank you so much in advance!


Re: Check IP - Neil. - 21.02.2013

This ain't the script request thread but anyways, I'll give you some pointers.

1. Create a new Command
2. Create a string (Preferrably 28 bytes)
3. Format the string and use GetPlayerIp
4. SSCANF. (Something like,
pawn Код:
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /ip [playerid]");
5. Process the result and voila!


Re: Check IP - SiggaSvana - 21.02.2013

Quote:
Originally Posted by Ken97
Посмотреть сообщение
This ain't the script request thread but anyways, I'll give you some pointers.

1. Create a new Command
2. Create a string (Preferrably 28 bytes)
3. Format the string and use GetPlayerIp
4. SSCANF. (Something like,
pawn Код:
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Usage: /ip [playerid]");
5. Process the result and voila!
Baby boo, I have no idea what you just said :P I will post this elsewhere


Re: Check IP - Xeiss - 21.02.2013

Next time please go to the Script Request thread
Код:
CMD:ip(playerid, params[]) {
	new id, ip[30], ipstr[30];
	if (sscanf(params, "d", id)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /ip [id]");
	GetPlayerIp(id, ip, sizeof(ip));
	format(ipstr, sizeof(ipstr), "%s", ip);
	SendClientMessage(playerid, 0xFFFFFFFF, ipstr);
	return 1;
}



Re: Check IP - Goldino - 21.02.2013

Even better:

Код:
CMD:getip( playerid, params[] )
{
	new ip[45],
		id,
		name[128],
		str[128];
		
	if(sscanf(params, "u", id ) )
	    return 	SendClientMessage(playerid, -1, "Usage: /getip [playerid]");
		
   	if ( id == INVALID_PLAYER_ID )
	    return SendClientMessage( playerid, RED, "That player is not connected!" );

	if ( id == playerid )
	    return SendClientMessage( playerid, RED, "You cannot get your own IP!");
	    
 	GetPlayerIp(id, ip, sizeof(ip));
	GetPlayerName(id,name,sizeof(name));
	format(str, sizeof (str), "%'s IP is: %i", name, ip );
	SendClientMessage(playerid, -1, str);
	return 1;
}



Re: Check IP - Djole1337 - 21.02.2013

@Goldino,

IP string should be 16.


Re: Check IP - Goldino - 21.02.2013

Quote:
Originally Posted by Mr_DjolE
Посмотреть сообщение
@Goldino,

IP string should be 16.
Sorry, edited:
Код:
CMD:getip( playerid, params[] )
{
	new ip[16],
	       id,
	       name[128],
	       str[128];
		
	if(sscanf(params, "u", id ) )
	    return 	SendClientMessage(playerid, -1, "Usage: /getip [playerid]");
		
   	if ( id == INVALID_PLAYER_ID )
	    return SendClientMessage( playerid, RED, "That player is not connected!" );

	if ( id == playerid )
	    return SendClientMessage( playerid, RED, "You cannot get your own IP!");
	    
 	GetPlayerIp(id, ip, sizeof(ip));
	GetPlayerName(id,name,sizeof(name));
	format(str, sizeof (str), "%'s IP is: %i", name, ip );
	SendClientMessage(playerid, -1, str);
	return 1;
}