OnPedDamage: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(Undo revision 81481 by Zeratul97 (talk))
Tag: Undo
 
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Server event}}
{{Server event}}
Ez az esemény akkor indul el amikor egy ped megsérül. Játékos esetén használja az [[onPlayerDamage]] helyette.
This event is triggered when a ped is damaged. For player damage, use [[onPlayerDamage]] instead.
{{Note|This event is not triggered prior to r21247.}}
{{Note|This event is not triggered prior to r21247.}}


Line 7: Line 7:
<syntaxhighlight lang="lua">float loss</syntaxhighlight>
<syntaxhighlight lang="lua">float loss</syntaxhighlight>


*'''loss''': egy [[int]] amely a ped elvesztett egészségi állapotának százalékát jelenti.
*'''loss''': an [[int]] representing the percentage of health the ped lost.


==Source==
==Source==
A [[event system#Event source|source]] ennek az eseménynek a [[ped]] aki megsérült.
The [[event system#Event source|source]] of this event is the [[ped]] that got damaged.


==Cancel Effect==
==Cancel Effect==
Az esemény törlésének nincs hatása. Törölje az kliens-oldali eseményt [[onClientPedDamage]] eseménnyel.
Canceling this event has no effect. Cancel the client-side event [[onClientPedDamage]] instead.


==Example==
==Example==
Ez a példa üzenetet küld a konzolnak, ha egy adott ped sérült.
This example outputs a message to the console when a specific ped is damaged.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local ped1 = createPed(112, 0, 0, 0) -- Létrehoz egy pedet
local ped1 = createPed(112, 0, 0, 0) -- create our ped


function pedDamaged(loss)
function pedDamaged(loss)
     outputConsole("ped1 sérült! veszteség: " .. tostring(loss))
     outputConsole("ped1 damaged! loss: " .. tostring(loss))
end
end


addEventHandler("onPedDamage", ped1, pedDamaged) -- csak akkor aktiválódik, ha a ped1 megsérül
addEventHandler("onPedDamage", ped1, pedDamaged) -- triggered only when ped1 gets damaged
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Ped events}}
{{See also/Server event|Ped events}}

Latest revision as of 14:39, 12 December 2024

This event is triggered when a ped is damaged. For player damage, use onPlayerDamage instead.

[[{{{image}}}|link=|]] Note: This event is not triggered prior to r21247.

Parameters

float loss
  • loss: an int representing the percentage of health the ped lost.

Source

The source of this event is the ped that got damaged.

Cancel Effect

Canceling this event has no effect. Cancel the client-side event onClientPedDamage instead.

Example

This example outputs a message to the console when a specific ped is damaged.

local ped1 = createPed(112, 0, 0, 0) -- create our ped

function pedDamaged(loss)
    outputConsole("ped1 damaged! loss: " .. tostring(loss))
end

addEventHandler("onPedDamage", ped1, pedDamaged) -- triggered only when ped1 gets damaged

See Also

Ped events


Event functions