Check IP
#1

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!
Reply
#2

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!
Reply
#3

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
Reply
#4

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;
}
Reply
#5

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;
}
Reply
#6

@Goldino,

IP string should be 16.
Reply
#7

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)