SA-MP Forums Archive
A little question about GameTextForPlayer - 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: A little question about GameTextForPlayer (/showthread.php?tid=586903)



A little question about GameTextForPlayer - saffierr - 26.08.2015

I've got an question, as soon as you connect to my server you will receive an message with "Welcome"

PHP код:
public OnPlayerRequestSpawn(playerid)
{
GameTextForPlayer(playerid"Welcome"25003);
return 
1;

But... I wanted to make it "Welcome %s", so It'd be "Welcome [players name]", I tried to do this.

PHP код:
public OnPlayerRequestSpawn(playerid)
{
new 
pName[MAX_PLAYER_NAME];
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
GameTextForPlayer(playerid"Welcome %s"25003pName);
return 
1
but it gives me an warning namely;
Quote:

warning 202: number of arguments does not match definition

and I know the warning is about the pName, in the GameTextForPlayer line, but how can I make it like I want?


Re: A little question about GameTextForPlayer - Threshold - 26.08.2015

You need to make use of the 'format' function.

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    new pName[MAX_PLAYER_NAME], welcomestring[35];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(welcomestring, sizeof(welcomestring), "Welcome %s", pName);
    GameTextForPlayer(playerid, welcomestring, 2500, 3);
    return 1;
}
https://sampwiki.blast.hk/wiki/Format