16.05.2010, 18:26
If so how?
new WasDamaged[MAX_VEHICLES];
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
WasDamaged[vehicleid-1] = 1; //because vehicleids start with 1 and end with MAX_VEHICLES and not before that
for (new id = 0; id < MAX_VEHICLES; id++)
{
if (id == vehicleid-1) continue;
if (WasDamaged[id] == 1)
{
new Float:x, Float:y, Float:z;
GetVehiclePos(id+1, x, y, z);
if (IsVehicleInRangeOfPoint(vehicleid, 1.0, x, y, z))
{
printf("Vehicle with ID: %d crashed/was crashed by vehicle with ID: %d", vehicleid, id+1);
}
}
}
SetTimerEx("Reset", 1000, 0, "d", vehicleid);
return 1;
}
forward Reset(vehicleid);
public Reset(vehicleid) WasDamaged[vehicleid-1] = 0;
IsVehicleInRangeOfPoint(vehicleid, Float:range, Float:x, Float:y, Float:z)
{
new Float:px, Float:py, Float:pz;
GetVehiclePos(vehicleid, px, py, pz);
px -= x; py -= y; pz -= z;
return ((px * px) + (py * py) + (pz * pz)) < (range * range);
}
public OnVehicleDamageStatusUpdate(vehicleid, playerid) { new string[128]; format(string,sizeof(string),"Vehicle ID %d damaged by playerid %d.",vehicleid,playerid); return 1; }
When two vehicles collide? |
when someone shoots the car, it loses health, but the driver caused the damge. cant be real. i tried to do an accurate solution, but i am stuck at this too. |
Originally Posted by juice.j
Quote:
When two vehicles collide they must be very close to each other. Check the range of distances between two vehicles when they are directly next to each other by doing some tests. As soon as a two vehicles crash into each other you just check upon OnVehicleDamageStatusUpdate whether a vehicle is in direct contact. To improve inappropriate triggers you can additionally check for damages on the possibly detected nearby vehicle, connect it to timestamps or whatsoever. |