Storing nametag colors in a database, always shows black -
justjamie - 27.07.2016
Title.
0xCC3300FF = the nametag color in the database
How i load the color:
PHP код:
new nametag[80];
cache_get_field_content(0, "Nametag", nametag);
myStrcpy(Player[playerid][Nametag], nametag);
SetPlayerColor(playerid, Player[playerid][Nametag]);
(if i use -1, it shows up as white, but any other color code it just shows black.
What's the problem here?
Re: Storing nametag colors in a database, always shows black -
K0P - 27.07.2016
Show the code where you save them
And try this:
Код:
new nametag;
cache_get_field_content(i, "Nametag", nametag);
Player[playerid][Nametag] = nametag;
Re: Storing nametag colors in a database, always shows black -
justjamie - 27.07.2016
Quote:
Originally Posted by K0P
Show the code where you save them
And try this:
new nametag;
cache_get_field_content(i, "Nametag", nametag);
myStrcpy(Player[playerid][Nametag], nametag);
|
i don't save it, for testing purposes i manually added them inside the mysql database.
When i remove the [80], it shows:
argument type mismatch
Re: Storing nametag colors in a database, always shows black -
K0P - 27.07.2016
Quote:
Originally Posted by justjamie
i don't save it, for testing purposes i manually added them inside the mysql database.
When i remove the [80], it shows:
argument type mismatch
|
Save the color in int form (not string),and use the code i told you
Color also works in int form.
Here is a command to show player color in int forum.
Код:
CMD:color(playerid, params[])
{
new str[50];
format(str, sizeof(str), "%d", GetPlayerColor(playerid));
SendClientMessage(playerid, 0xFFFFFFFF, str);
return 1;
}
Re: Storing nametag colors in a database, always shows black -
justjamie - 27.07.2016
Quote:
Originally Posted by K0P
Save the color in int form (not string),and use the code i told you
Color also works in int form.
Here is a command to show player color in int forum.
Код:
CMD:color(playerid, params[])
{
new str[50];
format(str, sizeof(str), "%d", GetPlayerColor(playerid));
SendClientMessage(playerid, 0xFFFFFFFF, str);
return 1;
}
|
INT is only numbers, correct?
F is not a number.
When i do:
PHP код:
new str[50];
format(str, sizeof(str), "%s", Player[playerid][Nametag);
SendClientMessage(playerid, -1, str);'
Then it does correctly show as the color code.
Re: Storing nametag colors in a database, always shows black -
K0P - 27.07.2016
Use this to show the code in numbers,save that number in mysql database,load it as color
PHP код:
new str[50];
format(str, sizeof(str), "%d", Player[playerid][Nametag]);
SendClientMessage(playerid, -1, str);'
Код:
The code will be shown in form of numbers
Re: Storing nametag colors in a database, always shows black -
Threshold - 27.07.2016
There are a number of things to note here:
Hexadecimal notation and decimal notation are both considered integers, so yes, hex codes are considered integers. (
https://sampwiki.blast.hk/wiki/Hexadecimal_number_system)
GetPlayerColor will return 0 unless SetPlayerColor has been used prior. (
https://sampwiki.blast.hk/wiki/GetPlayerColor)
Have you tried debugging to see what 'cache_get_field_content_int(0, "Nametag")' actually gives you? Also make sure you're not still trying to access a string instead of an integer and saving it to an appropriate variable.
Re: Storing nametag colors in a database, always shows black -
Threshold - 27.07.2016
0xFF0000FF = 4278190335
Yes... you can store it in an INT database. 'FF' IS a value.
Re: Storing nametag colors in a database, always shows black -
justjamie - 27.07.2016
Quote:
Originally Posted by Threshold
0xFF0000FF = 4278190335
Yes... you can store it in an INT database. 'FF' IS a value.
|
how did you get 4278190335 ?
edit;
with 4278190335, its still black
Re: Storing nametag colors in a database, always shows black -
Threshold - 27.07.2016
Can you show where you're using this color?