OnClientObjectDamage: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Client event}} This event is fired before an object gets damaged. Also note that this event is only triggered for players nearby the local player's camera. This is du...") |
(Added "attacker" parameter) |
||
Line 4: | Line 4: | ||
==Parameters== | ==Parameters== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
float loss | float loss, element attacker | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''loss:''' the health loss caused by the damage. This parameter contains the theoretical loss, which could be less than 0, if you substract it of the current health. If you want to get the real loss, you have to substract the new health of the old health (use a timer for this). | *'''loss:''' the health loss caused by the damage. This parameter contains the theoretical loss, which could be less than 0, if you substract it of the current health. If you want to get the real loss, you have to substract the new health of the old health (use a timer for this). | ||
*'''attacker:''' the vehicle/ped/player who is damaging the object | |||
==Source== | ==Source== |
Revision as of 11:51, 16 January 2013
This event is fired before an object gets damaged. Also note that this event is only triggered for players nearby the local player's camera. This is due to elements far away being streamed out.
Parameters
float loss, element attacker
- loss: the health loss caused by the damage. This parameter contains the theoretical loss, which could be less than 0, if you substract it of the current health. If you want to get the real loss, you have to substract the new health of the old health (use a timer for this).
- attacker: the vehicle/ped/player who is damaging the object
Source
The source of this event is the object which was damaged
Cancel effect
If this event is canceled, the object will not be damaged.
Example
Click to collapse [-]
ClientThis example outputs the theoretical and real loss.
function outputLoss(loss) local oldHealth = getElementHealth(source) setTimer(function() local newHealth = getElementHealth(source) outputChatBox("Real loss: "..(newHealth-oldHealth)) outputChatBox("Theoretical loss: "..loss) end) end addEventHandler("onClientObjectDamage", root, outputLoss)
Requirements
This template will be deleted.
See Also
Client object events
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled