GetPlayerName problem
#1

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

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.
Reply
#3

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

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.
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)