OnVehicleCrashWithObject - 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: OnVehicleCrashWithObject (
/showthread.php?tid=407139)
OnVehicleCrashWithObject -
Magic_Time - 12.01.2013
Is it possible to do?
PHP код:
OnVehicleCrashWithObject(objectid, Float: speed, Float: impactforce)
Re: OnVehicleCrashWithObject -
mrtms - 12.01.2013
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.
Re: OnVehicleCrashWithObject -
Magic_Time - 12.01.2013
I want to check the impact force.
I would do something like this.
PHP код:
if(impactforce == 100)
{
SetPlayerHealth(playerid, 10);
I want to check that, when a player is on a vehicle, His health will decrease according to the speed and the impact force.
Re: OnVehicleCrashWithObject -
mrtms - 12.01.2013
Try this
PHP код:
new Float: CarHealth[MAX_PLAYERS];
GetVehicleSpeed(v)
{
new Float: vehiclesVelocity[3];
GetVehicleVelocity(v, vehiclesVelocity[0], vehiclesVelocity[1], vehiclesVelocity[2]);
return floatround(floatsqroot((vehiclesVelocity[0]*vehiclesVelocity[0]+vehiclesVelocity[1]*vehiclesVelocity[1]))*100.0*1.6);
}
if(IsPlayerInAnyVehicle(playerid))
{
new Float: vehHealth, v = GetPlayerVehicleID(playerid);
GetVehicleHealth(GetPlayerVehicleID(playerid), vehHealth);
if(vehHealth > 250)
{
new Float: dif = CarHealth[playerid] - vehHealth;
if(dif > 150)
{
new Float: curHealth;
GetPlayerHealth(playerid, curHealth);
}
CarHealth[playerid] = vehHealth;
}
}