OnPlayerDeath: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Event|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|OnPlayerDeath}} {{FuncParameters}} == Example == __EDIT_ME__ {{RelatedFunctions}} {{ServerEvents}}" |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Event|Server|1.0}} | {{Info|Event|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Calls when a player dies by any means possible. If the player wasn't killed by another player, instigator will be the same as the player.}} | ||
{{FuncSyntax|OnPlayerDeath}} | {{FuncSyntax|OnPlayerDeath(player, instigator)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|player|The player that has died.}} | |||
{{FuncParam|instigator|The player who is responsible for the death.}} | |||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function OnPlayerDeath(player, instigator) | |||
if player == instigator then | |||
AddPlayerChat(player, '<span color="#ff0000">You have killed yourself.</>') | |||
else | |||
AddPlayerChat(player, '<span color="#ff0000">You were killed by '..GetPlayerName(instigator)..'.</>') | |||
end | |||
end | |||
AddEvent("OnPlayerDeath", OnPlayerDeath) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{ | {{PlayerEvents}} |
Latest revision as of 22:46, 24 January 2020
Description
Calls when a player dies by any means possible. If the player wasn't killed by another player, instigator will be the same as the player.
Syntax
OnPlayerDeath(player, instigator)
Parameters
- player
The player that has died. - instigator
The player who is responsible for the death.
Example
function OnPlayerDeath(player, instigator)
if player == instigator then
AddPlayerChat(player, '<span color="#ff0000">You have killed yourself.</>')
else
AddPlayerChat(player, '<span color="#ff0000">You were killed by '..GetPlayerName(instigator)..'.</>')
end
end
AddEvent("OnPlayerDeath", OnPlayerDeath)
See also
- OnPlayerServerAuth
- OnPlayerSteamAuth
- OnPlayerStreamIn
- OnPlayerStreamOut
- OnPlayerJoin
- OnPlayerQuit
- OnPlayerSpawn
- OnPlayerDeath
- OnPlayerWeaponShot
- OnPlayerDamage
- OnPlayerChat
- OnPlayerChatCommand
- OnPlayerInteractDoor
- OnPlayWeaponHitEffects
- OnPlayerSwitchCamera
- OnPlayerEnterWater
- OnPlayerLeaveWater
- OnPlayerCrouch
- OnPlayerEndCrouch
- OnPlayerEndFall
- OnPlayerFall
- OnPlayerTalking