CMD:c(playerid, params[]) {
if(playerVariables[playerid][pClan] < 1)
return SendClientMessage(playerid, COLOR_GREY, "Your clan data is invalid.");
if(isnull(params))
return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/c [message]");
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
switch(playerVariables[playerid][pClanRank])
{
case 1: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName1], szPlayerName, params);
case 2: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName2], szPlayerName, params);
case 3: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName3], szPlayerName, params);
case 4: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName4], szPlayerName, params);
case 5: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName5], szPlayerName, params);
case 6: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName6], szPlayerName, params);
case 7: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName7], szPlayerName, params);
default: format(szMessage, sizeof(szMessage), "{%s}[CLAN] %s %s: %s",clanVariables[playerVariables[playerid][pClan]][cClanColor], clanVariables[playerVariables[playerid][pClan]][cClanRankName1], szPlayerName, params);
}
SendToClan(playerVariables[playerid][pClan], COLOR_WHITE, szMessage);
return 1;
}
SendToClan(playerVariables[playerid][pClan], clanVariables[playerVariables[playerid][pClan]][cClanColor], szMessage);
sscanf(color_hex, "x", color_int);
|
Don't. Just save the color as an integer, as that's what they are after all. You can do this with sscanf.
pawn Код:
|
new color[24];
format(color,24, "0x%s",clanVariables[playerVariables[playerid][pClan]][cClanColor]);
|
Use format.
Example: PHP код:
|
new color_hex[11] = "0xFFFFFFFF", color_int;
sscanf(color_hex, "x", color_int);
|
What don't you understand? Colors are integers, not strings. You can use the sscanf plugin to convert a hexadecimal color to an integer. And use that integer instead of that string.
You can download sscanf at https://sampforum.blast.hk/showthread.php?tid=570927. To convert a color into a string, do: pawn Код:
|
|
But my color is not a HEX number. Its in this form, "XXXXXX" so "FFFFFF". Would that work the same?
|
stock HexToInt(hex[])
{
new int;
sscanf(hex, "x", int);
return int;
}
SendToClan(playerVariables[playerid][pClan], HexToInt(clanVariables[playerVariables[playerid][pClan]][cClanColor]), szMessage);
|
Colors AREN'T hexs, they are integers when the script is compiled. Just convert the hexadecimal value with the following function if you're having this much trouble, then:
pawn Код:
pawn Код:
|