Error while using cache_get_content_field -
blaudroid - 20.09.2016
So hello there, i have a problem with my script i can't get it working.
I want to store a value from my database "COLOR_WHITE" into pInfo[playerid][namecolor] but. When i store it i recieve no errors but it's still not working, i made a test string with SendClientMessage and it print's to me only letter "C" and the name is then converted to black, as the variable is not defined and doesn't exist in my color list as "C". The mysql colomn is "namecolor" set to TEXT as type. I tried varchar(250) too, nothing happens.
This is were the variable is set when user log in:
PHP код:
new dest[256];
cache_get_field_content(0,"namecolor",dest);
//cache_get_field_content(0,"namecolor",pInfo[playerid][namecolor],dbhandle,128); //i tried this too and same.
format(pInfo[playerid][namecolor], sizeof(dest), dest);
Here is when user uses command to change color: (still in test purposes)
PHP код:
CMD:color(playerid, params[])
{
new color = pInfo[playerid][namecolor];
SetPlayerColor(playerid, pInfo[playerid][namecolor]);
new string[128];
format(string, sizeof(string), "Color: %s", color);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}
I have no idea how to resolve this..
Re: Error while using cache_get_content_field -
Konstantinos - 20.09.2016
Save and load the color as integer.
pInfo[playerid][namecolor] should be declared as integer as well.
Retrieve it with
cache_get_field_content_int function.
pawn Код:
format(string, sizeof(string), "Color: %06x", pInfo[playerid][namecolor] >>> 8);
Re: Error while using cache_get_content_field -
blaudroid - 20.09.2016
Quote:
Originally Posted by Konstantinos
Save and load the color as integer.
pInfo[playerid][namecolor] should be declared as integer as well.
Retrieve it with cache_get_field_content_int function.
pawn Код:
format(string, sizeof(string), "Color: %06x", pInfo[playerid][namecolor] >>> 8);
|
Ok but what if i want to print something else from the database, this method with cache_get_field_content won't work either... For example what if i have some logs and i want to print them into a dialog, this will not work with integer for those thoo.
Re: Error while using cache_get_content_field -
Konstantinos - 20.09.2016
cache_get_field_content works just fine to retrieve the data as string, it is probably something wrong with what you have done.
Keep in mind that if you don't select
that column in a SELECT query and then trying to retrieve
that column won't work. Unless you post the mysql_log.txt, I can't say for sure what is wrong.
Re: Error while using cache_get_content_field -
blaudroid - 21.09.2016
Quote:
Originally Posted by Konstantinos
cache_get_field_content works just fine to retrieve the data as string, it is probably something wrong with what you have done.
Keep in mind that if you don't select that column in a SELECT query and then trying to retrieve that column won't work. Unless you post the mysql_log.txt, I can't say for sure what is wrong.
|
Ah that's why is not working, i am always using SELECT... what should i use instead?
Re: Error while using cache_get_content_field -
Konstantinos - 21.09.2016
That is really depends on what you want to select (which columns). An example of what I meant in my previous post:
Код:
SELECT column1 FROM table LIMIT 1;
and then retrieving it like:
Код:
cache_get_field_content(0, "column2", dest);
dest will be empty because there is no data selected for
column2, what we selected were the data for
column1.