Vehicle crash sytem
#1

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

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!
Reply
#3

Код:
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.
Reply
#4

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;
}
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)