OnVehicleCrashWithObject
#1

Is it possible to do?

PHP код:
OnVehicleCrashWithObject(objectidFloatspeedFloatimpactforce
Reply
#2

Yes for the impact force you can do something like:

Код:
new Float: vehHealth, v = GetPlayerVehicleID(playerid);
GetVehicleHealth(GetPlayerVehicleID(playerid), vehHealth);
new Float: force = CarHealth[playerid] - vehHealth;
It will automatically take the damage from the speed since in SA-MP cars take damage according to how fast you go, you don't really need to do anything for that.

As far as the object ID part, I don't really think you can get that as far as I know.
Reply
#3

I want to check the impact force.

I would do something like this.

PHP код:
if(impactforce == 100)
{
SetPlayerHealth(playerid10); 
I want to check that, when a player is on a vehicle, His health will decrease according to the speed and the impact force.
Reply
#4

Try this

PHP код:
new FloatCarHealth[MAX_PLAYERS];
GetVehicleSpeed(v)
{
    new 
FloatvehiclesVelocity[3];
    
GetVehicleVelocity(vvehiclesVelocity[0], vehiclesVelocity[1], vehiclesVelocity[2]);
    return 
floatround(floatsqroot((vehiclesVelocity[0]*vehiclesVelocity[0]+vehiclesVelocity[1]*vehiclesVelocity[1]))*100.0*1.6);
}
if(
IsPlayerInAnyVehicle(playerid))
{
    new 
FloatvehHealthGetPlayerVehicleID(playerid);
    
GetVehicleHealth(GetPlayerVehicleID(playerid), vehHealth);
    if(
vehHealth 250)
    {
        new 
Floatdif CarHealth[playerid] - vehHealth;
        if(
dif 150)
        {
            new 
FloatcurHealth;
            
GetPlayerHealth(playeridcurHealth);
        }
        
CarHealth[playerid] = vehHealth;
    }

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)