SA-MP Forums Archive
GetPlayerName problem - 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: GetPlayerName problem (/showthread.php?tid=462983)



GetPlayerName problem - ExtendedCarbon - 09.09.2013

I'm trying to make it display the users name when he dies

I have this under onplayerdeath
Код:
    if(IsPlayerInRangeOfPoint(playerid, 70, 85.0713,1748.0396,-59.2546))
    {
        new name[MAX_PLAYER_NAME+1];
        GetPlayerName(playerid, name, sizeof(name));
        SendClientMessageToAll(COLOR_PURPLE,"%d has died in the /bf");
    }
But it just shows up in game as



Re: GetPlayerName problem - Konstantinos - 09.09.2013

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 70, 85.0713,1748.0396,-59.2546))
{
    new name[MAX_PLAYER_NAME+1], msg[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(msg, sizeof(msg), "%s has died in the /bf", name);
    SendClientMessageToAll(COLOR_PURPLE,msg);
}
You need to format the message first and then send it.


Re: GetPlayerName problem - ExtendedCarbon - 09.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 70, 85.0713,1748.0396,-59.2546))
{
    new name[MAX_PLAYER_NAME+1], msg[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(msg, sizeof(msg), "%s has died in the /bf", name);
    SendClientMessageToAll(COLOR_PURPLE,msg);
}
You need to format the message first and then send it.
Thanks for that, do you mind explaining the format thing? Because I'm pretty new to scripting and this isn't an area I've covered.

+Rep for helping me with tho's lines of code anyway


Re: GetPlayerName problem - Konstantinos - 09.09.2013

format

You format a message and then you do what you want with that formatted message.

Parameters:
(output[], len, const format[], {Float,_}:...)

You declare a variable with the size in []
pawn Код:
// example:
new
    some_string[ 128 ] // 128 is the max client message
;
So, it goes:
pawn Код:
format( some_string, sizeof( some_string ), "An example of what we're going to print here. A string: %s | An integer: %d | A float: %f", "some text here", 10, 50.6418 );
Done. Then you can send client/player message or in print(f), gametexts/textdraws etc.


Re: GetPlayerName problem - ExtendedCarbon - 09.09.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
format

You format a message and then you do what you want with that formatted message.

Parameters:
(output[], len, const format[], {Float,_}:...)

You declare a variable with the size in []
pawn Код:
// example:
new
    some_string[ 128 ] // 128 is the max client message
;
So, it goes:
pawn Код:
format( some_string, sizeof( some_string ), "An example of what we're going to print here. A string: %s | An integer: %d | A float: %f", "some text here", 10, 50.6418 );
Done. Then you can send client/player message or in print(f), gametexts/textdraws etc.
Perfect! Thanks so much