Vehicle.GetPassenger

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This Vehicle class method will return the passenger pointer for the given seat. If the seat has no passenger, a null pointer will be returned.

Syntax

  1. Player Vehicle.GetPassenger( int seat )

Arguments

  • seat - The seat you wish to return the passenger for. seat is an integer from 0 to 7, 0 being the driver's seat.

Example

This example command returns the passenger who is sat in seat ID 0 of the current vehicle when a player types '/passenger'.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "passenger" )
  5. {
  6. local pVehicle = pPlayer.Vehicle;
  7. if ( pVehicle )
  8. {
  9. local pPassenger = pVehicle.GetPassenger( 0 );
  10. if ( pPassenger ) MessagePlayer( "Vehicle Driver: " + pPassenger.Name, pPlayer );
  11. }
  12. }
  13. return 1;
  14. }
  15.  

Notes

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

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox