MySQL Loading value problem
#1

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);
Reply
#2

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

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, "", "");
Reply
#4

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

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));
Reply
#6

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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)