Name of player in text
#1

I want to add the player name in this text on the place NAMEHERE
Код:
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login","{F7C600}Welcome back {458CFF} [NAMEHERE].","Login","Quit"));
Reply
#2

pawn Код:
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string),"{F7C600}Welcome back {458CFF}%s.", pName);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""COL_WHITE"Login", string, "Login","Quit");
Reply
#3

Format a string first:
pawn Код:
new string[128], playerName[24]; //declare the variables
GetPlayerName(playerid, playerName, sizeof(playerName)); //get the name
format(string, 128, "{F7C600}Welcome back {458CFF} %s.", playerName); //generate the string you want to be displayed in the dialog
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login", string,"Login","Quit")); //insert the string in the "info" field of the dialog
Reply
#4

You can achieve this by instead of placing the name directly there(which wouldn't work in PAWN - but in other similar languages such as PHP), formatting a string, and then inserting said string.

See the format function for more information;
https://sampwiki.blast.hk/wiki/format
Reply
#5

Thank you for the reactions, I got it working because of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)