Help with /ip
#1

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

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 ;_;
Reply
#3

Use %s instead of %d
Reply
#4

IP is a string not an integer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)