SA-MP Forums Archive
Loading color from SQL, Showing as black in game - 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: Loading color from SQL, Showing as black in game (/showthread.php?tid=478977)



Loading color from SQL, Showing as black in game - Shockey HD - 02.12.2013

Im trying to load a SetPlayerColor, Color from SQL.


Everytime it loads, it comes out black.


pawn Код:
new string[128];
                    format(string, sizeof(string), "TEAM COLOR CHANGED TO %s",tData[1][tColor]);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    SetPlayerColor(playerid, tData[1][tColor]);
Loading color

pawn Код:
mysql_fetch_field_row(tData[i][tColor],"tColor");

and it loads perfectly fine in the console


Код:
[01:14:36] Team Loaded:  (1) Los Santos Militia - 0x2E8B57AA
[01:14:36] Team Loaded:  (2) Los Santos Police Department - 0x0000BBAA
[01:14:36] Team Loaded:  (3) Bad Boys Society - 0x9370DBFF
[01:14:36] Team Loaded:  (4) Market Bloc'C Crips - 0x4682B4FF
[01:14:36] Team Loaded:  (5) Los Santos Vagos - 0xFFFF00FF



Re: Loading color from SQL, Showing as black in game - Kyosaur - 02.12.2013

You're using the "%s" specifier and mysql_fetch_field_row... that means you are storing these colors as strings? You should store them as integers instead (because that's what they are, and that's what SetPlayerColor wants). I don't know why you are even displaying the hex information in the messages either, tbh; you should just display "Team Loaded: (1) Los Santos Militia" in the corresponding color :P.


Re: Loading color from SQL, Showing as black in game - Shockey HD - 05.12.2013

Those Team Loaded messages are from Console.


And I did this -

pawn Код:
mysql_fetch_field_row(savingstring,"tColor"); tData[i][tColor] = strval(savingstring);
Removing it from being a string variable, now colors wont even load in console.


Re: Loading color from SQL, Showing as black in game - Kyosaur - 05.12.2013

Quote:
Originally Posted by Shockey HD
Посмотреть сообщение
Those Team Loaded messages are from Console.


And I did this -

pawn Код:
mysql_fetch_field_row(savingstring,"tColor"); tData[i][tColor] = strval(savingstring);
Removing it from being a string variable, now colors wont even load in console.
Did you update the DB, so that the colors are stored as integers too? If not, strval would likely just return 0, and that might be your issue.