OnPlayerDamage: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Event|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|OnPlayerDamage}} {{FuncParameters}} == Example == __EDIT_ME__ {{RelatedFunctions}} {{ServerEvents}}"
 
Chloe (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Info|Event|Server|1.0}}
{{Info|Event|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Event thats called when player receives damage.}}


{{FuncSyntax|OnPlayerDamage}}
{{FuncSyntax|OnPlayerDamage(player, damagetype, amount)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|player|The player who is being damaged.}}
{{FuncParam|damagetype|[[DamageType|Type]] of damage applied.}}
{{FuncParam|amount|Amount of damage applied.}}
== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
function OnPlayerDamage(player, damagetype, amount)
local DamageName = {
"Weapon",
"Explosion",
"Fire",
"Fall",
"Vehicle Collision"
}
 
print(GetPlayerName(player).."("..player..") took "..amount.." damage of type "..DamageName[damagetype])
end
AddEvent("OnPlayerDamage", OnPlayerDamage)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{ServerEvents}}
{{PlayerServerEvents}}

Latest revision as of 08:05, 16 January 2020

OnPlayerDamage

Type: Event
Context: Server
Introduced: v1.0

Description

Event thats called when player receives damage.

Syntax

OnPlayerDamage(player, damagetype, amount)

Parameters

  • player
    The player who is being damaged.
  • damagetype
    Type of damage applied.
  • amount
    Amount of damage applied.

Example

function OnPlayerDamage(player, damagetype, amount)
	local DamageName = {
		"Weapon",
		"Explosion",
		"Fire",
		"Fall",
		"Vehicle Collision"
	}

	print(GetPlayerName(player).."("..player..") took "..amount.." damage of type "..DamageName[damagetype])
end
AddEvent("OnPlayerDamage", OnPlayerDamage)

See also