SA-MP Forums Archive
Help with /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: Help with /ip (/showthread.php?tid=565096)



Help with /ip - HighHP - 25.02.2015

So when ever you do /ip it just says '49' here is me code
Код:
    if(strcmp(cmd, "/ip", true) == 0)
    {
        new playerip[16];
		strtok(cmdtext, idx);
		tmp = strtok(cmdtext, idx);
		giveplayerid = strval(tmp);
	 	GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
                format(string, 128, "%d",playerip);
		SendClientMessage(playerid, COLOR_HPDRIFT, string);
		return 1;
	}



Re: Help with /ip - -=Dar[K]Lord=- - 25.02.2015

Actually you are trying to convert a string to integer type this causes the conversion of the strings value in integer so if you want to format an array to a type you should use these..

%s - string
%d , %i - integer values
%f - float values
%c - character value

So your code will be as follows..

Код:
if(strcmp(cmd, "/ip", true) == 0)
    {
        new playerip[16];
		strtok(cmdtext, idx);
		tmp = strtok(cmdtext, idx);
		giveplayerid = strval(tmp);
	 	GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
                format(string, 128, "%s",playerip);
		SendClientMessage(playerid, COLOR_HPDRIFT, string);
		return 1;
	}
Sorry for spelling mistakes im on my android phone ;_;


Re: Help with /ip - Nabster - 25.02.2015

Use %s instead of %d


Re: Help with /ip - Beckett - 25.02.2015

IP is a string not an integer.