Vehicle issue
#1

Alright so the problem is simple, the script is loading only some vehicles, not all of them, in most cases it loads like 5 cars
PHP код:
public OnVehicleLoad()
{
    new 
rowsfields;
    
cache_get_data(rowsfieldsmysql);
      for(new 
0rowsi++)
    {
        new 
vehicleid CreateVehicle(cache_get_field_content_int(i,"ModelID"), cache_get_field_content_float(i,"PosX"),cache_get_field_content_float(i,"PosY"),cache_get_field_content_float(i,"PosZ"),cache_get_field_content_float(i,"PosA"),cache_get_field_content_int(i,"Color1"),cache_get_field_content_int(i,"Color2"),0,0);
        
VehInfo[vehicleid][VehMasterID] = cache_get_field_content_int(i,"MasterID");
        
VehInfo[vehicleid][VID] = cache_get_field_content_int(i,"ID");
        
VehInfo[vehicleid][ModelID] = cache_get_field_content_int(i,"ModelID");
        
VehInfo[vehicleid][Color1] = cache_get_field_content_int(i,"Color1");
        
VehInfo[vehicleid][Color2] = cache_get_field_content_int(i,"Color2");
        
VehInfo[vehicleid][VehPosX] = cache_get_field_content_float(i,"PosX");
        
VehInfo[vehicleid][VehPosY] = cache_get_field_content_float(i,"PosY");
        
VehInfo[vehicleid][VehPosZ] = cache_get_field_content_float(i,"PosZ");
        
VehInfo[vehicleid][VehPosA] = cache_get_field_content_float(i,"PosA");
        
VehInfo[vehicleid][VRespawnTime] = cache_get_field_content_int(i,"RespawnTime");
        
VehInfo[vehicleid][VPrice] = cache_get_field_content_int(i,"Price");
        
VehInfo[vehicleid][DamageStatus] = cache_get_field_content_float(i,"Damage");
        
VehInfo[vehicleid][FuelStatus] = cache_get_field_content_int(i,"FuelStatus");
        
VehInfo[vehicleid][EngineStatus] = cache_get_field_content_int(i,"EngineStatus");
        
VehInfo[vehicleid][Kilometrage] = cache_get_field_content_float(i,"Kilometrage");
        
VehInfo[vehicleid][vSiren] = cache_get_field_content_int(i,"Siren");
        
VehInfo[vehicleid][vOwned] = cache_get_field_content_int(i,"Owned");
        
VehInfo[vehicleid][VehWorld] = cache_get_field_content_int(i,"VirtualWorld");
        
VehInfo[vehicleid][VehInterior] = cache_get_field_content_int(i,"Interior");
        
SetVehicleVirtualWorld(vehicleid,VehInfo[vehicleid][VehWorld]);
        
LinkVehicleToInterior(vehicleid,VehInfo[vehicleid][VehInterior]);
        
SetVehiclePos(vehicleid,VehInfo[vehicleid][VehPosX],VehInfo[vehicleid][VehPosY],VehInfo[vehicleid][VehPosZ]);
        
SetVehicleZAngle(vehicleidVehInfo[vehicleid][VehPosA]);
        
VehiclesLoaded++;
    }
    
printf("Total %i vehicles spawned",VehiclesLoaded);
    if(
VehiclesLoaded == 0)
    {
        
printf("No vehicles loaded.");
    }
}
SaveAllCars() { //saving all vehicles in SQL
    
new VehiclesSaved 0;
    for(new 
1<= MAX_VEHICLESx++) {
        if(
IsValidVehicle(x)) {
            new 
Float:tmpStatus,query[128];
            
GetVehicleHealth(x,tmpStatus);
            
mysql_format(mysqlquerysizeof(query), "UPDATE `vehicles` SET `Color1`=%i,`Color2`=%i,`Damage`=%f,`FuelStatus`=%i,`Kilometrage`=%f WHERE `ID`=%d",\
            
VehInfo[x][Color1],VehInfo[x][Color2],tmpStatus,VehInfo[x][FuelStatus],VehInfo[x][Kilometrage],VehInfo[x][VID]);
            
mysql_tquery(mysqlquery);
            
VehiclesSaved++;
        }
    }
    
printf("Total of %i vehicles saved",VehiclesSaved);
    return 
true;


Query
PHP код:
mysql_tquery(mysql"SELECT * FROM `vehicles`""OnVehicleLoad"""); 
The problem started occuring when I reached around 50-60 vehicles, they are all saved inside the SQL and everything but they arent being loaded + the printf isnt being displayed at all

PHP код:
printf("Total %i vehicles spawned",VehiclesLoaded);
    if(
VehiclesLoaded == 0)
    {
        
printf("No vehicles loaded.");
    } 
Reply
#2

check when does MAX_VEHICLES stop

maybe MAX_VEHICLES is at like 50 that's why it only saves that much
Reply
#3

Quote:
Originally Posted by Golimad
Посмотреть сообщение
check when does MAX_VEHICLES stop

maybe MAX_VEHICLES is at like 50 that's why it only saves that much
I would do that but not sure how?
Reply
#4

printf("MAX_VEHICLES = %i",MAX_VEHICLES); on gamemodeinit.

Also about printf not being displayed you could try the following:

Код:
if(VehiclesLoaded == 0) 
{ 
	print("No vehicles loaded."); 
}
else
{
	printf("Total %i vehicles spawned",VehiclesLoaded); 
}
Reply
#5

Okay so results
PHP код:
[03:53:52MAX_VEHICLES 2000 
EDIT: The script loaded 9 vehicles from SQL (I used /gotocar and there were only vehicles to car ID:9, after that none)


EDIT V2: There are 9 different vehicle Models inside SQL but 20 cars, so basically it loads 1 car from every model.
Reply
#6

seems very strange, are you sure there are more than 9 vehicles in the vehicles table? if you are, then try putting a print inside your loop to pinpoint exactly when it stops and post back the results
Reply
#7

Quote:
Originally Posted by PinkFloydLover
Посмотреть сообщение
seems very strange, are you sure there are more than 9 vehicles in the vehicles table? if you are, then try putting a print inside your loop to pinpoint exactly when it stops and post back the results
20 different vehicles BUT 9 vehcle models (ie: turismo, infernus etc. etc) so its loading 1 vehicle from each model I have...


EDIT: I was actually wrong, its loading first 9 vehicles from the database
PHP код:
[04:07:30Number of vehicle models0
[04:07:30Created vehicle model411. Server ID1. SQL ID39
[04:07:31Created vehicle model400. Server ID2. SQL ID40
[04:07:31Created vehicle model402. Server ID3. SQL ID41
[04:07:31Created vehicle model411. Server ID4. SQL ID42
[04:07:31Created vehicle model411. Server ID5. SQL ID43
[04:07:31Created vehicle model411. Server ID6. SQL ID44
[04:07:31Created vehicle model411. Server ID7. SQL ID45
[04:07:31Created vehicle model451. Server ID8. SQL ID46
[04:07:31Created vehicle model444. Server ID9. SQL ID47 
My vehicle ID starts at 39 due to fact I erased some etc.


print
PHP код:
printf("Created vehicle model: %i. Server ID: %i. SQL ID: %i",VehInfo[vehicleid][ModelID],vehicleid,VehInfo[vehicleid][VID]); 
Reply
#8

pawn Код:
for(new i = 0; i < rows; i++)
    {
        VehInfo[vehicleid][VehMasterID] = cache_get_field_content_int(i,"MasterID");
        VehInfo[vehicleid][VID] = cache_get_field_content_int(i,"ID");
        VehInfo[vehicleid][ModelID] = cache_get_field_content_int(i,"ModelID");
        VehInfo[vehicleid][Color1] = cache_get_field_content_int(i,"Color1");
        VehInfo[vehicleid][Color2] = cache_get_field_content_int(i,"Color2");
        VehInfo[vehicleid][VehPosX] = cache_get_field_content_float(i,"PosX");
        VehInfo[vehicleid][VehPosY] = cache_get_field_content_float(i,"PosY");
        VehInfo[vehicleid][VehPosZ] = cache_get_field_content_float(i,"PosZ");
        VehInfo[vehicleid][VehPosA] = cache_get_field_content_float(i,"PosA");
        VehInfo[vehicleid][VRespawnTime] = cache_get_field_content_int(i,"RespawnTime");
        VehInfo[vehicleid][VPrice] = cache_get_field_content_int(i,"Price");
        VehInfo[vehicleid][DamageStatus] = cache_get_field_content_float(i,"Damage");
        VehInfo[vehicleid][FuelStatus] = cache_get_field_content_int(i,"FuelStatus");
        VehInfo[vehicleid][EngineStatus] = cache_get_field_content_int(i,"EngineStatus");
        VehInfo[vehicleid][Kilometrage] = cache_get_field_content_float(i,"Kilometrage");
        VehInfo[vehicleid][vSiren] = cache_get_field_content_int(i,"Siren");
        VehInfo[vehicleid][vOwned] = cache_get_field_content_int(i,"Owned");
        VehInfo[vehicleid][VehWorld] = cache_get_field_content_int(i,"VirtualWorld");
        VehInfo[vehicleid][VehInterior] = cache_get_field_content_int(i,"Interior");
        SetVehicleVirtualWorld(vehicleid,VehInfo[vehicleid][VehWorld]);
        LinkVehicleToInterior(vehicleid,VehInfo[vehicleid][VehInterior]);
        SetVehiclePos(vehicleid,VehInfo[vehicleid][VehPosX],VehInfo[vehicleid][VehPosY],VehInfo[vehicleid][VehPosZ]);
        SetVehicleZAngle(vehicleid, VehInfo[vehicleid][VehPosA]);
        VehiclesLoaded++;

        new vehicleid = CreateVehicle(VehInfo[vehicleid][ModelID], VehInfo[vehicleid][VehPosX], VehInfo[vehicleid][VehPosY], VehInfo[vehicleid][VehPosZ], VehInfo[vehicleid][VehPosA], VehInfo[vehicleid][Color1], VehInfo[vehicleid][Color2], 0 0);
        printf("CreateVehicle(%d, %.2f, %.2f, %.2f, %.2f, %d, %d, 0 ,0)", VehInfo[vehicleid][ModelID], VehInfo[vehicleid][VehPosX], VehInfo[vehicleid][VehPosY], VehInfo[vehicleid][VehPosZ], VehInfo[vehicleid][VehPosA], VehInfo[vehicleid][Color1], VehInfo[vehicleid][Color2]);
        printf("row %d loaded succesfully.", i);

    }
^^ try that, i added print messages to help explain whats going on better, also you shouldn't be reading the fields each time you want to use them, just read them once and then use the stored value
Reply
#9

here we go
PHP код:
[04:16:02CreateVehicle(4112280.13, -81.6526.52223.6700,0)
[
04:16:02row 0 loaded succesfully.
[
04:16:02CreateVehicle(400509.98, -1294.7316.96305.0100,0)
[
04:16:02row 1 loaded succesfully.
[
04:16:02CreateVehicle(402509.98, -1294.7316.96305.0100,0)
[
04:16:02row 2 loaded succesfully.
[
04:16:02CreateVehicle(411296.37, -1171.2380.6332.6200,0)
[
04:16:02row 3 loaded succesfully.
[
04:16:02CreateVehicle(411, -399.701228.516.32170.7600,0)
[
04:16:02row 4 loaded succesfully.
[
04:16:02CreateVehicle(411700.22, -833.4342.64107.1800,0)
[
04:16:02row 5 loaded succesfully.
[
04:16:02CreateVehicle(4111609.81311.5320.98263.4400,0)
[
04:16:02row 6 loaded succesfully.
[
04:16:02CreateVehicle(4511681.56, -334.1245.04192.1900,0)
[
04:16:02row 7 loaded succesfully.
[
04:16:02CreateVehicle(4441677.10, -319.0545.09188.2311,0)
[
04:16:02row 8 loaded succesfully
Reply
#10

Let's see how many rows are actually found.
PHP код:
new rowsfields
cache_get_data(rowsfieldsmysql);
printf("ROW COUNT: Method 1: %i, Method 2: %i"rowscache_get_row_count()); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)