onVehicleUpdate

From Liberty Unleashed Wiki
Revision as of 02:38, 15 April 2011 by Juppi (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events
LU Warning: This event can be called multiple times per second for any occupied or unoccupied vehicles. It is not recommended to run any heavy code under this.

This event is called every time a vehicle sync packet (player is driving a vehicle or unoccupied sync) is received.

Syntax

  1. function onVehicleUpdate( Vehicle vehicle, Player trigger )

Arguments

  • vehicle - Vehicle which was updated
  • trigger - The player who triggered this event (either the vehicle driver or the player who moved an unoccupied vehicle)

Returns

  • 1 - This sync packet will be transmitted to other clients normally
  • 0 - Do not broadcast this sync packet to other clients

Example

This example will message the player if they move an unoccupied vehicle.

  1.  
  2. function onVehicleUpdate( vehicle, player )
  3. {
  4. // Check that the vehicle has no driver
  5. if ( vehicle.Driver ) return 1;
  6. MessagePlayer( "Nice one you scratched the paint of that " + GetVehicleName( vehicle.Model ), player );
  7. return 1;
  8. }
  9.  

Notes

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

Related Events

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox