SA-MP Forums Archive
Vehicle crash sytem - 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: Vehicle crash sytem (/showthread.php?tid=445339)



Vehicle crash sytem - NewLifeRoleplay - 20.06.2013

How do i make it so when a vehicle crashes the player driving loses -1% health?


Re: Vehicle crash sytem - Scenario - 20.06.2013

If you ask me, the only logical way to detect this is to check for drastic changes in the vehicle's speed. For example, if the vehicle is going 100 and then suddenly drops to 30, it hit something pretty hard.

You might want to make sure it isn't because they hit the reverse key (default is S), or the handbrake (spacebar).

EDIT: I didn't even know there was a function such as OnVehicleDamageStatusUpdate. Holy fucking shit!


Re: Vehicle crash sytem - SwisherSweet - 20.06.2013

Код:
new Float:HP;
GetVehicleHealth(vehicleid, HP);
SetPlayerHealth(playerid, HP / 10);
Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)///when a vehicle is damage
{
      new Float:vehHealth;
    new Float:vehHealth;// we crate a new var (type Float value 0.0)
    vehHealth = GetVehicleHealth(vehicleid, vehHealth);//we get the vehicle damaged health and store the returned value in vehHealth(value returned e.g: 95.2)
    SetPlayerHealth(playerid, vehHealth1);// we set the playerhealth at the value of vehHealth(value of VehHealth after passed in this function e.g : 95)
 /*
 NB: SetPlayerHealth() automaticaly transform vehHealth (Float) in an integer value
 */
}
This was not made from made i took it from another tread.


Re: Vehicle crash sytem - jakejohnsonusa - 21.06.2013

You can also use a great include called OnPlayerVehicleDamage, it detects when a player damages a vehicle (as the name implies).

So it would be like:
pawn Код:
#include <OPVD>

public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    SetPlayerHealth(playerid, health-1)
    return 1;
}



Re: Vehicle crash sytem - Sasino97 - 21.06.2013

Quote:
Originally Posted by Aveger
Посмотреть сообщение
Код:
new Float:HP;
GetVehicleHealth(vehicleid, HP);
SetPlayerHealth(playerid, HP / 10);
Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)///when a vehicle is damage
{
      new Float:vehHealth;
    new Float:vehHealth;// we crate a new var (type Float value 0.0)
    vehHealth = GetVehicleHealth(vehicleid, vehHealth);//we get the vehicle damaged health and store the returned value in vehHealth(value returned e.g: 95.2)
    SetPlayerHealth(playerid, vehHealth1);// we set the playerhealth at the value of vehHealth(value of VehHealth after passed in this function e.g : 95)
 /*
 NB: SetPlayerHealth() automaticaly transform vehHealth (Float) in an integer value
 */
}
This was not made from made i took it from another tread.
This will work bad, because vehicle health goes from 0 to 1000, and player's health from 0 to 100, and you are setting player's health to vehicle's health.

Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
You can also use a great include called OnPlayerVehicleDamage, it detects when a player damages a vehicle (as the name implies).

So it would be like:
pawn Код:
#include <OPVD>

public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    SetPlayerHealth(playerid, health-1)
    return 1;
}
This should work fine instead.