OnClientVehicleCollision: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Cazomino05 (talk | contribs) mNo edit summary |
||
Line 14: | Line 14: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | |||
addEventHandler("onClientVehicleCollision", getRootElement(), | |||
function(collider,force, bodyPart, x, y, z, vx, vy, vz) | |||
-- force does not take into account the collision damage multiplier (this is what makes heavy vehicles take less damage than banshees for instance) so take that into account to get the damage delt | |||
local fDamageMultiplier = getVehicleHandling(source).collisionDamageMultiplier | |||
-- Create a marker (this will be sized roughly the amount of damage done by each hit) | |||
local m = createMarker(x, y, z, "corona", force * fDamageMultiplier, 0, 9, 231) | |||
-- Destroy the marker in 2 seconds | |||
setTimer(destroyElement, 2000, 1, m) | |||
end | |||
) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== |
Revision as of 09:50, 11 January 2012
Added in MTA SA 1.3
This event is triggered when a vehicle collides with something.
Parameters
collidedWith, force, bodyPart, collisionX, collisionY, collisionZ, velocityX, velocityY, velocityZ
Source
The source of this event is the vehicle that collided with something.
Example
addEventHandler("onClientVehicleCollision", getRootElement(), function(collider,force, bodyPart, x, y, z, vx, vy, vz) -- force does not take into account the collision damage multiplier (this is what makes heavy vehicles take less damage than banshees for instance) so take that into account to get the damage delt local fDamageMultiplier = getVehicleHandling(source).collisionDamageMultiplier -- Create a marker (this will be sized roughly the amount of damage done by each hit) local m = createMarker(x, y, z, "corona", force * fDamageMultiplier, 0, 9, 231) -- Destroy the marker in 2 seconds setTimer(destroyElement, 2000, 1, m) end )
See Also
Client vehicle events
- onClientTrailerAttach
- onClientTrailerDetach
- onClientVehicleCollision
- onClientVehicleDamage
- onClientVehicleEnter
- onClientVehicleExit
- onClientVehicleExplode
- onClientVehicleNitroStateChange
- onClientVehicleRespawn
- onClientVehicleStartEnter
- onClientVehicleStartExit
- onClientVehicleWeaponHit
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled