Squirrel/Server/Functions/Vehicles/PassengerCount

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Notes)
m (Optimised example, updated link list)
 
Line 11: Line 11:
  
 
== Example ==
 
== Example ==
 +
 +
This example command returns the passenger count of the current vehicle.
  
 
<code lang="squirrel">
 
<code lang="squirrel">
Line 17: Line 19:
 
if ( szCommand == "passengers" )
 
if ( szCommand == "passengers" )
 
{
 
{
if ( pPlayer.Vehicle ) MessagePlayer( "Vehicle passenger count is " + pPlayer.Vehicle.PassengerCount, pPlayer );
+
local pVeh = pPlayer.Vehicle;
 +
if ( pVeh ) MessagePlayer( "Vehicle passenger count is " + pVeh.PassengerCount, pPlayer );
 
}
 
}
  
Line 26: Line 29:
 
=== Notes ===
 
=== Notes ===
  
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
+
The functions [[Squirrel/Server/Functions/Players/Vehicle|Player.Vehicle]], [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Vehicles}}
 
{{Squirrel/Server/Functions/Vehicles}}

Latest revision as of 19:20, 29 September 2010

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

This Vehicle class member returns the passenger count of the vehicle.

[edit] Syntax

  1. int Vehicle.PassengerCount

[edit] Arguments

  • none

[edit] Example

This example command returns the passenger count of the current vehicle.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "passengers" )
  5. {
  6. local pVeh = pPlayer.Vehicle;
  7. if ( pVeh ) MessagePlayer( "Vehicle passenger count is " + pVeh.PassengerCount, pPlayer );
  8. }
  9.  
  10. return 1;
  11. }
  12.  

[edit] Notes

The functions Player.Vehicle, MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox