Squirrel/Server/Functions/Vehicles/GetPassenger
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example) |
(We don't like null passengers) |
||
Line 10: | Line 10: | ||
== Example == | == Example == | ||
+ | |||
+ | This example command returns who is driving the vehicle when a player types '/driver'. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
function onPlayerCommand( pPlayer, szCommand, szText ) | function onPlayerCommand( pPlayer, szCommand, szText ) | ||
{ | { | ||
− | + | if ( szCommand == "driver" ) | |
− | + | { | |
− | + | local pVehicle = pPlayer.Vehicle; | |
− | + | if ( pVehicle ) | |
− | + | { | |
− | + | local pDriver = pVehicle.GetPassenger( 0 ); | |
− | + | if ( pDriver ) MessagePlayer( "Vehicle Driver: " + pDriver.Name, pPlayer ); | |
+ | } | ||
+ | } | ||
+ | |||
+ | return 1; | ||
} | } | ||
</code> | </code> | ||
Line 26: | Line 32: | ||
=== Notes === | === Notes === | ||
− | The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] | + | The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]], [[Squirrel/Server/Functions/Players/Vehicle|Player.Vehicle]] 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}} |
Revision as of 18:00, 29 September 2010
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
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 who is driving the vehicle when a player types '/driver'.
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "driver" ) { local pVehicle = pPlayer.Vehicle; if ( pVehicle ) { local pDriver = pVehicle.GetPassenger( 0 ); if ( pDriver ) MessagePlayer( "Vehicle Driver: " + pDriver.Name, pPlayer ); } } return 1; }
Notes
The functions MessagePlayer, Player.Vehicle and event onPlayerCommand were used in this example. More info about them in the corresponding pages.
Related Functions
- CreateVehicle
- FindVehicle
- GetClosestVehicle
- GetVehicleCount
- GetVehicleHandlingData
- GetVehicleIDFromName
- GetVehicleName
- SetVehicleHandlingData
- Vehicle.Alpha
- Vehicle.Angle
- Vehicle.Colour1
- Vehicle.Colour2
- Vehicle.Driver
- Vehicle.EngineDamage
- Vehicle.Explode
- Vehicle.Fix
- Vehicle.GetAddon
- Vehicle.GetPassenger
- Vehicle.GetHandlingData
- Vehicle.GetWheelStatus
- Vehicle.Health
- Vehicle.ID
- Vehicle.IdleRespawnTime
- Vehicle.IdleTime
- Vehicle.LightState
- Vehicle.Locked
- Vehicle.Marker
- Vehicle.MarkerScale
- Vehicle.MarkerSprite
- Vehicle.Model
- Vehicle.OneTime
- Vehicle.PassengerCount
- Vehicle.Pos
- Vehicle.Remove
- Vehicle.Respawn
- Vehicle.RespawnTime
- Vehicle.RGBColour1
- Vehicle.RGBColour2
- Vehicle.SetHandlingData
- Vehicle.SetWheelStatus
- Vehicle.SpawnAngle
- Vehicle.SpawnPos
- Vehicle.SetAddon
- Vehicle.SetEngineState
- Vehicle.SetRadio
- Vehicle.Siren
- Vehicle.SirenLight
- Vehicle.TaxiLight
- Vehicle.Velocity
- Vehicle.VirtualWorld
- Vehicle.Wrecked