CMD 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: CMD ip! (
/showthread.php?tid=470440)
CMD ip! -
Another1 - 18.10.2013
hello im trying to make a cmd for get the player ip but didnt work!
Код:
CMD:ip(playerid,params[])
{
new targetid;
if(sscanf(params,"u", targetid)) return SCM(playerid, RED, "Getting ip of a player:/ip <playerid>");
if(!IsPlayerConnected(targetid)) return SCM(playerid, RED, "Player is not connected");
if(!IsPlayerAdmin(playerid)) return SCM(playerid, RED, "UnKnown Command! Type /help");
new ip[25], ip_msg[30];
GetPlayerIp(playerid, ip,sizeof (ip));
format(ip_msg,sizeof (ip_msg),"(%i)",ip);
ShowPlayerDialog(playerid, DIALOG_MSG, DIALOG_STYLE_MSGBOX, "IP", ip_msg, "Close", "");
return 1;
}
Re: CMD ip! -
[FSaF]Jarno - 18.10.2013
GetPlayerIp(playerid, ip,sizeof (ip));
format(ip_msg,sizeof (ip_msg),"(%i)",ip);
to
GetPlayerIp(targetid, ip,sizeof (ip));
format(ip_msg,sizeof (ip_msg),"(%s)",ip);
GetPlayerIP returns a string, not an integer.
Re: CMD ip! -
Konstantinos - 18.10.2013
You can improve it a bit by not using format for parenteses and removing one of the arrays.
pawn Код:
CMD:ip(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SCM(playerid, RED, "UnKnown Command! Type /help");
new targetid;
if(sscanf(params,"u", targetid)) return SCM(playerid, RED, "Getting ip of a player:/ip <playerid>");
if(!IsPlayerConnected(targetid)) return SCM(playerid, RED, "Player is not connected");
new ip[16];
GetPlayerIp(playerid, ip,sizeof (ip));
ShowPlayerDialog(playerid, DIALOG_MSG, DIALOG_STYLE_MSGBOX, "IP", ip, "Close", "");
return 1;
}