[Help] MySQL Vehicle System Saving
#1

Hello i change all my vehicle system from my server to mysql, the model, color,pos! its working but i have fuel and health it use to work.. but now doesn't work any more don't know why!

MySql version: R39-6
SA-MP version: Last one..


Load:
PHP код:
public LoadDynamicCars()
{
    new 
rows cache_num_rows();
        for (new 
idx=0idx rowsidx++)
       {
            if(
rows
            {
            
DynamicCars[idx][cID] = cache_get_field_content_int(idx"cID");
            
DynamicCars[idx][CarModel] = cache_get_field_content_int(idx"CarModel");
            
DynamicCars[idx][CarX] = cache_get_field_content_float(idx"CarX");
            
DynamicCars[idx][CarY] = cache_get_field_content_float(idx"CarY");
            
DynamicCars[idx][CarZ] = cache_get_field_content_float(idx"CarZ");
            
DynamicCars[idx][CarAngle] = cache_get_field_content_float(idx"CarAngle");
            
DynamicCars[idx][CarColor1] = cache_get_field_content_int(idx"CarColor1");
            
DynamicCars[idx][CarColor2] = cache_get_field_content_int(idx"CarColor2");
            
DynamicCars[idx][FactionCar] = cache_get_field_content_int(idx"FactionCar");
            
DynamicCars[idx][CarType] = cache_get_field_content_int(idx"CarType");
            
DynamicCars[idx][cOwner] = cache_get_field_content_int(idx"cOwner");
            
DynamicCars[idx][cValue] = cache_get_field_content_int(idx"cValue");
            
DynamicCars[idx][cOwned] = cache_get_field_content_int(idx"cOwned");
            
DynamicCars[idx][cLock] = cache_get_field_content_int(idx"cLock");
            
DynamicCars[idx][cFuel] = cache_get_field_content_int(idx"cFuel");
            
DynamicCars[idx][cGold] = cache_get_field_content_int(idx"cGold");
            
DynamicCars[idx][cHealth] = cache_get_field_content_float(idx"cHealth");
            
DynamicCars[idx][cPanels] = cache_get_field_content_int(idx"cPanels");
            
DynamicCars[idx][cDoors] = cache_get_field_content_int(idx"cDoors");
            
DynamicCars[idx][cLights] = cache_get_field_content_int(idx"cLights");
            
DynamicCars[idx][cTires] = cache_get_field_content_int(idx"cTires");
            
DynamicCars[idx][mod1] = cache_get_field_content_int(idx"mod1");
            
DynamicCars[idx][mod2] = cache_get_field_content_int(idx"mod2");
            
DynamicCars[idx][mod3] = cache_get_field_content_int(idx"mod3");
            
DynamicCars[idx][mod4] = cache_get_field_content_int(idx"mod4");
            
DynamicCars[idx][mod5] = cache_get_field_content_int(idx"mod5");
            
DynamicCars[idx][mod6] = cache_get_field_content_int(idx"mod6");
            
DynamicCars[idx][mod7] = cache_get_field_content_int(idx"mod7");
            
DynamicCars[idx][mod8] = cache_get_field_content_int(idx"mod8");
            
DynamicCars[idx][mod9] = cache_get_field_content_int(idx"mod9");
            
DynamicCars[idx][mod10] = cache_get_field_content_int(idx"mod10");
            
DynamicCars[idx][mod11] = cache_get_field_content_int(idx"mod11");
            
DynamicCars[idx][mod12] = cache_get_field_content_int(idx"mod12");
            
DynamicCars[idx][mod13] = cache_get_field_content_int(idx"mod13");
            
DynamicCars[idx][mod14] = cache_get_field_content_int(idx"mod14");
            
DynamicCars[idx][mod15] = cache_get_field_content_int(idx"mod15");
            
DynamicCars[idx][mod16] = cache_get_field_content_int(idx"mod16");
            
DynamicCars[idx][mod17] = cache_get_field_content_int(idx"mod17");
            
DynamicCars[idx][paintjob] = cache_get_field_content_int(idx"paintjob");
            
AddVehicleComponent(idx,DynamicCars[idx][mod1]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod2]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod3]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod4]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod5]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod6]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod7]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod8]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod9]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod10]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod11]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod12]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod13]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod14]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod15]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod16]);
            
AddVehicleComponent(idx,DynamicCars[idx][mod17]);
            
ChangeVehiclePaintjob(idx,DynamicCars[idx][paintjob]);
            
            
            new 
string[32];
            
format(string,sizeof(string),"RC-%d-17",idx);
            
SetVehicleNumberPlate(CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1),string);
                new 
Float:vida DynamicCars[idx][cHealth];
                
SetVehicleHealth(idxvida);
            
printf("%f vida",DynamicCars[idx][cHealth]);
            
Fuel[idx] = DynamicCars[idx][cFuel];
            
UpdateVehicleDamageStatus(idxDynamicCars[idx][cPanels],DynamicCars[idx][cDoors],DynamicCars[idx][cLights],DynamicCars[idx][cTires]);
}}
    return 
1;

Saving:
PHP код:
public SaveDynamicCars(playerid)
{
    new 
idx;
    
idx GetPlayerVehicleID(playerid);
    
GetVehiclePos(idxDynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ]);
    
GetVehicleZAngle(idx,DynamicCars[idx][CarAngle]);
    
GetVehicleHealth(idxDynamicCars[idx][cHealth]);
    
format(querysizeof(query),"UPDATE `carros` SET `CarX` = '%f',`CarY` = '%f',`CarZ` = '%f',`CarAngle` = '%f',`CarColor1` = '%d',`CarColor2` = '%d' WHERE `cID` = '%d'",DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2],idx);
    
mysql_tquery(mysqlquery"""");
    
format(querysizeof(query),"UPDATE `carros` SET `FactionCar` = '%d',`CarType` = '%d',`cOwner` = '%d',`cValue` = '%d',`cLock` = '%d',`cOwned` = '%d' WHERE `cID` = '%d'",DynamicCars[idx][FactionCar],DynamicCars[idx][CarType],DynamicCars[idx][cOwner],DynamicCars[idx][cValue],DynamicCars[idx][cLock],DynamicCars[idx][cOwned],idx);
    
mysql_tquery(mysqlquery"""");
    
format(querysizeof(query),"UPDATE `carros` SET `cGold` = '%d',`cFuel` = '%d',`cHealth` = '%f',`cPanels` = '%d',`cDoors` = '%d',`cLights` = '%d',`cTires` = '%d'  WHERE `cID` = '%d'",DynamicCars[idx][cGold],DynamicCars[idx][cFuel],DynamicCars[idx][cHealth],DynamicCars[idx][cPanels],DynamicCars[idx][cDoors],DynamicCars[idx][cLights],DynamicCars[idx][cTires],idx);
    
mysql_tquery(mysqlquery"""");
    
    return 
1;

Reply


Messages In This Thread
[Help] MySQL Vehicle System Saving - by CJoao - 04.10.2017, 23:12
Re: [Help] MySQL Vehicle System Saving - by whadez - 04.10.2017, 23:18
Re: [Help] MySQL Vehicle System Saving - by CJoao - 05.10.2017, 00:03
Re: [Help] MySQL Vehicle System Saving - by CJoao - 05.10.2017, 09:55
Re: [Help] MySQL Vehicle System Saving - by CJoao - 05.10.2017, 21:26
Re: [Help] MySQL Vehicle System Saving - by oMa37 - 05.10.2017, 22:56

Forum Jump:


Users browsing this thread: 1 Guest(s)