Squirrel/Server/Functions/Players/Vehicle

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|Vehicle.Health}} This ''Player'' class member returns or sets the players vehicle. == Syntax == You can either return or set a new value using this member: <co…')
 
 
Line 1: Line 1:
{{Squirrel/Title|Vehicle.Health}}
+
{{Squirrel/Title|Player.Vehicle}}
 
This ''Player'' class member returns or sets the players vehicle.
 
This ''Player'' class member returns or sets the players vehicle.
  

Latest revision as of 10:07, 11 October 2010

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

This Player class member returns or sets the players vehicle.

[edit] Syntax

You can either return or set a new value using this member:

  1. vehicle player.Vehicle
  1. player.Vehicle = vehicle veh

[edit] Arguments

  • veh - The vehicle to set

[edit] Example 1. Returning

  1.  
  2. function onPlayerCommand( player, szCommand, szText )
  3. {
  4. if ( szCommand == "mycar" )
  5. {
  6. if ( player.Vehicle ) MessagePlayer( "You are currently driving a " + GetVehicleName( player.Vehicle ), player );
  7. }
  8. return 1;
  9. }
  10.  

[edit] Notes

The function MessagePlayer, GetVehicleName and event onPlayerCommand were used in this example. More info about them in the corresponding pages.

[edit] Example 2. Setting

  1.  
  2. function onPlayerCommand( player, szCommand, szText )
  3. {
  4. if ( szCommand == "runaway" )
  5. {
  6. local veh = GetClosestVehicle( player );
  7. if ( veh )
  8. {
  9. MessagePlayer( "Placing you in the closest vehicle so you can run away! (wuss!)", player );
  10. player.Vehicle = veh;
  11. }
  12. }
  13. return 1;
  14. }
  15.  

[edit] Notes

The function MessagePlayer, GetClosestVehicle and event onPlayerCommand was used in this example. More info about this in the corresponding page.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox