SA-MP Forums Archive
Command to SetPlayerColor by Choice. - 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: Command to SetPlayerColor by Choice. (/showthread.php?tid=629827)



Command to SetPlayerColor by Choice. - verlaj - 04.03.2017

I tryed something like this but it gives me an error with SetPlayerColor. I do not posses the necessary knowledge with these Hex colors and stuff -_-

pawn Код:
COMMAND:groupcolor(playerid, params[])
{
    new i = group[playerid][gid];
        if(groupinfo[i][leader] == playerid)
    {
        new color[7];
        if(sscanf(params, "h", color) || strlen(params) != 6)
            SendClientMessage(playerid, -1, "{FF0000}Invalid hex color!");
        else
        {
            new msg[56];
            format(msg, sizeof(msg), "{%s}Your group color has been changed!", params);
            SendClientMessage(playerid, -1, msg);
            format(groupinfo[i][GroupColor], 7, "%s", params);
                        SetPlayerColor(playerid, group[i][GroupColor]); //HexToInt is not working either. And how do i deal with the transparency parameters ? Like if i wanna set 50 as default ?
        }
    }
    else
        SendClientMessage(playerid, -1, "{FF0000}You must be a group leader to use this command!");
    return 1;
}



Re: Command to SetPlayerColor by Choice. - Konstantinos - 04.03.2017

I would change GroupColor to an integer and then:
pawn Код:
groupinfo[i][GroupColor] = (color << 8) | 0x7F; // 0x7F is alpha
SetPlayerColor(playerid, group[i][GroupColor]);