Squirrel/Client/Events/Player/onClientHurt
From Liberty Unleashed Wiki
(Difference between revisions)
m (Err... whoops) |
(Added an example.) |
||
Line 19: | Line 19: | ||
== Example == | == Example == | ||
− | + | This example makes you invincible if you're called 'Bob' (does not apply to damage taken from other players). | |
− | + | ||
− | + | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | + | function onClientHurt(entity) | |
+ | { | ||
+ | // Get the local player | ||
+ | local player = FindLocalPlayer(); | ||
+ | if(player) | ||
+ | { | ||
+ | // Check if they're called "Bob" | ||
+ | local name = player.Name; | ||
+ | if(name == "Bob") | ||
+ | { | ||
+ | // Cancel the damage | ||
+ | return 0; | ||
+ | } | ||
+ | } | ||
+ | } | ||
</code> | </code> | ||
Latest revision as of 00:16, 27 September 2011
This event is called when the local player gets hurt.
Note: This does not fire when the player gets shot. Use onClientShot instead.
[edit] Syntax
function onClientHurt( entity )
[edit] Arguments
- entity - The pointer to the entity that hurt the player. Either vehicle or null
[edit] Returns
- 1 - Let the player be hurt normally
- 0 - Stops the player being hurt
[edit] Example
This example makes you invincible if you're called 'Bob' (does not apply to damage taken from other players).
function onClientHurt(entity) { // Get the local player local player = FindLocalPlayer(); if(player) { // Check if they're called "Bob" local name = player.Name; if(name == "Bob") { // Cancel the damage return 0; } } }
[edit] Notes
-- List of used functions and other notes here.
[edit] Related Events
- onClientArmourChange
- onClientCashChange
- onClientCollideWithPlayer
- onClientCommand
- onClientDeath
- onClientFall
- onClientHealthChange
- onClientHurt
- onClientKill
- onClientKeyStateChange
- onClientRequestClass
- onClientRequestSpawn
- onClientShot
- onClientSpawn
- onClientUseDetonator
- onClientWeaponChange
- onPlayerDeath
- onPlayerJoin
- onPlayerKill
- onPlayerPart
- onPlayerSpawn