Player list command - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Player list command (
/showthread.php?tid=260776)
Player list command -
sim_sima - 10.06.2011
Hello guys.
Im trying to make a /players command that shows the playerid, name and IP, using zcmd.
I did like this:
pawn Код:
COMMAND:players(playerid, params[])
{
if(PlayerInfo[playerid][pAdminLevel] >= 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new name[MAX_PLAYER_NAME], string[28 + MAX_PLAYER_NAME], ip[16];
GetPlayerName(i, name, sizeof(name));
GetPlayerIp(i, ip, sizeof(ip));
format(string, sizeof(string), "(ID:%i) %s (%f)", i, name, ip);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
}
else return 0;
return 1;
}
But it just shows the IP like this: "0.000000000".
Hope you can help. Thank you.
Re: Player list command -
Sascha - 10.06.2011
the IP is a string not a float..
pawn Код:
format(string, sizeof(string), "(ID:%i) %s (%s)", i, name, ip);
Re: Player list command -
sim_sima - 10.06.2011
Quote:
Originally Posted by Sascha
the IP is a string not a float..
pawn Код:
format(string, sizeof(string), "(ID:%i) %s (%s)", i, name, ip);
|
Thanks, ill try.
Re: Player list command -
sim_sima - 10.06.2011
Quote:
Originally Posted by Sascha
the IP is a string not a float..
pawn Код:
format(string, sizeof(string), "(ID:%i) %s (%s)", i, name, ip);
|
Lol, thanks, it works.
i tryed both %i and %f,
i dont understand why its %s.
I really thourght IP was a float...
But thanks anyways.
Re: Player list command -
Sascha - 10.06.2011
a float is a decimal number like:
90.123 or 12512.61902 - so a number with 1 dot..
an IP has 4 dots (21.612.73.69 << random IP! or 127.0.0.1) therefore it has to be a string^^ or someone needs to invent another kind of... variable
Re: Player list command -
sim_sima - 10.06.2011
Quote:
Originally Posted by Sascha
a float is a decimal number like:
90.123 or 12512.61902 - so a number with 1 dot..
an IP has 4 dots (21.612.73.69 << random IP! or 127.0.0.1) therefore it has to be a string^^ or someone needs to invent another kind of... variable 
|
Yea. But when i thourght about an IP address, i were imidently thinking of a float, because it looks much like a float, but i didnt think about the fact that a float only can hold one dot.
Re: Player list command -
Sascha - 10.06.2011
now you know^^
Re: Player list command -
sim_sima - 10.06.2011
Quote:
Originally Posted by Sascha
now you know^^
|
Yea, thank you