SA-MP Forums Archive
Name of player in text - 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: Name of player in text (/showthread.php?tid=557964)



Name of player in text - xX4m4zingXx - 15.01.2015

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"));



Re: Name of player in text - Schneider - 15.01.2015

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");



Re: Name of player in text - HazardouS - 15.01.2015

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



Re: Name of player in text - Abagail - 15.01.2015

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


Re: Name of player in text - xX4m4zingXx - 15.01.2015

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