OnClientPlayerWasted: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (Using predefined variables in "Example" code)
 
(8 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:Incomplete Event]]
__NOTOC__
{{Client event}}
This event is triggered whenever a player, including those remote, dies.


__NOTOC__
==Parameters==
This event is blahblah and is used for blahblah.
 
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
void onClientPlayerWasted ( void )
element killer, int weapon, int bodypart, bool stealth
</syntaxhighlight>  
</syntaxhighlight>  
*'''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]].
*'''bodypart''': An [[int|integer]] representing the bodypart the player was damaged.
{{BodyParts}}
*'''stealth''': A [[boolean]] representing whether or not this was a stealth kill.
==Source==
The [[event system#Event source|source]] of this event is the [[player]] that died.


==Example==  
==Example==  
This example does...
This example outputs a mocking message when the local player dies.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
local messages = {
blabhalbalhb --abababa
"Better luck next time",
--This line does this...
"Don't think you're so cool now, do you?",
mooo
"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)
</syntaxhighlight>
</syntaxhighlight>
==See Also==
===Client player events===
{{Client_player_events}}
===Client event functions===
{{Client_event_functions}}

Latest revision as of 11:22, 27 June 2023

This event is triggered whenever a player, including those remote, dies.

Parameters

element killer, int weapon, int bodypart, bool stealth
  • 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


Client event functions

Shared