Squirrel/Server/Events/Vehicle/onVehicleUpdate

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|onVehicleUpdate}} {{Warning|This event can be called multiple times per second for any occupied or unoccupied vehicles. It is not recommended to run any heavy co…')
 
m (Correct category for related events)
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 
{{Squirrel/Title|onVehicleUpdate}}
 
{{Squirrel/Title|onVehicleUpdate}}
 +
{{ScriptingChangesIn0.1.0.9}}
 
{{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.}}
 
{{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.
 
This event is called every time a vehicle sync packet (player is driving a vehicle or unoccupied sync) is received.
Line 38: Line 39:
 
== Related Events ==
 
== Related Events ==
  
{{Squirrel/Server/Events/Player}}
+
{{Squirrel/Server/Events/Vehicle}}

Latest revision as of 01:38, 15 April 2011

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.

[edit] Syntax

  1. function onVehicleUpdate( Vehicle vehicle, Player trigger )

[edit] 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)

[edit] Returns

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

[edit] 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.  

[edit] Notes

The functions MessagePlayer, GetVehicleName and Vehicle.Model 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