Mysql R7 Load Problem
#1

PHP код:
#define MAX_WORK_VEHICLES 10
enum wAndmed
{
    
wT88ID,
    
wMasinaID,
    
wT88MasinaID,
    
wModelID,
    
wTyyp[36],
    
FloatwPosX,
     
FloatwPosY,
     
FloatwPosZ,
     
FloatwAngle,
     
wV2rv1,
     
wV2rv2
}
new 
T88MasinateInfo[MAX_WORK_VEHICLES][wAndmed];
forward LoadWorkVehicles();
public 
LoadWorkVehicles()
{
    new 
rowsfieldsstring[256], number[11];
    
cache_get_data(rowsfields);
    if(!
rows)
    {
        print(
"Tцц Masinad = Tьhi.");
        return 
1;
    }
    else
    {
        new 
1;
        while(
MAX_WORK_VEHICLES)
        {
            
cache_get_row(00number), T88MasinateInfo[i][wT88ID] = strval(number);
            
cache_get_row(01number), T88MasinateInfo[i][wMasinaID] = strval(number);
            
cache_get_row(02number), T88MasinateInfo[i][wT88MasinaID] = strval(number);
            
cache_get_row(03number), T88MasinateInfo[i][wModelID] = strval(number);
            
cache_get_row(04string); format(T88MasinateInfo[i][wTyyp], 36"%s"string);
            
cache_get_row(05number), T88MasinateInfo[i][wPosX] = floatstr(number);
            
cache_get_row(06number), T88MasinateInfo[i][wPosY] = floatstr(number);
            
cache_get_row(07number), T88MasinateInfo[i][wPosZ] = floatstr(number);
            
cache_get_row(08number), T88MasinateInfo[i][wAngle] = floatstr(number);
            
cache_get_row(09number), T88MasinateInfo[i][wV2rv1] = strval(number);
            
cache_get_row(010number), T88MasinateInfo[i][wV2rv2] = strval(number);
            
printf("%d"i);
            if(
T88MasinateInfo[i][wT88MasinaID])
            {
                
T88MasinateInfo[i][wMasinaID] = CreateVehicle(T88MasinateInfo[i][wModelID], T88MasinateInfo[i][wPosX], T88MasinateInfo[i][wPosY], T88MasinateInfo[i][wPosZ], T88MasinateInfo[i][wAngle], T88MasinateInfo[i][wV2rv1], T88MasinateInfo[i][wV2rv2], 2);
                
printf("Masinad ID: %d"T88MasinateInfo[i][wMasinaID]);
            }
            
i++;
        }
        print(
"Tцц Masinad = Laetud.");
    }
    return 
1;

PHP код:
forward OnGameModeInitMysqlLoad();
public 
OnGameModeInitMysqlLoad()
{
    new 
query[500];
    
format(querysizeof(query), "SELECT * FROM tццmasinad");
    
mysql_function_query(SQLquerytrue"LoadWorkVehicles""");
    return 
1;

'OnGameModeInitMysqlLoad();' is under 'OnGameModeInit()'.

Problem is that.... He create me 9 cars, but in database is only one.(All 9 is same pos and color.)

Reply
#2

That would loop MAX_WORK_VEHICLES-1 times and it would use the row 0 everytime.

Loop through the rows and use the i for the row instead of 0 (if more than 1 row existed, then it'd fail).

pawn Код:
else
{
    for(new i; i != rows; i++)
    {
        cache_get_row(i, 0, number), T88MasinateInfo[i][wT88ID] = strval(number);
        cache_get_row(i, 1, number), T88MasinateInfo[i][wMasinaID] = strval(number);
        cache_get_row(i, 2, number), T88MasinateInfo[i][wT88MasinaID] = strval(number);
        cache_get_row(i, 3, number), T88MasinateInfo[i][wModelID] = strval(number);
        cache_get_row(i, 4, string); format(T88MasinateInfo[i][wTyyp], 36, "%s", string);
        cache_get_row(i, 5, number), T88MasinateInfo[i][wPosX] = floatstr(number);
        cache_get_row(i, 6, number), T88MasinateInfo[i][wPosY] = floatstr(number);
        cache_get_row(i, 7, number), T88MasinateInfo[i][wPosZ] = floatstr(number);
        cache_get_row(i, 8, number), T88MasinateInfo[i][wAngle] = floatstr(number);
        cache_get_row(i, 9, number), T88MasinateInfo[i][wV2rv1] = strval(number);
        cache_get_row(i, 10, number), T88MasinateInfo[i][wV2rv2] = strval(number);
        printf("%d", i);
        if(T88MasinateInfo[i][wT88MasinaID])
        {
            T88MasinateInfo[i][wMasinaID] = CreateVehicle(T88MasinateInfo[i][wModelID], T88MasinateInfo[i][wPosX], T88MasinateInfo[i][wPosY], T88MasinateInfo[i][wPosZ], T88MasinateInfo[i][wAngle], T88MasinateInfo[i][wV2rv1], T88MasinateInfo[i][wV2rv2], 2);
            printf("Masinad ID: %d", T88MasinateInfo[i][wMasinaID]);
        }
    }
    print("Tцц Masinad = Laetud.");
}
EDIT:

Quote:
Originally Posted by zT KiNgKoNg
Посмотреть сообщение
Sice you're using MySQL you want to make i = 1 so it links to the Database entry id and make it easy for any 'Admin' systems to work, not 0.
No, that's bad. Rows may start from 1 in the phpMyAdmin but in the modes, it must start from 0.
Reply
#3

Sice you're using MySQL you want to make i = 1 so it links to the Database entry id and make it easy for any 'Admin' systems to work, not 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)