Car load won't work
#1

Hi, i got a problem with MYSQL car loading. Using R5 MYSQL plugin and trying to do this:

Код:
enum Cars
{
Id,
Owner,
Model,
Float:X,
Float:Y,
Float:Z,
Float:Angle,
HP,
Fuel,
Color1,
Color2,
Lock,
tune0,
tune1,
tune2,
tune3,
tune4,
tune5,
tune6,
tune7,
tune8,
tune9,
tune10,
tune11,
tune12,

}
new vInfo[MAX_VEHICLES][Cars];
AND:

Код:
  	for(new i; i < MAX_VEHICLES; i++)
    {
        new FetchLine[256];
        mysql_query("SELECT * FROM vehicles WHERE ID = '%d'",i);
        mysql_store_result();
        if(mysql_fetch_row_format(FetchLine,"|"))
        {
            printf("%s", FetchLine);
            sscanf(FetchLine, "p<|>e<isdffffdddddddddddddddddd>",vInfo[i][Id],vInfo[i][Owner],vInfo[i][Model],vInfo[i][X],vInfo[i][Y],vInfo[i][Z],vInfo[i][Angle],vInfo[i][HP],vInfo[i][Fuel],vInfo[i][Color1],vInfo[i][Color2],vInfo[i][Lock],vInfo[i][tune0],vInfo[i][tune1],vInfo[i][tune2],vInfo[i][tune3],vInfo[i][tune4],vInfo[i][tune5],vInfo[i][tune6],vInfo[i][tune7],vInfo[i][tune8],vInfo[i][tune9],vInfo[i][tune10],vInfo[i][tune11],vInfo[i][tune12]);
            CreateVehicle(vInfo[i][Model],vInfo[i][X],vInfo[i][Y],vInfo[i][Z],vInfo[i][Angle],vInfo[i][Color1],vInfo[i][Color2],0);
            printf("%s", FetchLine);

        }
    }
What's wrong with that? It won't create car.
Reply
#2

Not tested
try.:
pawn Код:
#include <a_samp>
#include <a_mysql>
#include <sscanf2>

enum
    Cars_Enum
{
    Id,        
    Owner[24],
    Model,
    Float:X,
    Float:Y,
    Float:Z,
    Float:Angle,
    HP,
    Fuel,
    Color1,
    Color2,
    Lock,
    tune0,
    tune1,
    tune2,
    tune3,
    tune4,
    tune5,
    tune6,
    tune7,
    tune8,
    tune9,
    tune10,
    tune11,
    tune12
};

new
    vInfo[MAX_VEHICLES][Cars_Enum];

stock
    LoadVehicles_Mysql()
{
    if(!mysql_ping()) return 0;
    new
        FetchLine[512],
        index = 0;
    mysql_query("SELECT * FROM `vehicles`"); // select from all vehicles database
    mysql_store_result();                   // store result
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(FetchLine))
        {
            sscanf(FetchLine, "e<p<|>is[25]dffffdddddddddddddddddd>", vInfo[index]);
            CreateVehicle(  vInfo[index][Model],
                            vInfo[index][X],
                            vInfo[index][Y],
                            vInfo[index][Z],
                            vInfo[index][Angle],
                            vInfo[index][Color1],
                            vInfo[index][Color2],
                            60000
                        );
            index++;
            if(index == MAX_VEHICLES - 1) break;
        }
    } print("ERROR 0 row's sql database");
    mysql_free_result(); // free result
    return 1;
}
   
public
//  OnFilterScriptInit()
// or
    OnGameModeInit()
{
    ConnectMySQL();    
    LoadVehicles_Mysql();
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)