Player list command
#1

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

the IP is a string not a float..
pawn Код:
format(string, sizeof(string), "(ID:%i) %s (%s)", i, name, ip);
Reply
#3

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

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.
Reply
#5

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

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

now you know^^
Reply
#8

Quote:
Originally Posted by Sascha
Посмотреть сообщение
now you know^^
Yea, thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)