SA-MP Forums Archive
GetPlayerName on Dialog? - 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)
+--- Thread: GetPlayerName on Dialog? (/showthread.php?tid=427195)



GetPlayerName on Dialog? - Morten_Guado - 31.03.2013

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.


Re: GetPlayerName on Dialog? - Harti - 31.03.2013

Use strcat instead of format.


Re: GetPlayerName on Dialog? - Morten_Guado - 31.03.2013

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.


Re: GetPlayerName on Dialog? - Morten_Guado - 31.03.2013

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.


Re: GetPlayerName on Dialog? - Harti - 31.03.2013

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.


Re: GetPlayerName on Dialog? - Windrush - 31.03.2013

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



Re: GetPlayerName on Dialog? - Morten_Guado - 31.03.2013

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

Anyway, thanks a lot. It compiles fine.