SA-MP Forums Archive
sscanf (set hex color) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: sscanf (set hex color) (/showthread.php?tid=177647)



sscanf (set hex color) - BuLLeT[LTU] - 18.09.2010

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;
}



Re: sscanf (set hex color) - BuLLeT[LTU] - 18.09.2010

Noone can help?


Re: sscanf (set hex color) - Vince - 18.09.2010

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


Re: sscanf (set hex color) - Kyosaur - 18.09.2010

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.


Re: sscanf (set hex color) - BuLLeT[LTU] - 19.09.2010

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)


Re: sscanf (set hex color) - BuLLeT[LTU] - 19.09.2010

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


Re: sscanf (set hex color) - Kyosaur - 19.09.2010

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.