Data loading wrong
#1

I just noticed that the cars are loading wrong
Code:
PHP код:
LoadVehicleStats()
{
    
mysql_tquery(Database"SELECT * FROM Vehicles LIMIT" #MAX_PVEHICLES, "OnVehiclesAvailable");
    
return 1;
}
public 
OnVehiclesAvailable()
{
    for(new 
0MAX_PVEHICLESi++)
    {
        
cache_get_value_int(i"ID"VehicleInfo[i][ID]);
        
cache_get_value(i"Owner"VehicleInfo[i][vOwner], 24);
        
cache_get_value_int(i"vModel"VehicleInfo[i][vModel]);
        
cache_get_value_float(i"Pos_x"VehicleInfo[i][vPos_x]);
        
cache_get_value_float(i"Pos_y"VehicleInfo[i][vPos_y]);
        
cache_get_value_float(i"Pos_z"VehicleInfo[i][vPos_z]);
        
cache_get_value_float(i"Rot"VehicleInfo[i][vRot]);
        
cache_get_value_int(i"Fuel"VehicleInfo[i][vFuel]);
        
cache_get_value_int(i"Type"VehicleInfo[i][vType]);
        
cache_get_value(i"Plate"VehicleInfo[i][vPlate], 120);
        
cache_get_value_int(i"vLock"VehicleInfo[i][vLock]);
        
cache_get_value_int(i"Color1"VehicleInfo[i][vColor1]);
        
cache_get_value_int(i"Color2"VehicleInfo[i][vColor2]);
        
cache_get_value_int(i"RespawnDelay"VehicleInfo[i][vRespawnDelay]);
        
cache_get_value_int(i"Price"VehicleInfo[i][vPrice]);
        
VehicleInfo[i][Vehicle_Cache] = cache_save();
        
pvehicle[VehicleInfo[i][ID]] = CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vPos_x], VehicleInfo[i][vPos_y], VehicleInfo[i][vPos_z], VehicleInfo[i][vRot], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2], VehicleInfo[i][vRespawnDelay]);
        
SetVehicleNumberPlate(pvehicle[VehicleInfo[i][ID]], VehicleInfo[i][vPlate]);
    }
    return 
1;

Example, I have a car that is type 1(for sale)
The plate is set right as it is saved in the database, but if I enter the car and use the debug command
PHP код:
CMD:testcar(playeridparams[])
{
    new 
string[200], vid;
    
vid GetPlayerVehicleID(playerid);
    
format(stringsizeof(string), "Vehicle ID: %d | Vehicle Type: %d, Plate: %s | Owner: %s"vidVehicleInfo[vid][vType], VehicleInfo[vid][vPlate], VehicleInfo[vid][vOwner] );
    
SCM(playeridCOLOR_YELLOWstring);
    return 
1;

It will tell me the right ID, that it is a type 3 vehicle which is DMV(wrong), and also it will tell me a DMV plate also DMV owner.

I also noticed that the car is misplaced with the first DMV car and the last SPAWN car is misplaced with this car.

Why is the data loading wrong?
Reply
#2

maybe there is something wrong with the current query, try this one:
Код:
mysql_tquery(Database, "SELECT * FROM Vehicles LIMIT "#MAX_PVEHICLES"", "OnVehiclesAvailable");
Reply
#3

Quote:
Originally Posted by Sabur
Посмотреть сообщение
maybe there is something wrong with the current query, try this one:
Код:
mysql_tquery(Database, "SELECT * FROM Vehicles LIMIT "#MAX_PVEHICLES"", "OnVehiclesAvailable");
I use the same on buildings and there is no issue
Reply
#4

simply remove that max pvehicle because on when to gamemode starts, the cars are spawned randomly. You must query it using the players id or the owners name so... Hope it fixes..
Reply
#5

I tested a bit more and I discovered that even if I add new vehicles, only the first 8 vehicles load..

I mean the vehicles spawn right but if I use a command to debug them and check their details like vType, plate etc, it shows only for the first 8. I really don't know what is wrong with the code so if anyone can fix this I'll be very happy...
Reply
#6

REMOVE MAX_PVEHICLE as your limit coz it will read that...

or just remove the LIMIT part towards the MAX_PVEHICLE don't set any maximum

if you are loading player cars

Yiu should het it from the id.

PHP код:
LoadVehicleStats() 

    
mysql_tquery(Database"SELECT * FROM Vehicles" "OnVehiclesAvailable"); 
    return 
1

That's all you need to do

It will load all the cars on your server player and non player vehicles.
Reply
#7

Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
REMOVE MAX_PVEHICLE as your limit coz it will read that...

or just remove the LIMIT part towards the MAX_PVEHICLE don't set any maximum

if you are loading player cars

Yiu should het it from the id.

PHP код:
LoadVehicleStats() 

    
mysql_tquery(Database"SELECT * FROM Vehicles" "OnVehiclesAvailable"); 
    return 
1

That's all you need to do.

then remove that for loop
Still same issue

I have 10 vehicles:

1. SPAWN Vehicle(loaded as vehicle 2)
2. SPAWN Vehicle(loaded as vehicle 3)
3. SPAWN Vehicle(loaded as vehicle 4)
4. SPAWN Vehicle(loaded as vehicle 5)
5. For sale vehicle(loaded as vehicle 6)
6. DMV Vehicle(loaded as vehicle 7)
7. DMV Vehicle(loaded as vehicle
8. DMV Vehicle(loaded as vehicle 9)
9. DMV Vehicle (anything from here on is not loading anymore)
10. For sale vehicle
Reply
#8

remove that for loop also it stops you from spawning more than the max pvehicle.

PHP код:
new rows;
use 
cache_get_row_count(rows);
if(
rows)
    {
           for(new 
irowsi++)
           
// your code here
     

[EDIT]
This is also an important one don't set the new i = 0; it will load from zero let it load from null to load the first vehicle. Which is ID 0 if it's equals zero it will skip 0 which is the id of the first car and start with ID 1 which is the second car

[EDIT2]
To explain that part the for loop reads the variable the way you set it. Since you set it from zero it will read the variable as 0 Now it will look at if its less than the max vehicle you set which is eight or for me the rows of cars on the database. Then it will say oh yes its less than maximum the scripter set. okay let's add one so either i++ than having 0 as first to read.

It will read 1.
Reply
#9

Same issue... and I really don't know why.. I use the same damn system for buildings (/enter /exit) and it works PERFECTLY, they load PERFECTLY, why this one is broken (


I mean, the cars load perfectly too, they spawn with the right plate, everything that is in the loop is loaded okay, but if I call the VehicleInfo later, example

If I am in the vehicle id 1 and I use a command to check the details of it, it will show me the details of the vehicle with ID2 from the database...
Reply
#10

I got a problem, not exactly like this but.. it's kind the same thing. My problem came from the loop.
PHP код:
mysql_tquery(MySQL"SELECT * FROM Vehicle ORDER BY ID""OnVehiclesLoad""");    
PUBLIC:
OnVehiclesLoad()
{
    for (new 
i1cache_num_rows(); != ji++, r++)
    {
        
cache_get_value_int(i"ID"vStats[r][vSQLIB]);
        
cache_get_value_float(i"x"vStats[r][vX]);
        
cache_get_value_float(i"y"vStats[r][vY]);
        
cache_get_value_float(i"z"vStats[r][vZ]);
        
cache_get_value_int(i"Color1"vStats[r][vColor1]);
        
cache_get_value_int(i"Color2"vStats[r][vColor2]);
        
cache_get_value_float(i"Health"vStats[r][vHealth]);
        
cache_get_value_int(i"Model"vStats[r][vModel]);
        
cache_get_value_int(i"Respawn"vStats[r][vRespawn]);
        
cache_get_value_float(i"Angle"vStats[r][vZr]);
        
cache_get_value(i"Plate"vStats[r][vPlate], 20);
        
CreatedVehicle[r] = false;
        
#if DebugMode
              
printf("Vйhicule ID %i"r);
          
#endif
        
vStats[r][vID] = CreateVehicle(vStats[r][vModel], vStats[r][vX], vStats[r][vY], vStats[r][vZ], vStats[r][vZr], vStats[r][vColor1], vStats[r][vColor2], vStats[r][vRespawn]);
        
SetVehicleHealth(vStats[r][vID], vStats[r][vHealth]);
        
SetVehicleNumberPlate(vStats[r][vID], vStats[r][vPlate]);
        
#if DebugMode
            
GetVehicleDebugInfos(r);
        
#endif
    
}
    print(
"[SERVER] All vehicle are loaded.\n\n");

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)