OnVehicleDeath
#5

Using ColAndreas in this case will be more accurate.

Code:
public OnVehicleDeath(vehicleid, killerid)
{
	new Float:health, Float:depth, Float:vehicledepth;
	GetVehicleHealth(vehicleid, health);
	if(health >= 250.0 && !CA_IsVehicleInWater(vehicleid, depth, vehicledepth))
	{
		return 0; // we prevent respawn
	}
	return 1;
}
Code:
stock CA_IsVehicleInWater(vehicleid, &Float:depth, &Float:vehicledepth)
{
	new Float:x, Float:y, Float:z, Float:retx[10], Float:rety[10], Float:retz[10], Float:retdist[10], modelids[10];
	GetVehiclePos(vehicleid, x, y, z);
	new collisions = CA_RayCastMultiLine(x, y, z + 1000.0, x, y, z - 1000.0, retx, rety, retz, retdist, modelids, 10);
	if(collisions)
	{
		for(new i = 0; i < collisions; i++)
		{
			if(modelids[i] == WATER_OBJECT)
			{
				depth = INFINITY;

				for(new j = 0; j < collisions; j++)
				{
					if(retz[j] < depth)
					depth = retz[j];
				}

				depth = retz[i] - depth;
				if(depth < 0.001 && depth > -0.001)
				depth = 100.0;
				vehicledepth = retz[i] - z;

				if(vehicledepth < -2.0)
				return 0;

				return 1;
			}
		}
	}
	return 0;
}
Reply


Messages In This Thread
OnVehicleDeath - by Romz - 05.12.2017, 07:12
Re: OnVehicleDeath - by BeckzyBoi - 05.12.2017, 07:23
Re: OnVehicleDeath - by Romz - 05.12.2017, 07:26
Re: OnVehicleDeath - by BeckzyBoi - 05.12.2017, 07:29
Re: OnVehicleDeath - by Romz - 05.12.2017, 07:30
Re: OnVehicleDeath - by BeckzyBoi - 05.12.2017, 07:33
Re: OnVehicleDeath - by Romz - 05.12.2017, 07:35
Re: OnVehicleDeath - by Romz - 05.12.2017, 07:54
Re: OnVehicleDeath - by Jelly23 - 05.12.2017, 08:01
Re: OnVehicleDeath - by Romz - 05.12.2017, 08:59
Re: OnVehicleDeath - by Locky_ - 05.12.2017, 10:02
Re: OnVehicleDeath - by Romz - 05.12.2017, 10:07
Re: OnVehicleDeath - by Locky_ - 05.12.2017, 10:10
Re: OnVehicleDeath - by Romz - 05.12.2017, 10:31
Re: OnVehicleDeath - by stabker - 05.12.2017, 10:40

Forum Jump:


Users browsing this thread: 3 Guest(s)