SA-MP Forums Archive
Preventing car explosion - 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: Preventing car explosion (/showthread.php?tid=303027)



Preventing car explosion - xGoldenx - 11.12.2011

Hello.
How can I prevent car from exploding? I just want to turn it's engine off when car's health is low (without exploding).

Is it possible?


Re: Preventing car explosion - THE_KNOWN - 11.12.2011

if you have a speedo, put
pawn Code:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
new panels, tires;
    GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
    bonnet = doors & 0x7;
    if(bonnet == 3)
    {
          SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
return 1;
}
will stop engine when bonnet comes off. modify it check its health. if its lower than 500 turn it off.


Re: Preventing car explosion - xGoldenx - 11.12.2011

Ok, but with how much health car explodes? 0?


Re: Preventing car explosion - THE_KNOWN - 11.12.2011

nah somewhere arounf 400's u better keep the check at 500


Re: Preventing car explosion - xGoldenx - 11.12.2011

Sorry, but I still don't know how to do it.

Can somebody explain it? I don't understand all these vehiclehealth functions.


Re: Preventing car explosion - THE_KNOWN - 11.12.2011

pawn Code:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    new Float:h;
    GetVehicleHealth(vehicleid,h);
    if(h < 500)
    {
        SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,-1,-1,-1,-1,-1,-1);
    }
    return 1;
}



Re: Preventing car explosion - AeroBlast - 11.12.2011

pawn Code:
public OnVehicleDamageStatusUpdate(vehicleid, playerid) //Get called every time a vehicle health changes (I think)
{
    new Float:health; //Creating a variable for the car's health
    GetVehicleHealth(vehicleid,health); //Storing the actual health of the vehicle in the variable
    if(health < 400.0) //Checkin if the health is lower than 400.0 (1000.0 is the max, somewhere around 400.0, it catches fire)
    {
        new engine, lights, alarm, doors, bonnet, boot, objective; //Creating variable's for the vehicle's parameters (doors, bonnet, engine, etc)
        GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); //Getting the vehicle's parameters)
        SetVehicleParamsEx(vehicleid, 0, 0, 0, doors, bonnet, boot, objective); //Turning off the engine
        return 1;
    }
    return 1;
}
Hope I helped =D


Re: Preventing car explosion - [LHT]Bally - 11.12.2011

i used that and when my car was refixed the enine didnt switch back on


Re: Preventing car explosion - wildcookie007 - 11.12.2011

Using damagestatusupdate is wrong for detecting its health because it only detects when some kind of part of the vehicle is damaged so using the callback is not the best way.


Re: Preventing car explosion - THE_KNOWN - 11.12.2011

Quote:
Originally Posted by [LHT]Bally
View Post
i used that and when my car was refixed the enine didnt switch back on
did you increase its health enough so that it wont switch off again?