SQL loop problem
#1

Alright so the problem is simple
PHP код:
SaveAllCars() {
    new 
VehiclesSaved 0;
    for(new 
0MAX_VEHICLESx++) {
        if(
IsValidVehicle(x)) {
            new 
Float:tmpStatus;
            
GetVehicleHealth(x,tmpStatus);
            new 
query[1512] = "UPDATE `vehicles` SET `Color1`=%i,`Color2`=%i";
            
strcat(query,",`Damage`=%f,`FuelStatus`=%i,`EngineStatus`=%i,`Kilometrage`=%f,`FactionID`=%i,\
            `Locked`=%i,`TrunkSlot1`=%i,`Plates`='%e',`Windows`=%i"
);
            
strcat(query,",`GloveboxWeapon`=%i,`GloveboxWeaponAmmo`=%i,\
            `TrunkWeapon1`=%i,`TrunkWeapon1Ammo`=%i,`TrunkWeapon2`=%i,`TrunkWeapon2Ammo`=%i,`TrunkWeapon3`=%i,\
            `TrunkWeapon3Ammo`=%i WHERE `ID`=%d"
);
            
format(querysizeof(query), queryVehInfo[x][Color1],VehInfo[x][Color2],
            
tmpStatus,VehInfo[x][FuelStatus],VehInfo[x][EngineStatus],
            
VehInfo[x][Kilometrage],VehInfo[x][VehFaction],VehInfo[x][VLock],VehInfo[x][VehTrunkSlot1],VehInfo[x][VehPlate],
            
VehInfo[x][VehWindows],VehInfo[x][GloveboxWeapon],VehInfo[x][GloveboxWeaponAmmo],
            
VehInfo[x][TrunkSlot1Weapon],VehInfo[x][TrunkSlot1WeaponAmmo],
            
VehInfo[x][TrunkSlot2Weapon],VehInfo[x][TrunkSlot2WeaponAmmo],
            
VehInfo[x][TrunkSlot3Weapon],VehInfo[x][TrunkSlot3WeaponAmmo],VehInfo[x][VID]);
            
mysql_tquery(mysqlquery"""");
            
VehiclesSaved++;
            print(
query);
        }
    
    }
    
MsgToAll(COLOR_RED,"[!A] All vehicles have been saved");
    
printf("Total of %i vehicles saved",VehiclesSaved);
    return 
true;

The problem is it will display result for this like

PHP код:
[18:35:14UPDATE `vehiclesSET `Color1`=1,`Color2`=0,`Damage`=1000.000000,`FuelStatus`=100,`EngineStatus`=0,`Kilometrage`=0.000000,`FactionID`=0,`Locked`=0,`TrunkSlot1`=0,`Plates`='e',`Windows`=48,`GloveboxWeapon`=0,`GloveboxWeaponAmmo`=24,`TrunkWeapon1`=100,`TrunkWeapon1Ammo`=0,`TrunkWeapon2`=0,`TrunkWeapon2Ammo`=0,`TrunkWeapon3`=0,`TrunkWeapon3Ammo`=0 WHERE `ID`=
For all cars it says ID:0


EDIT: I just added printf("%i",VehInfo[x][VID]); infront of all of it and it printed out all ID's correctly. But problem remains.
Reply
#2

woah, are you loading the ID too?
Reply
#3

Nope?
PHP код:
VehInfo[x][VID
this is SQL ID of the vehicle
Reply
#4

hmm.. give me a seccond
My vehicle create/loading code =
VehicleID[vehicleid] = CreateVehicle(ServerVehicle[vehicleid][Model],ServerVehicle[vehicleid][Spawn][0],ServerVehicle[vehicleid][Spawn][1],ServerVehicle[vehicleid][Spawn][2],ServerVehicle[vehicleid][Spawn][3],ServerVehicle[vehicleid][Color][0],ServerVehicle[vehicleid][Color][1],120, ServerVehicle[vehicleid][Siren]);


Maybe you may find this usefull.
Reply
#5

Look at what was printed out, "`Plates`='e'".

%e isn't a valid specifier on "format".
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Look at what was printed out, "`Plates`='e'".

%e isn't a valid specifier on "format".
Whaaaat? Holly shit (sorry for cursing)!
Thanks mate! That fixed it!
+rep to yall
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)