SA-MP Forums Archive
Adding the players name into GUI ;/ - 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: Adding the players name into GUI ;/ (/showthread.php?tid=265465)



Adding the players name into GUI ;/ - Moron - 01.07.2011

How do i add the players name where %s is?

Код:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST,"%s","1\n2\n3\n4","OK","Cancel");
I get the name and try to add it, but i always get:

Код:
warning 202: number of arguments does not match definition



Re: Adding the players name into GUI ;/ - eDz0r - 01.07.2011

You need to format a string then introduce into ShowPlayerDialog...

This Should Work

pawn Код:
new pName[MAX_PLAYER_NAME], pString[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(pString, sizeof(pString), "%s", pName);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "%s", "1\n2\n3\n4", "OK", "Cancel");



Re: Adding the players name into GUI ;/ - Babul - 01.07.2011

the ShowPlayerDialog() takes a string as parameter which you try to format inside, that wont work. try this:
Код:
new Name(MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
new string[128];
format(string,sizeof(string),"{ffff00}%s {00ff00}(%d)",Name,playerid);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST,string,"1\n2\n3\n4","OK","Cancel");
i took the chance to also add the playerid in brackets and some color changing in the dialog string, maybe it answers an coming-up question in advance hehe
edito: nice. 1 minute post difference to eDz0r - basically the same code lol


Re: Adding the players name into GUI ;/ - Moron - 01.07.2011

Thank you both, it works