SA-MP Forums Archive
Problem (carhealth=0) [Rep++] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem (carhealth=0) [Rep++] (/showthread.php?tid=332539)



Problem (carhealth=0) [Rep++] - HondaCBR - 08.04.2012

Im using a car system on my server and when you leave the server I want all cars of yours to get updated on carhealth etc and then get destroyed.

OnPlayerDisconnect
pawn Код:
new CarFile2[35];
    format(CarFile2,sizeof(CarFile2),"Auta/%d.ini",PlayerInfo[playerid][pCarKey1]);
    if(dini_Int(CarFile2,"Spawned") == 1)
    {
        new Float:health;
        new Damage[4];
        GetVehicleHealth(Car[playerid][VehicleGameID],health);
        GetVehicleDamageStatus(Car[playerid][VehicleGameID],Damage[0],Damage[1],Damage[2],Damage[3]);
        dini_FloatSet(Car[playerid][Dini],"Health",health);
        dini_IntSet(Car[playerid][Dini],"Panels",Damage[0]);
        dini_IntSet(Car[playerid][Dini],"Doors",Damage[1]);
        dini_IntSet(Car[playerid][Dini],"Lights",Damage[2]);
        dini_IntSet(Car[playerid][Dini],"Tires",Damage[3]);
        DestroyVehicle(Car[playerid][VehicleGameID]);
    //  Car[playerid][UID]               =  0;
//      Car[playerid][VehicleGameID]     =  0;
//      Car[playerid][Spawned]           =  false;
//      dini_IntSet(Car[playerid][Dini],"Spawned",0);
    }
    new CarFile[35];
    format(CarFile,sizeof(CarFile),"Auta/%d.ini",PlayerInfo[playerid][pCarKey2]);
    if(dini_Int(CarFile,"Spawned") == 1)
    {
        new Float:health;
        new Damage[4];
        GetVehicleHealth(Car[playerid][VehicleGameID],health);
        GetVehicleDamageStatus(Car[playerid][VehicleGameID],Damage[0],Damage[1],Damage[2],Damage[3]);
        dini_FloatSet(Car[playerid][Dini],"Health",health);
        dini_IntSet(Car[playerid][Dini],"Panels",Damage[0]);
        dini_IntSet(Car[playerid][Dini],"Doors",Damage[1]);
        dini_IntSet(Car[playerid][Dini],"Lights",Damage[2]);
        dini_IntSet(Car[playerid][Dini],"Tires",Damage[3]);
        DestroyVehicle(Car[playerid][VehicleGameID]);
    //  Car[playerid][UID]               =  0;
    //  Car[playerid][VehicleGameID]     =  0;
    //  Car[playerid][Spawned]           =  false;
    //  dini_IntSet(Car[playerid][Dini],"Spawned",0);
    }
The problem is that the 2nd cars helath goes down to 0.0000 as soon as you disconnect, where the 1st cars health saves properly.

Some of the car system functions:
pawn Код:
enum CarEnum
{
    UID,
    Dini[35],
    VehicleGameID,
    bool:Spawned
};
new Car[MAX_PLAYERS][CarEnum];