MySql: Objects not loading
#1

here is my codes
PHP код:
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]; 
PHP код:
mysql_function_query(dbhandlequerytrue"OnTowerLoad""");
    
format(querysizeof(query), "SELECT * FROM towers"); 
PHP код:
public OnTowerLoad(limit)
{
    new 
countrowsfields;
    
cache_get_data(rowsfields);
    for(new 
irowsi++)
    {
        for(new 
hsizeof(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.00.00.0,200,300);
                
count++;
                break;
            }
        }
    }
    
printf("Current objects on the server: %d",CountDynamicObjects());
    return 
1;

Database:


its not getting data from the db
Reply
#2

is it gaves u some errors or it doesnt createobjects?
and what does printf("Current objects on the server: %d",CountDynamicObjects()); says?
Reply
#3

Quote:
Originally Posted by Mugalito
Посмотреть сообщение
is it gaves u some errors or it doesnt createobjects?
and what does printf("Current objects on the server: %d",CountDynamicObjects()); says?
CreateDynamicObject loading 1 but it not creating ingame
Reply
#4

are you sure its not getting data from database? use debugs and make sure that it's not loaded.
Reply
#5

Your query looks fine, it should load data.
But i don't know why do you have this?
PHP код:
for(new hsizeof(tInfo); h++) 
        { 
            if(
tInfo[h][t_id] == 0
            { 
You are looping through whole array which is probably empty i assume, so you are loading the last row into the whole array.

You don't need that, simply loop once like this:
PHP код:
// 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 
irowsi++) {
    
tInfo[i][···] = cache_get_field_content_int(i, ...);

And you are not saving the dynamic object id anywhere, i don't know if its intentional or not. Just pointing out.
Reply
#6

Thanks all!
problem solved...

I had problem on query
PHP код:
mysql_function_query(dbhandlequerytrue"OnTowerLoad"""); 
    
format(querysizeof(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 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)