It Online Show ID not Playername (ID)
#1

So when I do /jailed it only shows (ID:0) not the whole name and id like this Playername (ID:2)

pawn Код:
dcmd_jailed(playerid,params[])
{
    #pragma unused params
    if(AccInfo[playerid][LoggedIn] == 1)
    {
        if(AccInfo[playerid][Level] >= 1)
        {
            new Count, str[512];
            for(new i; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && AccInfo[i][Jailed])
                {
                    format(str, sizeof(str), "%s (ID: %d)\n", i, PlayerName2(i));
                    Count++;
                }
            }
            if(Count == 0) strcat(str, "No players are Jailed!\n");
            return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Jailed Players", str, "OK", "");
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF,"{FF0000}ERROR: You must be logged in to use this commands");
}
Reply
#2

Quote:
Originally Posted by kbalor
Посмотреть сообщение
So when I do /jailed it only shows (ID:0) not the whole name and id like this Playername (ID:2)

pawn Код:
dcmd_jailed(playerid,params[])
{
    #pragma unused params
    if(AccInfo[playerid][LoggedIn] == 1)
    {
        if(AccInfo[playerid][Level] >= 1)
        {
            new Count, str[512];
            for(new i; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && AccInfo[i][Jailed])
                {
                    format(str, sizeof(str), "%s (ID: %d)\n", i, PlayerName2(i));
                    Count++;
                }
            }
            if(Count == 0) strcat(str, "No players are Jailed!\n");
            return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Jailed Players", str, "OK", "");
        }
        else return ErrorMessages(playerid, 1);
    }
    else return SendClientMessage(playerid, 0xFFFFFFFF,"{FF0000}ERROR: You must be logged in to use this commands");
}
pawn Код:
format(str, sizeof(str), "%s (ID: %d)\n", PlayerName2(i), i);
PS. string size 512? change it to like 64...
Reply
#3

pawn Код:
format(str, sizeof(str), "%s%s (ID: %d)\n",str,PlayerName2(i),i);
Reply
#4

Quote:
Originally Posted by ddnbb
Посмотреть сообщение
pawn Код:
format(str, sizeof(str), "%s (ID: %d)\n", PlayerName2(i), i);
PS. string size 512? change it to like 64...
Thanks man its working now.
I also have same problem but this time the ID doesn't show
Код:
if(!strlen(params[strlen(tmp2)+1]))
format(string,sizeof(string),"%s has Frozen %s",adminname,playername);
else format(string,sizeof(string),"%s has Frozen %s | Reason: %s",adminname,playername,params[strlen(tmp)+1]);
I think the purpose of 512.. what if they are around 20 players in jailed? and their names are long.
Reply
#5

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
format(str, sizeof(str), "%s%s (ID: %d)\n",str,PlayerName2(i),i);
Both are working and same, but what is the difference??
Reply
#6

Code by ddnbb shows only one person, my all in jail
Reply
#7

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Both are working and same, but what is the difference??
EDIT: NVM
Reply
#8

Thanks I give rep to you both

If you have time to fix this, it only show name not with the ID.

It should be something like this "Playername (ID:2)

Код:
if(!strlen(params[strlen(tmp2)+1]))
format(string,sizeof(string),"%s has Frozen %s",adminname,playername);
else format(string,sizeof(string),"%s has Frozen %s | Reason: %s",adminname,playername,params[strlen(tmp)+1]);
Reply
#9

pawn Код:
format(string,sizeof(string),"%s(%i) has Frozen %s",adminname,adminid, playername);
Do something like this. You obviously are a very new beginner.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)