OnPlayerText + GetPlayerColor
#1

Basically, I've tried following this:
https://sampforum.blast.hk/showthread.php?tid=333430
But the name always shows black for me.
I currently use this one, since theirs was buggy for me D:

pawn Код:
public OnPlayerText(playerid, text[])
{
        new name[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid, name, sizeof(name));
        //other scripts here
        if(!PlayerInfo[playerid][pMuted])
    {
        format(string, sizeof(string), "[%d]%s: {FFFFFF}%s", playerid, name, text);
        SendClientMessageToAll(-1,string);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");
        return 0;
    }
    return 0; // Return 0 at the end as well to prevent the default chat from being sent
}
Any way to create it, so it shows the players color, instead of the -1(White), or the bugged one(black)?
Reply
#2

Try this, also note that GetPlayerColor only works properly if SetPlayerColor has been used beforehand. (wiki)
pawn Код:
public OnPlayerText(playerid, text[])
{
    new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    new string[128];
    //other scripts here
    if(!PlayerInfo[playerid][pMuted])
    {
        format(string, sizeof(string), "[%d]{%h}%s: {FFFFFF}%s", playerid, GetPlayerColor(playerid) >>> 8, name, text);
        SendClientMessageToAll(-1,string);
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "[MUTE] - You can't talk while you're muted!");
        return 0;
    }
    return 0; // Return 0 at the end as well to prevent the default chat from being sent
}
source
Reply
#3

"GetPlayerColor will return nothing unless SetPlayerColor has been used!"
https://sampwiki.blast.hk/wiki/GetPlayerColor
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)