OnClientPlayerWasted: Difference between revisions
Jump to navigation
Jump to search
(Added stealth parameter) |
(Add beta header) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
==Parameters== | ==Parameters== | ||
{{New feature/item|3.0161|1.6.0|22620| | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
element killer, int weapon, int bodypart, bool stealth, int animGroup, int animID | |||
</syntaxhighlight> | |||
}} | |||
{{Deprecated_feature|3|1.0|<syntaxhighlight lang="lua"> | |||
element killer, int weapon, int bodypart, bool stealth | element killer, int weapon, int bodypart, bool stealth | ||
</syntaxhighlight> | </syntaxhighlight>}} | ||
*'''killer''': A [[player]] [[element]] representing the killer. | *'''killer''': A [[player]], [[ped]] or [[vehicle]] [[element]] representing the killer. | ||
*'''weapon''': An [[int|integer]] representing the [[Weapons|killer weapon]] or the [[Damage Types|damage types]]. | *'''weapon''': An [[int|integer]] representing the [[Weapons|killer weapon]] or the [[Damage Types|damage types]]. | ||
*'''bodypart''': An [[int|integer]] representing the bodypart the player was damaged. | *'''bodypart''': An [[int|integer]] representing the bodypart the player was damaged. | ||
{{BodyParts}} | {{BodyParts}} | ||
*'''stealth''': A [[boolean]] representing whether or not this was a stealth kill. | *'''stealth''': A [[boolean]] representing whether or not this was a stealth kill. | ||
{{New feature/item|3.0161|1.6.0|22620| | |||
*'''animGroup''': an [[int|integer]] representing the player's current animation group. | |||
}} | |||
{{New feature/item|3.0161|1.6.0|22620| | |||
*'''animID''': an [[int|integer]] representing the player's current animation ID. | |||
}} | |||
==Source== | ==Source== | ||
Line 20: | Line 32: | ||
This example outputs a mocking message when the local player dies. | This example outputs a mocking message when the local player dies. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
messages = { | local messages = { | ||
"Better luck next time", | "Better luck next time", | ||
"Don't think you're so cool now, do you?", | "Don't think you're so cool now, do you?", | ||
"Nice one, pal", | "Nice one, pal", | ||
"Your opinion is void" | "Your opinion is void" | ||
} | } | ||
function | -- add an event for the local player only | ||
local | addEventHandler("onClientPlayerWasted", localPlayer, function(killer, weapon, bodyPart) | ||
local randomMessage = messages[math.random(#messages)] -- get a random message from the table | |||
outputChatBox ( randomMessage, 255, 0, 0 ) --output the message | outputChatBox(randomMessage, 255, 0, 0) -- output the message | ||
end | end) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 21:03, 15 July 2024
This event is triggered whenever a player, including those remote, dies.
Parameters
- killer: A player, ped or vehicle element representing the killer.
- weapon: An integer representing the killer weapon or the damage types.
- bodypart: An integer representing the bodypart the player was damaged.
- 3: Torso
- 4: Ass
- 5: Left Arm
- 6: Right Arm
- 7: Left Leg
- 8: Right Leg
- 9: Head
- stealth: A boolean representing whether or not this was a stealth kill.
Source
The source of this event is the player that died.
Example
This example outputs a mocking message when the local player dies.
local messages = { "Better luck next time", "Don't think you're so cool now, do you?", "Nice one, pal", "Your opinion is void" } -- add an event for the local player only addEventHandler("onClientPlayerWasted", localPlayer, function(killer, weapon, bodyPart) local randomMessage = messages[math.random(#messages)] -- get a random message from the table outputChatBox(randomMessage, 255, 0, 0) -- output the message end)
See Also
Client player events
- onClientPlayerChangeNick
- onClientPlayerChoke
- onClientPlayerDamage
- onClientPlayerHeliKilled
- onClientPlayerHitByWaterCannon
- onClientPlayerJoin
- onClientPlayerPickupHit
- onClientPlayerPickupLeave
- onClientPlayerQuit
- onClientPlayerRadioSwitch
- onClientPlayerSpawn
- onClientPlayerStealthKill
- onClientPlayerStuntFinish
- onClientPlayerStuntStart
- onClientPlayerTarget
- onClientPlayerVehicleEnter
- onClientPlayerVehicleExit
- onClientPlayerVoicePause
- onClientPlayerVoiceResumed
- onClientPlayerVoiceStart
- onClientPlayerVoiceStop
- onClientPlayerWasted
- onClientPlayerWeaponFire
- onClientPlayerWeaponSwitch
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled