nick color change -
fireboy - 23.03.2013
hey, i need a help with my created command, that changes nick color, but when i type /tcolor 0xcc3333 (it's red) or whatever other hex color, it's sets to black.
pawn Код:
if(strcmp("/tcolor", cmdtext, true, 6) == 0)
{
new coco[50];
coco=strtok(cmdtext, idx);
if (!strlen (coco))
{
SendClientMessage(playerid, 0xE6000055, "USE: /tcolour [COLOR(Example. 0xFFFF00AA]"); // Translated it to english :d
}
else
{
SetPlayerColor(playerid,strval(coco));
}
}
return 1;
}
so if you can help me, then please answer, i will appreciate it.
Re: nick color change -
Misiur - 23.03.2013
Pass alpha channel too (0xcc3333FF), or use
pawn Код:
SetPlayerColor(playerid, (akna << 8) | 0x000000FF)
Re: nick color change -
fireboy - 23.03.2013
doesn't help, black anyway.
AW: nick color change -
Nero_3D - 23.03.2013
strval only returns integers from a string, you need to use sscanf or some custom code
pawn Код:
//
if(strcmp("/tcolor", cmdtext, true, 7) == 0) {
static const
sUsage[] = "USE: /tcolour [COLOR(Example. 0xFFFF00AA]"
;
if(cmdtext[7] == EOS) {
return SendClientMessage(playerid, 0xE6000055, sUsage);
}
if(cmdtext[7] == ' ') {
if(sscanf(cmdtext[8], "x", cmdtext)) {
return SendClientMessage(playerid, 0xE6000055, sUsage);
}
return SetPlayerColor(playerid, cmdtext[0]);
}
}
Also switch to y_cmd or zcmd
Edit: There was a mistake, thanks to Vince \/
Re: nick color change -
Vince - 23.03.2013
The specifier is "x", not "f".
Re: AW: nick color change -
fireboy - 24.03.2013
Quote:
Originally Posted by Nero_3D
strval only returns integers from a string, you need to use sscanf or some custom code
pawn Код:
// if(strcmp("/tcolor", cmdtext, true, 7) == 0) { static const sUsage[] = "USE: /tcolour [COLOR(Example. 0xFFFF00AA]" ; if(cmdtext[7] == EOS) { return SendClientMessage(playerid, 0xE6000055, sUsage); } if(cmdtext[7] == ' ') { if(sscanf(cmdtext[8], "x", cmdtext)) { return SendClientMessage(playerid, 0xE6000055, sUsage); } return SetPlayerColor(playerid, cmdtext[0]); } }
Also switch to y_cmd or zcmd
Edit: There was a mistake, thanks to Vince \/
|
command not working, when i type /tcolor, it sends me Example:/tcolor [color], but when i /tcolor 0xcc3333FF, it sends me SERVER:UNKNOWN COMMAND. :/
AW: Re: AW: nick color change -
Nero_3D - 24.03.2013
Quote:
Originally Posted by fireboy
command not working, when i type /tcolor, it sends me Example:/tcolor [color], but when i /tcolor 0xcc3333FF, it sends me SERVER:UNKNOWN COMMAND. :/
|
Once again I tested it and it works flawless, it would be easier if you would use zcmd or y_cmd
Also what happens if you type "/tcolor " (with a space behind it), should return the message
If that doesnt happen than their is something wrong with your sscanf, do you even have it ?