sscanf (set hex color)
#1

How to use sscanf to set hex color? I tried this but it doesn't work. (Server Unknown Command)

pawn Код:
dcmd_setcolor(playerid, params[]){
new giveplayerid;
new colorid;
if(!IsPlayerAdmin(playerid)){
SendClientMessage(playerid, COLOR_WHITE, "*[INFO]: Tik RCON Administratoriams!");
return 1;
}
if(sscanf(params, "dh",giveplayerid,colorid)){
return SetcolorUsage(playerid);
}
if(giveplayerid < 0 || giveplayerid > 200) return WrongPlayerID(playerid);
if(!IsPlayerConnected(giveplayerid)) return WrongPlayerID(playerid);
SetPlayerColor(playerid,colorid);
return 1;
}
Reply
#2

Noone can help?
Reply
#3

Try to use x instead of h (although h should work, according to the thread). You're using the plugin, I assume?
Reply
#4

You should really indent your code lol.

Код:
dcmd_setcolor(playerid, params[])
{
    new giveplayerid;
    new colorid;
    if(!IsPlayerAdmin(playerid)) {
        SendClientMessage(playerid, COLOR_WHITE, "*[INFO]: Tik RCON Administratoriams!");
        return 1;
    }
    if(sscanf(params, "dh",giveplayerid,colorid)) {
        return SetcolorUsage(playerid);
    }
    if(giveplayerid < 0 || giveplayerid > 200) return WrongPlayerID(playerid);
    if(!IsPlayerConnected(giveplayerid)) return WrongPlayerID(playerid);
    SetPlayerColor(playerid,colorid);
    return 1;
}
First off, you should be using the 'u' specifier for players (this allows you to type in their name, part of their name, or even physical id). Second, why are you even checking for this other player if your not using his ID for anything in your script? You're basically checking if the specified player is connecting, then completely blowing him off, and just setting the player who typed the command's color lol.

Ignoring that, if you're recieving a "server unkown command" error, its likely that one of your functions return 0, or that your dcmd line under OnPlayerCommandText is messed up. Can we see your two custom functions, and your dcmd line?


Btw this might be of use to you:

Код:
stock RGBAToHex(r, g, b, a) 
{
    return (r<<24 | g<<16 | b<<8 | a);
}
It does exactly as it name says, converts RGBA to hexadecimal. This is a LOT more user friendly then having to type in a hex color lol.
Reply
#5

I don't understand how to use it. I want players to set their colors using these color codes (http://www.ufrik.com/wp-content/uplo...hex_colors.jpg)
Reply
#6

I foun website with RGB codes so i will use your RGBA converter. Thank you Kyosaur for help.
Reply
#7

Quote:
Originally Posted by BuLLeT[LTU]
Посмотреть сообщение
I foun website with RGB codes so i will use your RGBA converter. Thank you Kyosaur for help.
Np. It was made by betamaster, not by myself btw :P.


Tell me if you have any more problems.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)