Squirrel/Client/Events/Player/onClientShot
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with '{{Squirrel/Title|onClientShot}} This event is called when the local player gets shot. == Syntax == <code>function onClientShot( player, weapon, bodypart )</code> === Arguments…') |
(→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> | ||
Revision as of 21:03, 11 November 2013
This event is called when the local player gets shot.
Syntax
function onClientShot( player, weapon, bodypart )
Arguments
- player - The pointer to the player that hurt the local player
- weapon - The weapon used
- bodypart - The bodypart that was hit
Returns
- 1 - Let the player be hurt normally
- 0 - Stops the player being hurt
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; } } }
Notes
-- List of used functions and other notes here.
Related Events
- onClientArmourChange
- onClientCashChange
- onClientCollideWithPlayer
- onClientCommand
- onClientDeath
- onClientFall
- onClientHealthChange
- onClientHurt
- onClientKill
- onClientKeyStateChange
- onClientRequestClass
- onClientRequestSpawn
- onClientShot
- onClientSpawn
- onClientUseDetonator
- onClientWeaponChange
- onPlayerDeath
- onPlayerJoin
- onPlayerKill
- onPlayerPart
- onPlayerSpawn