03.12.2018, 19:03
PHP Code:
if(dialogid == sua_dialog):
{
if(response)
{
if(strlen(inputtext) != strlen("FFFFFF") || isnull(inputtext) || !isValidHexCode(inputtext))
return SendClientMessage(playerid, 0xff0000ff, "* Vocк precisa digitar um cуdigo hex vбlido!");
String[0] = EOS;
format(String, sizeof(String), "0x%sFF", inputtext), SetPlayerColor(playerid, HexToInt(String));
return SendClientMessage(playerid, HexToInt(String), "Vocк setou sua cor!");
}
return true;
}
PHP Code:
stock isValidHexCode(code[])
{
new checked;
for(new i; i < strlen(code); i++)
{
if(code[i] >= '0' && code[i] <= '9')
checked+=1;
else if((code[i] == 'A' || code[i] == 'a') || (code[i] == 'B' || code[i] == 'b') || (code[i] == 'C' || code[i] == 'c') || (code[i] == 'D' || code[i] == 'd') || (code[i] == 'E' || code[i] == 'e') || (code[i] == 'F' || code[i] == 'f'))
checked+=1;
}
if(checked == 6)
return true;
return false;
}
PHP Code:
stock HexToInt(string[])
{
if(!string[0]) return 0;
new cur = 1, res = 0;
for(new i = strlen(string); i > 0; i--)
{
res += cur * (string[i - 1] - ((string[i - 1] < 58) ? (48) : (55)));
cur = cur * 16;
}
return res;
}