PDA

View Full Version : Dynamic Label System [MYSQL || Problem]


zT KiNgKoNg
28/05/2013, 08:44 PM
Hey guys for some reason the dynamic lables are not showing up when the server loads, Its says and defined that there aren't any in the database when there's three, I don't know if this is a sscanf error or its just not loading correctly



enum DynamicLables {

DynamicLableID,
Float: DL_X,
Float: DL_Y,
Float: DL_Z,
DL_String[500]
};


new DL_Data[MAX_DYNAMIC_LABLES][DynamicLables];
new Text3D:DL_Set[MAX_DYNAMIC_LABLES];
new LableCount;


Loading

public CreateDynamicLables()
{
new LableID,FetchRow[300];

format(Query, sizeof(Query), "SELECT * FROM `dynamiclabels`");
mysql_query(Query);
mysql_store_result();
LableID = mysql_num_rows();
//DL_Data[LableID][]

if(LableID > 0)
{
while(mysql_fetch_row(FetchRow))
{
//DynamicLableID
sscanf(FetchRow, "p<|>dfffs[300]>", DL_Data[LableID]);
DL_Set[LableID] = CreateDynamic3DTextLabel(DL_Data[LableID][DL_String], 0xFFFFFF, DL_Data[LableID][DL_X], DL_Data[LableID][DL_Y], DL_Data[LableID][DL_Z], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
LableID++;
LableCount ++;
}
mysql_free_result();

} else {

print("No Dynamic Lables were created, Make some ingame");

}

return 1;
}

zT KiNgKoNg
29/05/2013, 04:26 PM
Really needed!

Konewka
29/05/2013, 05:11 PM
format(Query, sizeof(Query), "SELECT * FROM `dynamiclabels`");
mysql_query(Query);

format(FetchRow, sizeof(FetchRow), "SELECT * FROM `dynamiclabels`");
mysql_query(FetchRow);

zT KiNgKoNg
29/05/2013, 05:48 PM
Didn't work because i changed it to Query already!

GiamPy.
29/05/2013, 09:24 PM
First of all, I suggest you to switch over threaded callbacks and cached functions provided by BlueG MySQL plugin. The way you're making the script extremely inefficient.

Anyway, you're not loading the data at all.

sscanf(FetchRow, "p<|>dfffs[300]>", DL_Data[LableID]);

You are only loading the first "d" (integer) value in DL_Data[LableID] - also not properly.
The four remaining values are parsed properly but they are not loaded in each variable.

This way should make it work:

sscanf(FetchRow, "p<|>dfffs[300]>", DL_Data[LableID][DynamicLableID], DL_Data[LableID][DL_X], DL_Data[LableID][DL_Y], DL_Data[LableID][DL_String]);

Also, you've chosen to parse the string with an array of 300 instead of 500, as you defined in your enum. That doesn't make any sense. It's just better if you change both arrays to 128 which is the maximum length of a string.

zT KiNgKoNg
29/05/2013, 09:29 PM
Well thats funny, Because its still not loading the three dynamic lables in the database, And there is three in the database. So far nothing is working.

Updated Code (Pretty much the same way i load all the player data with e<>)

public CreateDynamicLables()
{
new LableID;

format(Query, sizeof(Query), "SELECT * FROM `dynamiclabels`");
mysql_query(Query);
mysql_store_result();
LableID = mysql_num_rows();
//DL_Data[LableID][]

if(LableID > 0)
{
while(mysql_fetch_row_format(Query,"|"))
{
//DynamicLableID
sscanf(Query, "e<p<|>dfffs[300]>", DL_Data[LableID]);
DL_Set[LableID] = CreateDynamic3DTextLabel(DL_Data[LableID][DL_String], 0xFFFFFF, DL_Data[LableID][DL_X], DL_Data[LableID][DL_Y], DL_Data[LableID][DL_Z], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
LableID++;
LableCount ++;
}
mysql_free_result();
printf("%i Dynamic Lables Created", LableCount);

} else {
printf("%i Dynamic Lables Created",0);
}
return 1;
}

Player Data

sscanf(Query, "e<p<|>is[100]s[100]s[100]s[100]fffdids[100]ididi>", pData[playerid]);

GiamPy.
29/05/2013, 09:34 PM
Could you please show me a screenshot of the table structure?
Also, can you please making a debug print of the variables:

DL_Data[LableID][DynamicLableID]
DL_Data[LableID][DL_X]
DL_Data[LableID][DL_Y]
DL_Data[LableID][DL_String]


.. into the while iteration?

zT KiNgKoNg
29/05/2013, 09:42 PM
Structure.
http://i41.tinypic.com/301k41s.jpg

And its not printing "Loading" in the while statement.

GiamPy.
29/05/2013, 09:52 PM
You're saying that the while iteration is never executed?

zT KiNgKoNg
29/05/2013, 09:55 PM
I am by the looks of it.

zT KiNgKoNg
30/05/2013, 06:49 PM
Still need help with this....