SA-MP Forums Archive
MySQL Loading value problem - 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)
+--- Thread: MySQL Loading value problem (/showthread.php?tid=522547)



MySQL Loading value problem - Affan - 28.06.2014

pawn Код:
cache_get_field_content(0, "RGB", mHolder, cHandle);
format(string, sizeof(string),"%d", mHolder);
SetPlayerColor(playerid, string);
Error:
pawn Код:
error 035: argument type mismatch (argument 2) // This error is on SetPlayerColor
I'm using /color <0-255> <0-255> <0-255>
The "color" is the value which is set as the player's name color. It saves correctly, but I can't manage to load it because of the error.
pawn Код:
new Query[300];
format(Query, sizeof(Query), "UPDATE `users` SET `RGB` = '%d' WHERE `Name` = '%s'", color, GetName(playerid));
mysql_function_query(cHandle, Query, false, "", "d", playerid);



Re: MySQL Loading value problem - Jack_Leslie - 28.06.2014

Try something like:
pawn Код:
new rbg;
rbg = cache_get_field_content(0, "RGB", mHolder, cHandle);
Then use rbg, instead of string.


Re: MySQL Loading value problem - Raefal - 28.06.2014

Try this

Код:
new Query[300];
format(Query, sizeof(Query), "UPDATE `users` SET `RGB` = '%d' WHERE `Name` = '%s'", color, GetName(playerid));
mysql_function_query(cHandle, Query, false, "", "");



Re: MySQL Loading value problem - Affan - 28.06.2014

Quote:
Originally Posted by Raefal
Посмотреть сообщение
Try this

Код:
new Query[300];
format(Query, sizeof(Query), "UPDATE `users` SET `RGB` = '%d' WHERE `Name` = '%s'", color, GetName(playerid));
mysql_function_query(cHandle, Query, false, "", "");
It saves correctly, just it doesn't load.

@Jack_Leslie: It sets the color to BLACK.

Also anyone know how to fix this?
I use /color and it doesn't show on the map, is it because of RGB?


Re: MySQL Loading value problem - Emmet_ - 28.06.2014

This is because "SetPlayerColor" takes an integer or a hexadecimal parameter, using "string" is incorrect in this case.

pawn Код:
cache_get_field_content(0, "RGB", mHolder, cHandle);
SetPlayerColor(playerid, strval(mHolder));



Re: MySQL Loading value problem - AiRaLoKa - 28.06.2014

you should use RGBA not RGB. thats why you color doesnt showed in the map.
try to use it. (credits going to vince)
pawn Код:
//
    new color;

    if(sscanf(params, "x", color)) return SendClientMessage(playerid, -1, "[USAGE]: /color [color(i.e: FFFF00)]");

    color <<= 8;
    color |= 0xFF;
inside the command


Re: MySQL Loading value problem - Affan - 28.06.2014

Quote:
Originally Posted by AiRaLoKa
Посмотреть сообщение
you should use RGBA not RGB. thats why you color doesnt showed in the map.
try to use it. (credits going to vince)
pawn Код:
//
    new color;

    if(sscanf(params, "x", color)) return SendClientMessage(playerid, -1, "[USAGE]: /color [color(i.e: FFFF00)]");

    color <<= 8;
    color |= 0xFF;
inside the command
But I want to use RGB and show colors on the map.

@Emmet_: Thanks, I'll try that.


Re: MySQL Loading value problem - AiRaLoKa - 28.06.2014

yeah it's rgb. thats whats these line used for

pawn Код:
color <<= 8; //shifting to left for the transparency
color |= 0xFF;//adding the transparency



Re: MySQL Loading value problem - Affan - 28.06.2014

Quote:
Originally Posted by AiRaLoKa
Посмотреть сообщение
yeah it's rgb. thats whats these line used for

pawn Код:
color <<= 8; //shifting to left for the transparency
color |= 0xFF;//adding the transparency
It's currently like this
pawn Код:
CMD:color(playerid, params[])
{
    new color;
    static R, G, B;
    if(sscanf(params, "iii", R,G,B)) return SendClientMessage(playerid, -1, ""RED"USAGE: "WHITE"/color <0-255> <0-255> <0-255>");
    if(R > 255 || R < 0) return SendClientMessage(playerid, -1, ""RED"[COLOR] "WHITE"Invalid value!");
    if(G > 255 || G < 0) return SendClientMessage(playerid, -1, ""RED"[COLOR] "WHITE"Invalid value!");
    if(B > 255 || B < 0) return SendClientMessage(playerid, -1, ""RED"[COLOR] "WHITE"Invalid value!");
    SendClientMessageEx(playerid,(R * 16777216) + (G * 65536) + (B*256), "You have changed your name color to RGB <%d> <%d> <%d>", R , G , B);
    color = (R * 16777216) + (G * 65536) + (B*256);
    SendClientMessageEx(playerid, -1, "%d", color);
    SetPlayerColor(playerid, color);
    new Query[300];
    format(Query, sizeof(Query), "UPDATE `users` SET `RGB` = '%d' WHERE `Name` = '%s'", color, GetName(playerid));
    mysql_function_query(cHandle, Query, false, "", "d", playerid);
    return 1;
}
So what do I add there?


Re: MySQL Loading value problem - Jack_Leslie - 28.06.2014

Quote:
Originally Posted by Affan
Посмотреть сообщение
It saves correctly, just it doesn't load.

@Jack_Leslie: It sets the color to BLACK.

Also anyone know how to fix this?
I use /color and it doesn't show on the map, is it because of RGB?
I didn't say anything about black, or what color it sets it to, I said not to use a string, use a strval instead, like Emmet, except my method was different. Just pointing that out.