OnPlayerText not getting player color.
#1

Hi, this isn't getting the player color, even if I change the color in-game it will throw it on white
Code:
pawn Код:
public OnPlayerText(playerid, text[])
{
new message[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(message, sizeof(message), "%s(%i): %s", name, playerid, text);
SendClientMessageToAll(-1, message);
return 0;
}
Reply
#2

I'm sorry, what?
Reply
#3

You have to use the color of the player to show the correct color.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(message, sizeof message, "%s(%d): {FFFFFF}%s", name, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid), message);
    return 0;
}
Reply
#4

try this

Код:
public OnPlayerText(playerid, text[])
{
new message[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(message, sizeof(message), "%s(%i): {ffffff}%s", name, playerid, text);
SendClientMessageToAll(GetPlayerColor(playerid), message);
return 0;
}
Reply
#5

Quote:
Originally Posted by BigETI
Посмотреть сообщение
You have to use the color of the player to show the correct color.
pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(message, sizeof message, "%s(%d): {FFFFFF}%s", name, playerid, text);
    SendClientMessageToAll(GetPlayerColor(playerid), message);
    return 0;
}
Ok i'll try it.


haha i was trying like this lol
pawn Код:
public OnPlayerText(playerid, text[])
{
    new message[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        GetPlayerColor(playerid);
    format(message, sizeof message, "%s(%d): {FFFFFF}%s", name, playerid, text);
    SendClientMessageToAll(playerid, message);
    return 0;
}
EDIT: YES! it works perfectly thanks
but it sets the player color to black. is there a way to make it random. because everyone will be black in the server lol
Reply
#6

Are you even serious?

You're using GetPlayerColor then going no where with it.
Reply
#7

SendPlayerMessageToAll is probably a better option than SendClientMessageToAll.
Reply
#8

You have to set the player's color before you use GetPlayerColor, otherwise it will return 0.
Reply
#9

Quote:
Originally Posted by Vince
Посмотреть сообщение
SendPlayerMessageToAll is probably a better option than SendClientMessageToAll.
Hey! this is exactly what I needed. This whole thing was because I wanted to show the player id next to the name.

Thanks Vince!!

Thanks BigETI!!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)