Storing nametag colors in a database, always shows black
#1

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(playeridPlayer[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?
Reply
#2

Show the code where you save them
And try this:
Код:
new nametag; 
cache_get_field_content(i, "Nametag", nametag); 
Player[playerid][Nametag] = nametag;
Reply
#3

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

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;
}
Reply
#5

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(strsizeof(str), "%s"Player[playerid][Nametag);
    
SendClientMessage(playerid, -1str);
Then it does correctly show as the color code.
Reply
#6

Use this to show the code in numbers,save that number in mysql database,load it as color

PHP код:
    new str[50];
    
format(strsizeof(str), "%d"Player[playerid][Nametag]);
    
SendClientMessage(playerid, -1str);
Код:
The code will be shown in form of numbers
Reply
#7

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

0xFF0000FF = 4278190335

Yes... you can store it in an INT database. 'FF' IS a value.
Reply
#9

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

Can you show where you're using this color?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)