Adding the players name into GUI ;/
#1

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

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");
Reply
#3

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

Thank you both, it works
Reply


Forum Jump:


Users browsing this thread: