Need Help With GetPlayerColor
#1

Hello i was making a command and i need help with this :
Код:
COMMAND:hackclanleader(playerid, params)
{
    if(hackb[playerid] == true)
    {
        if(hackel[playerid] == true)
	{
		hackel[playerid] = false;
		hackl[playerid] = Create3DTextLabel(".:HACK CLAN LEADER:.", 0x2EFF83FF, 30.0, 40.0, 50.0, 40.0, 0);
		Attach3DTextLabelToPlayer(hackl[playerid], playerid, 0.0, 0.0, 0.7);
		TextDrawShowForPlayer(playerid, hack);
        	SendClientMessage(playerid, 0x2EFF83FF, "[HACK] {FFFFFF}Welcome Leader");
		new name[MAX_PLAYER_NAME+1], string[50+MAX_PLAYER_NAME+1];
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "[HACK] {FFFFFF}OMG Leader %s is Here :O.", name);
		SendClientMessageToAll(0x2EFF83FF, string);
                new output[144];
		format(output, sizeof(output), "0x%06x", GetPlayerColor(playerid) >>> 8);
		}
		else if(hackel[playerid] == false)
		{
		    hackel[playerid] = true;
		    Delete3DTextLabel(hackl[playerid]);
		    SetPlayerColor(playerid, output);
		    TextDrawHideForPlayer(playerid, hack);
        	    SendClientMessage(playerid, 0x2EFF83FF, "[HACK] {FFFFFF}GoodBye Leader");
		    new name[MAX_PLAYER_NAME+1], string[50+MAX_PLAYER_NAME+1];
		    GetPlayerName(playerid, name, sizeof(name));
		    format(string, sizeof(string), "[HACK] {FFFFFF}OMG Leader %s is Gone :O.", name);
		    SendClientMessageToAll(0x2EFF83FF, string);
		}
	}
	else SendClientMessage(playerid, 0x2EFF83FF, "[HACK] {FFFFFF}You are not HACK CLAN LEADER!");
	return 1;
}
How can i put output as color to this line
Код:
SetPlayerColor(playerid, output);
Reply
#2

You try to store the player's colour as hex (with alpha equal to 0) in a string and then set that color (which is already set) but the 2nd argument must be integer, not a string. Except the fact that I find that pointless unless you wanted to do something else, you can use sscanf.
Reply
#3

can you give example how can i do this with sscanf
Reply
#4

Okay, but read my post again. You try to set the color as hex by retrieving the colour which returns a readable number. Hex is a number as well so it's like you do this:
pawn Код:
SetPlayerColor(playerid, GetPlayerColor(playerid));
which I don't see any reason for it.

With sscanf, you can use "x" specifier.
pawn Код:
new
    colour;

sscanf("0x00FF00FF", "x", colour); // the first argument can be a string you declared.
Reply
#5

I didnt get this can you explain me more ? And i want to store in my first type /hackclanleader
and i want use when i type /hackclanleader back
Reply
#6

All you want is to store the color the first time and the next to set that saved color?

pawn Код:
// global:
static
    Player_Colour[MAX_PLAYERS];

COMMAND:hackclanleader(playerid, params)
{
    if(hackb[playerid] == true)
    {
        if(hackel[playerid] == true)
        {
            hackel[playerid] = false;
            hackl[playerid] = Create3DTextLabel(".:HACK CLAN LEADER:.", 0x2EFF83FF, 30.0, 40.0, 50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(hackl[playerid], playerid, 0.0, 0.0, 0.7);
            TextDrawShowForPlayer(playerid, hack);
            SendClientMessage(playerid, 0x2EFF83FF, "[HACK] {FFFFFF}Welcome Leader");
            new name[MAX_PLAYER_NAME+1], string[50+MAX_PLAYER_NAME+1];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "[HACK] {FFFFFF}OMG Leader %s is Here :O.", name);
            SendClientMessageToAll(0x2EFF83FF, string);
            Player_Colour[playerid] = GetPlayerColor(playerid);
        }
        else if(hackel[playerid] == false)
        {
            hackel[playerid] = true;
            Delete3DTextLabel(hackl[playerid]);
            SetPlayerColor(playerid, Player_Colour[playerid]);
            TextDrawHideForPlayer(playerid, hack);
            SendClientMessage(playerid, 0x2EFF83FF, "[HACK] {FFFFFF}GoodBye Leader");
            new name[MAX_PLAYER_NAME+1], string[50+MAX_PLAYER_NAME+1];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "[HACK] {FFFFFF}OMG Leader %s is Gone :O.", name);
            SendClientMessageToAll(0x2EFF83FF, string);
        }
    }
    else SendClientMessage(playerid, 0x2EFF83FF, "[HACK] {FFFFFF}You are not HACK CLAN LEADER!");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)