Squirrel/Client/Events/Vehicle/onClientVehicleShot

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Notes)
(Example)
 
Line 18: Line 18:
 
== Example ==
 
== Example ==
  
This example will show a message to the player indicating which player shot what car and with what weapon.  
+
This example will show a message to the client indicating which player shot his vehicle and with what weapon.  
  
 
<code lang="squirrel">
 
<code lang="squirrel">
 
function onClientVehicleShot( vehicle, player, weapon )
 
function onClientVehicleShot( vehicle, player, weapon )
 
{
 
{
Message(player.Name + " shot a " + GetVehicleName( vehicle ) + " with a " + GetWeaponName( weapon ) );
+
Message(player.Name + " shot your " + GetVehicleName( vehicle ) + " with a " + GetWeaponName( weapon ) );
 
}
 
}
  

Latest revision as of 22:39, 16 November 2016

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

This is called when a vehicle is shot.

[edit] Syntax

  1. function onClientVehicleShot( Vehicle vehicle, Player player, int weapon )

[edit] Arguments

  • vehicle - The vehicle that was shot
  • player - The player that shot the vehicle.
  • weapon - ID representing the type of weapon used to shoot the vehicle

[edit] Returns

This event does not handle return values.

[edit] Example

This example will show a message to the client indicating which player shot his vehicle and with what weapon.

  1.  
  2. function onClientVehicleShot( vehicle, player, weapon )
  3. {
  4. Message(player.Name + " shot your " + GetVehicleName( vehicle ) + " with a " + GetWeaponName( weapon ) );
  5. }
  6.  
  7.  

[edit] Notes

  • Only gets triggered when the client is in a vehicle and is getting shot at by another player
  • Molotovs and flamethrower both return a weapon ID of 9.
  • Grenades and RPG return an ID 18

The functions GetVehicleName and GetWeaponName were used in this example. More info about them can be found in the corresponding pages.

[edit] Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox