Using GetPlayerColor in client messages.
#1

How do I use a players color, instead of define new colors and detecting teams and stuff... My players have multiple teams so that's a huge process (Not really but hell, why not go this way)... Ok, I tried storing their color in a pColor variable and using that in the color param of SendClientMessage, that doesn't use the right color for some reason... I tried embedding pColor into the string, which I already knew would screw up :P...

So how do I embed the players color?
Reply
#2

Here's an example:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    new Name[24];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "{%06x}%s[%d]: {FFFFFF}%s", (GetPlayerColor(playerid) >>> 8), Name, playerid, text);
    SendClientMessageToAll(-1, string);
    return 0;
}
Reply
#3

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
Here's an example:

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    new Name[24];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "{%06x}%s[%d]: {FFFFFF}%s", (GetPlayerColor(playerid) >>> 8), Name, playerid, text);
    SendClientMessageToAll(-1, string);
    return 0;
}
Definitely something I didn't think of, kinda made me feel super retarded lol... I should've knew this, it's almost exactly like my radio message... Thanks Phenix
Reply
#4

Colours aren't strings, they're integers.

pawn Код:
SendClientMessageToAll(GetPlayerColor(playerid), string);
Reply
#5

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Colours aren't strings, they're integers.

pawn Код:
SendClientMessageToAll(GetPlayerColor(playerid), string);
No shit, we converted it to be usable as string by using (GetPlayerColor(playerid) >>> , then used {%06x}%s to embed it as hex...

No hard feelings, I'm glad to see you trying to help, thanks bro... Read before you think you know bro...
Reply
#6

Quote:
Originally Posted by Crayder
Посмотреть сообщение
No shit, we converted it to be usable as string by using (GetPlayerColor(playerid) >>> , then used {%06x}%s to embed it as hex...

No hard feelings, I'm glad to see you trying to help, thanks bro... Read before you think you know bro...
We? You didn't do anything, 0, nothing at all!

You should be nicer to people, I didn't want to post something that was already stated above.

Plus, the code of ThePhenix and mine does the exact same thing, in this case (The example of ThePhenix and my line).

Here's another way of doing this, assuming you stored a colour "0xFF00FFFF" in a string "PlayerInfo[playerid][pColour]":

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[144], name[MAX_PLAYER_NAME], playercolour;
    GetPlayerName(playerid, name, sizeof(name));
    sscanf(PlayerInfo[playerid][pColour], "x", playercolour);
    format(string, sizeof(string), "(%d) %s: {FFFFFF}%s", playerid, name, text);
    SendClientMessageToAll(playercolour, string);
    return 0;
}
Don't mislead others without a single clue what so ever.

- Regards,
SickAttack.
Reply
#7

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
We? You didn't do anything, 0, nothing at all!

You should be nicer to people, I didn't want to post something that was already stated above.

Plus, the code of ThePhenix and mine does the exact same thing, in this case (The example of ThePhenix and my line).

Here's another way of doing this, assuming you stored a colour "0xFF00FFFF" in a string "PlayerInfo[playerid][pColour]":

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[144], name[MAX_PLAYER_NAME], playercolour;
    GetPlayerName(playerid, name, sizeof(name));
    sscanf(PlayerInfo[playerid][pColour], "x", playercolour);
    format(string, sizeof(string), "(%d) %s: {FFFFFF}%s", playerid, name, text);
    SendClientMessageToAll(playercolour, string);
    return 0;
}
Don't mislead others without a single clue what so ever.

- Regards,
SickAttack.
Ehmm, if you would read the main post, it says that your way does not work, I already tried it... It sends the wrong colors, and if I use his code, I did do something... Also, I stated in my comment that I already had something just like his and I didn't think about it... And for you, I was being nice, I said thanks, I was glad to see you trying to help, and I said NO HARD FEELINGS... Quit being a dick, just read...
Reply
#8

pawn Код:
SendClientMessageToAll(GetPlayerColor(playerid), string);
The line above works, it's not my fault you fail..

"I was glad to see you trying to help" - To me that means failure, which isn't an option for me.
Reply
#9

Well, sorry to say, but that doesn't work... You failed to read, you failed to comprehend, you failed to keep your own policy, too bad that's not an option for you...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)