enum TowerEnum{
t_owner[MAX_PLAYER_NAME],
t_range,
Text3D:t_text,
Float:t_x,
Float:t_y,
Float:t_z,
Float:t_rx,
Float:t_ry,
Float:t_rz,
t_model,
t_id
}
new tInfo[MAX_TOWER][TowerEnum];
mysql_function_query(dbhandle, query, true, "OnTowerLoad", "");
format(query, sizeof(query), "SELECT * FROM towers");
public OnTowerLoad(limit)
{
new count, rows, fields;
cache_get_data(rows, fields);
for(new i; i < rows; i++)
{
for(new h; h < sizeof(tInfo); h++)
{
if(tInfo[h][t_id] == 0)
{
cache_get_field_content(i, "owner", tInfo[h][t_owner], dbhandle);
tInfo[h][t_range] = cache_get_field_content_int(i, "t_range", dbhandle);
tInfo[h][t_model] = cache_get_field_content_int(i, "t_model", dbhandle);
tInfo[h][t_x] = cache_get_field_content_float(i, "t_x", dbhandle);
tInfo[h][t_y] = cache_get_field_content_float(i, "t_y", dbhandle);
tInfo[h][t_z] = cache_get_field_content_float(i, "t_z", dbhandle);
new string[126];
format(string,sizeof(string),"%i,%f,%f,%f",tInfo[h][t_model], tInfo[h][t_x], tInfo[h][t_y], tInfo[h][t_z]);
SendClientMessageToAll(-1,string);
CreateDynamicObject(tInfo[h][t_model], tInfo[h][t_x], tInfo[h][t_y], tInfo[h][t_z], 0.0, 0.0, 0.0,200,300);
count++;
break;
}
}
}
printf("Current objects on the server: %d",CountDynamicObjects());
return 1;
}
is it gaves u some errors or it doesnt createobjects?
and what does printf("Current objects on the server: %d",CountDynamicObjects()); says? |
for(new h; h < sizeof(tInfo); h++)
{
if(tInfo[h][t_id] == 0)
{
// this goes on top, it checks if the data in database is not more than the declared array size, if so we only load till the limit
if (rows > MAX_TOWER) {
rows = MAX_TOWER;
}
for(new i; i < rows; i++) {
tInfo[i][···] = cache_get_field_content_int(i, ...);
}
mysql_function_query(dbhandle, query, true, "OnTowerLoad", "");
format(query, sizeof(query), "SELECT * FROM towers"); //This line should be in top of mysql otherwise it will not get the correct thing what you want to do