nick color change
#1

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.
Reply
#2

Pass alpha channel too (0xcc3333FF), or use
pawn Код:
SetPlayerColor(playerid, (akna << 8) | 0x000000FF)
Reply
#3

doesn't help, black anyway.
Reply
#4

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 \/
Reply
#5

The specifier is "x", not "f".
Reply
#6

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. :/
Reply
#7

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 ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)