- Documentation
- Client events
- onClientVehicleCollision
Event
onClientVehicleCollision
The vehicle this player drives hit something (a sudden change of speed, at least 2.5 m/s in one frame). Teleports and setElementVelocity from scripts do not count.
Handler
addEventHandler("onClientVehicleCollision", root, function(theHitElement, force, bodyPart, collisionX, collisionY, collisionZ, normalX, normalY, normalZ, hitElementForce, model) ... end)Parameters
theHitElementelement- The element hit, or
false(wall, ground, building). forcefloat- Impact force: change of speed × mass / 50.
bodyPartint- Always
0. collisionX, collisionY, collisionZfloat- Impact point.
normalX, normalY, normalZfloat- Surface normal.
hitElementForcefloat- Speed of the element hit (m/s).
modelint- Model of the element hit, or
0.
Source
source is the vehicle.
Example
addEventHandler("onClientVehicleCollision", root, function(hit, force)
if force > 500 then playSoundFrontEnd(4) end
end)
See also
onClientVehicleDamageA vehicle lost health in your game: from a crash, gunfire, an explosion, fire or a health change from a script. It covers every vehicle your game knows, including other players' cars. The game checks vehicle health 10 times per second and only while some script listens to this event; several quick hits in that time arrive as one loss.getElementVelocityReturns the element's velocity. Units: 1 is 50 m/s, so km/h is the vector length times 180.