PDA

View Full Version : Help with MySQL loading (cache)


PaulDinam
24/01/2013, 07:46 AM
I made 3dtext label system.. but when it loads.. it creates only 1 text draw from the first row, the rest no...

public LoadDynamicLabels()
{
new rows, fields, Float:posx, Float:posy, Float:posz, LabelInfo[256], tt[256];
new total = 0;
cache_get_data(rows, fields);
if(rows)
{
while(total < rows)
{
new temp[12];
cache_get_row(0, 1, temp), posx = floatstr(temp);
cache_get_row(0, 2, temp), posy = floatstr(temp);
cache_get_row(0, 3, temp), posz = floatstr(temp);
cache_get_row(0, 4, LabelInfo);
CreateDynamic3DTextLabel(LabelInfo, COLOR_WHITE, posx, posy, posz, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
total++;
}
}
format(tt,sizeof(tt), "Loaded %d labels from MySQL.", total);
printf(tt);
return 1;
}

coakiddo
24/01/2013, 07:52 AM
public LoadDynamicLabels()
{
new rows, fields, Float:posx, Float:posy, Float:posz, LabelInfo[256], tt[256];
new total = 0;
cache_get_data(rows, fields);
if(rows)
{
for(new i = 0; i < rows+1; i++)
{
new temp[12];
cache_get_row(i, 1, temp), posx = floatstr(temp);
cache_get_row(i, 2, temp), posy = floatstr(temp);
cache_get_row(i, 3, temp), posz = floatstr(temp);
cache_get_row(i, 4, LabelInfo);
CreateDynamic3DTextLabel(LabelInfo, COLOR_WHITE, posx, posy, posz, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
total++;
}
}
format(tt,sizeof(tt), "Loaded %d labels from MySQL.", total);
printf(tt);
return 1;
}
This should work.

PaulDinam
24/01/2013, 07:59 AM
Yep :)

thanks, haven't seen this 0 lol..
so the "i" means row number right?

coakiddo
24/01/2013, 08:01 AM
Yes. I'm glad that it works.