GetVehiclePassenger: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetVehiclePassenger(vehicle, seat)}} {{FuncParameters}} {{FuncParam|vehicle|__EDIT_ME__}} {{FuncPa..." |
Add client support for v1.1.0 |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Get any occupant of a vehicle at a given seat.}} | ||
{{FuncSyntax|GetVehiclePassenger(vehicle, seat)}} | {{FuncSyntax|GetVehiclePassenger(vehicle, seat)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|vehicle| | {{FuncParam|vehicle|The vehicle to get a passenger from.}} | ||
{{FuncParam|seat| | {{FuncParam|seat|The seat to the passenger.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns the player identifier. If there is no passenger in that seat '''0''' is returned.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function cmd_passengers(player, vehicle) | |||
if (vehicle == nil) then | |||
return AddPlayerChat(player, "Usage: /passengers <vehicle>") | |||
end | |||
if (not IsValidVehicle(vehicle)) then | |||
return AddPlayerChat(player, "Vehicle (ID: "..vehicle..") does not exist") | |||
end | |||
for i=1, GetVehicleNumberOfSeats(vehicle) do | |||
local passenger = GetVehiclePassenger(vehicle, i) | |||
if (passenger == 0) then | |||
occupants[i] = "Empty" | |||
else | |||
occupants[i] = GetPlayerName(passenger).."("..passenger..")" | |||
end | |||
end | |||
for k, v in ipairs(occupants) do | |||
AddPlayerChat(player, ' Seat '..k..': '..v) | |||
end | |||
end | |||
AddCommand("passengers", cmd_passengers) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{VehicleFunctions}} |
Latest revision as of 20:47, 7 March 2020
Description
Get any occupant of a vehicle at a given seat.
Syntax
GetVehiclePassenger(vehicle, seat)
Parameters
- vehicle
The vehicle to get a passenger from. - seat
The seat to the passenger.
Return Value
- Returns the player identifier. If there is no passenger in that seat 0 is returned.
Example
function cmd_passengers(player, vehicle)
if (vehicle == nil) then
return AddPlayerChat(player, "Usage: /passengers <vehicle>")
end
if (not IsValidVehicle(vehicle)) then
return AddPlayerChat(player, "Vehicle (ID: "..vehicle..") does not exist")
end
for i=1, GetVehicleNumberOfSeats(vehicle) do
local passenger = GetVehiclePassenger(vehicle, i)
if (passenger == 0) then
occupants[i] = "Empty"
else
occupants[i] = GetPlayerName(passenger).."("..passenger..")"
end
end
for k, v in ipairs(occupants) do
AddPlayerChat(player, ' Seat '..k..': '..v)
end
end
AddCommand("passengers", cmd_passengers)
See also
- CreateVehicle
- DestroyVehicle
- IsValidVehicle
- GetVehicleCount
- GetAllVehicles
- GetVehicleModel
- GetVehicleModelName
- SetVehicleRespawnParams
- IsVehicleStreamedIn
- GetStreamedVehiclesForPlayer
- GetStreamedVehicles
- SetVehicleLocation
- GetVehicleLocation
- SetVehicleRotation
- GetVehicleRotation
- SetVehicleHeading
- GetVehicleHeading
- SetVehicleHealth
- GetVehicleHealth
- SetVehicleLicensePlate
- GetVehicleVelocity
- GetVehicleDriver
- GetVehiclePassenger
- GetVehicleNumberOfSeats
- SetVehicleColor
- GetVehicleColor
- SetVehicleLinearVelocity
- SetVehicleAngularVelocity
- GetVehicleGear
- SetVehicleHoodRatio
- GetVehicleHoodRatio
- SetVehicleTrunkRatio
- GetVehicleTrunkRatio
- StartVehicleEngine
- StopVehicleEngine
- GetVehicleEngineState
- SetVehicleLightEnabled
- GetVehicleLightState
- SetVehicleDamage
- GetVehicleDamage
- AttachVehicleNitro