Squirrel/Client/Events/Player/onClientShot

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example)
(Example)
 
Line 21: Line 21:
 
This example makes you invincible if you're called 'Bob' (does not apply to damage taken from other players).
 
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)
+
function onClientShot( player, weapon, bodypart )
 
{
 
{
 
// Get the local player
 
// Get the local player

Latest revision as of 21:03, 11 November 2013

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This event is called when the local player gets shot.

[edit] Syntax

  1. function onClientShot( player, weapon, bodypart )

[edit] Arguments

  • player - The pointer to the player that hurt the local player
  • weapon - The weapon used
  • bodypart - The bodypart that was hit

[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).

  1.  
  2. function onClientShot( player, weapon, bodypart )
  3. {
  4. // Get the local player
  5. local player = FindLocalPlayer();
  6. if(player)
  7. {
  8. // Check if they're called "Bob"
  9. local name = player.Name;
  10. if(name == "Bob")
  11. {
  12. // Cancel the damage
  13. return 0;
  14. }
  15. }
  16. }
  17.  

[edit] Notes

-- List of used functions and other notes here.

[edit] Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox