Loading
#1

PHP код:
forward AtmsLoad();
public 
AtmsLoad()
{
    new 
rows cache_num_rows();
    if(
rows)
    {
        new 
index Iter_Free(i_ATM);
        for(new 
0rowsi++)
        {
            
cache_get_value_int(i"ID"AtmInfo[index][aID]);
            
cache_get_value_float(i"PosX"AtmInfo[index][aPosX]);
            
cache_get_value_float(i"PosY"AtmInfo[index][aPosY]);
            
cache_get_value_float(i"PosZ"AtmInfo[index][aPosZ]);
            
cache_get_value_float(i"Angle"AtmInfo[index][aAngle]);
            
cache_get_value_int(i"VW"AtmInfo[index][aVW]);
            
cache_get_value_int(i"Interior"AtmInfo[index][aInt]);
            
AtmInfo[i][AtmExist] = true;
            
Iter_Add(i_ATMindex);
            
CreateAtm(index);
        }
        
printf("ATMs loaded: %d"rows);
    }
    return 
1;

ID's are saved as 1, 2, 3, 4,.. in DB and that is fine..
But every ID is loading as 0.. Any ideas?

EDIT: When I am creating ATMs ther are created with ID 1, 2, 3, 4.. so loading is problem only..
Reply
#2

Shouldn't the Iter_Free line be inside the loop? As I see it you're now constantly overwriting the same index.
Reply
#3

So you are suggesting this??
PHP код:
forward AtmsLoad();
public 
AtmsLoad()
{
    new 
rows cache_num_rows();
    if(
rows)
    {
        for(new 
0rowsi++)
        {
            new 
index Iter_Free(i_ATM);
            
cache_get_value_int(i"ID"AtmInfo[index][aID]);
            
cache_get_value_float(i"PosX"AtmInfo[index][aPosX]);
            
cache_get_value_float(i"PosY"AtmInfo[index][aPosY]);
            
cache_get_value_float(i"PosZ"AtmInfo[index][aPosZ]);
            
cache_get_value_float(i"Angle"AtmInfo[index][aAngle]);
            
cache_get_value_int(i"VW"AtmInfo[index][aVW]);
            
cache_get_value_int(i"Interior"AtmInfo[index][aInt]);
            
AtmInfo[i][AtmExist] = true;
            
Iter_Add(i_ATMindex);
            
CreateAtm(index);
        }
        
printf("ATMs loaded: %d"rows);
    }
    return 
1;

If yes there is a problem. It is loading ID's as 0, 1..
Problem is that ID 0 is treated as ID 1
ID 1 is treated as ID 2
ID 2 is treated as ID 3...
Reply
#4

-FIXED-
This is loading
PHP код:
forward AtmsLoad(); 
public 
AtmsLoad() 

    new 
rows cache_num_rows(); 
    if(
rows
    { 
        new 
index Iter_Free(i_ATM); 
        for(new 
0rowsi++) 
        { 
            
cache_get_value_int(i"ID"AtmInfo[index][aID]); 
            
cache_get_value_float(i"PosX"AtmInfo[index][aPosX]); 
            
cache_get_value_float(i"PosY"AtmInfo[index][aPosY]); 
            
cache_get_value_float(i"PosZ"AtmInfo[index][aPosZ]); 
            
cache_get_value_float(i"Angle"AtmInfo[index][aAngle]); 
            
cache_get_value_int(i"VW"AtmInfo[index][aVW]); 
            
cache_get_value_int(i"Interior"AtmInfo[index][aInt]); 
            
AtmInfo[i][AtmExist] = true
            
Iter_Add(i_ATMindex); 
            
CreateAtm(index); 
        } 
        
printf("ATMs loaded: %d"rows); 
    } 
    return 
1

Problem was here
PHP код:
CreateAtm(id)
{
    new 
string[120];
    
format(stringsizeof(string), ""SERVERBLUE"ID: "WHITE"%d\n"SERVERBLUE"ATM\n"WHITE"To use ATM press 'Y'"AtmInfo[id][aID]);
    
AtmLabel[id] = CreateDynamic3DTextLabel(string0x1D9F00AAAtmInfo[id][aPosX], AtmInfo[id][aPosY], AtmInfo[id][aPosZ]+0.125.0___00__);
    
AtmObject[id] = CreateDynamicObject(ATM_OBJECTAtmInfo[id][aPosX], AtmInfo[id][aPosY], AtmInfo[id][aPosZ], 0.00.0AtmInfo[id][aAngle], AtmInfo[id][aVW], AtmInfo[id][aInt], __);
    return 
1;

Instead of AtmInfo[id][aID] I was creating ID with just wiriting ID there xD
Reply
#5

Your loading is most likely bugged.
I'm pretty sure Vince is right about Iter_Free.

You're re-using the same index (Iter_Free returns the nearest 'free' index inside of the iterator)
If you use it just once, you'll always be using the same index, so you'll be overwriting the old data.
Reply
#6

Quote:
Originally Posted by Micko123
Посмотреть сообщение
So you are suggesting this??
Код:
code
If yes there is a problem. It is loading ID's as 0, 1..
Problem is that ID 0 is treated as ID 1
ID 1 is treated as ID 2
ID 2 is treated as ID 3...
Look at that.. I did it my way and it is working like charm xD
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)