GetPlayerName on Dialog?
#1

Hi, I'm having an issue with a command. Basicly what I'm trying to do is make a command which shows me names of all players in an event. It works fine with SendClientMessage, but fills my chat with names, and I don't want that. So I decided to put those names on a Dialog, but it just shows one name.

Here is my code:

pawn Код:
if(strcmp(cmdtext,"/seeplayers",true) == 0)
{
       
    for(new i = 0; i <= MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    if(InEvent[i] == 1))
    {
        new name[MAX_PLAYER_NAME], string[50+MAX_PLAYER_NAME];
        GetPlayerName(i, name, sizeof(name));
        format(string, sizeof(string), " - %s", name);
        ShowPlayerDialog(playerid,MY_DIALOG_ID, DIALOG_STYLE_MSGBOX, "Players in Event", string, "Ok", "");//My Dialog
       
    }
    }
    }
   return 1;
}
Any help would be appreciated.
Thanks in advance.
Reply
#2

Use strcat instead of format.
Reply
#3

Quote:
Originally Posted by Harti
Посмотреть сообщение
Use strcat instead of format.
Could you please show an example?

I don't know how Strcat would go here.

Thanks.
Reply
#4

Quote:
Originally Posted by KingJohny
Посмотреть сообщение
I can Show You one

Put your friends dick in your ass.Easy

3<
Very helpful, KingJohny.
I can see where that reputation of -77 comes from.
Reply
#5

You will learn more when you try it yourself, syntax etc. is on the wiki.
But I will tell you what's wrong with your code. You are looping through all players like you should (foreach from YSI would be a better choice btw.) but then you re-format the string.
So basically it gets all names like it should but it overrides them the whole time.

strcat concatenates both strings in one.
Reply
#6

This
pawn Код:
format(string, sizeof(string), " - %s", name);
replace it
pawn Код:
strcat(string," - %s", name);
Reply
#7

I've read the strcat syntax, but was not sure of where the name should go in.

Anyway, thanks a lot. It compiles fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)