Dynamic labels refuses to load -
BizzyD - 18.11.2013
Hello, got a problem with dynamic labels that I made. They refuse to load, I can create them just fine.
They save in the database fine, but wont load.
This feature is called on OnGameModeInit:
Code:
AddLabelsFromFile();
And this is the stock.
Code:
stock AddLabelsFromFile()
{
new
LabelInfo[128],
Float:LX,
Float:LY,
Float:LZ,
lTotal;
new Query[150];
format(Query, sizeof(Query), "SELECT * FROM `labels`");
new rows, fields;
cache_get_data(rows, fields, conn);
if(rows)
{
CreateDynamic3DTextLabel(LabelInfo, RColors[random(sizeof(RColors))], LX, LY, LZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
lTotal++;
}
mysql_free_result();
printf("** %i\t<->\tLabels Loaded From\t<->\tMySQL\t\t **", lTotal);
return 1;
}
Any help is appreciated.
Thanks
Re: Dynamic labels refuses to load -
BizzyD - 18.11.2013
New stock:
Code:
stock AddLabelsFromFile()
{
new
LabelInfo[128],
Float:LX,
Float:LY,
Float:LZ,
lTotal;
new Query[150];
format(Query, sizeof(Query), "SELECT * FROM `labels`");
new rows, fields;
cache_get_data(rows, fields, conn);
if(rows)
{
cache_get_field_content_float(0, "LabelX", conn);
cache_get_field_content_float(0, "LabelY", conn);
cache_get_field_content_float(0, "LabelZ", conn);
new Field[128];
cache_get_field_content(0, "LabelInfo", Field, conn, sizeof(Field));
CreateDynamic3DTextLabel(LabelInfo, RColors[random(sizeof(RColors))], LX, LY, LZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, TEXTLABELDISTANCE);
lTotal++;
}
mysql_free_result();
printf("** %i\t<->\tLabels Loaded From\t<->\tMySQL\t\t **", lTotal);
return 1;
}
Still dont work
EDIT: Changed
Code:
cache_get_field_content(0, "LabelInfo", Field, conn, sizeof(Field));
to:
Code:
cache_get_field_content(0, "LabelInfo", Field, conn, sizeof(Field), sizeof(Field), "%s", Field);
Gives me 3 warnings:
Code:
warning 202: number of arguments does not match definition x3
Respuesta: Dynamic labels refuses to load -
Jejox - 18.11.2013
You missed changing some variables I
Re: Dynamic labels refuses to load -
Konstantinos - 18.11.2013
This is not how cache is used with the MySQL plugin. Read this tutorial:
https://sampforum.blast.hk/showthread.php?tid=337810
You execute the query - something you don't do and then in a separate public function, you get the rows and the fields. If there are rows, then load and assign them.