onGlassSmash

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events


This event is called when somebody smashes a glass window in game.

Syntax

  1. function onGlassSmash( damage, x, y, z, hitx, hity, hitz, explosion )

Arguments

  • damage - How much damage was done to the window
  • x - Originating X position Unsure
  • x - Originating Y position Unsure
  • x - Originating Z position Unsure
  • hitx - The X position on the glass of where it was hit
  • hity - The Y position on the glass of where it was hit
  • hitz - The Z position on the glass of where it was hit
  • explosion - Was it an explosion that smashed the window

Returns

  • 1 - Let the window smash normally
  • 0 - Returning 0 stops the window smashing

Example

This will hurt the player when they stand too close near shattering glass.

  1.  
  2. function onGlassSmash( damage, x, y, z, hitx, hity, hitz, explosion )
  3. {
  4. local pPlayer = FindLocalPlayer();
  5. if ( pPlayer )
  6. {
  7. if ( GetDistance( pPlayer.Pos, Vector( hitx, hity, hitz ) ) <= 20 )
  8. {
  9. pPlayer.Health -= 10;
  10. Message("Ouch!", Colour(255,0,0));
  11. }
  12. }
  13. }
  14.  

Notes

The functions FindLocalPlayer, GetDistance and Message were used in in this example. More info about them in corresponding pages.

Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox