View Single Post
Old 03/02/2020, 05:26 PM   #12
OsmanMalagic
Little Clucker
 
Join Date: Jul 2016
Location: EX-YU
Posts: 40
Reputation: 51
Spray Re: MySQL load vehicles issue

Quote:
Originally Posted by Sasinosoft View Post
You should really show us more code, especially the enum structure and CarInfo.

Also:
Code:
for(new i = 0; i < rows; i++)
    {
        for(new j = 1; j < sizeof(CarInfo); j++)
        { //...
Almost certainly, there is something wrong with that. It's like you are trying to create sizeof(CarInfo) cars for each car row in the table.
PHP Code:
enum cInfo
{
    
cID// Unique ID 
    
cCarID// Real Car ID goes from 1 to 1000 through loop carinfo
    
cModel,
    
Float:cLocationx,
    
Float:cLocationy,
    
Float:cLocationz,
    
Float:cAngle,
    
cColorOne,
    
cColorTwo,
    
cOwner[MAX_PLAYER_NAME],
    
cOwned,
    
cVirWorld
};
new 
CarInfo[600][cInfo];
new 
ownedcar[sizeof(CarInfo)]; 
Saving:

PHP Code:
new car 1;
for(new 
1sizeof(CarInfo); h++)
{
    if(
CarInfo[h][cOwned] == 0)
    {
        
car h;
        
9999;
    }
}

CarInfo[car][cOwned] = 1;
strmid(CarInfo[car][cOwner], sendername0strlen(sendername), 999);
CarInfo[car][cLocationx] = 590.3740;
CarInfo[car][cLocationy] = 1026.0565;
CarInfo[car][cLocationz] = 103.9063;
CarInfo[car][cAngle] = 317.1649;
CarInfo[car][cCarID] = car;
CarInfo[car][cModel] = model;
CarInfo[car][cVirWorld] = 0;
CarInfo[car][cColorOne] = 1;
CarInfo[car][cColorTwo] = 1;
ownedcar[car] = NBC_AddStaticVehicleEx(CarInfo[car][cModel], CarInfo[car][cLocationx], CarInfo[car][cLocationy], CarInfo[car][cLocationz], CarInfo[car][cAngle], 11600000); 
After saving part CarInfo[car][cCarID] is 1 in MySQL Database!

Now loading part:

PHP Code:
public OnGameModeInit()
{
    
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `vehicles`");
    
mysql_pquery(mysqlquery"LoadVehicles""");
    return 
1;
}

forward LoadVehicles();
public 
LoadVehicles()
{
    
// Your code here
    
return 1;



Now i've deleted all cars from the server, and ID is 1, like from my Database.
Second part is to add vehicles step by step, if problem does not accours xD
OsmanMalagic is offline   Reply With Quote