GetVehicleDriver: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetVehicleDriver(vehicle)}} {{FuncParameters}} {{FuncParam|vehicle|__EDIT_ME__}} {{FuncReturnValu..." |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Get the driver (player identifier) of a given vehicle.}} | ||
{{FuncSyntax|GetVehicleDriver(vehicle)}} | {{FuncSyntax|GetVehicleDriver(vehicle)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|vehicle| | {{FuncParam|vehicle|The vehicle identifier.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|The player identifier. Returns '''false''' on error.}} | ||
== Example == | == Example == | ||
function cmd_getdriver(player, vehicle) | |||
if (vehicle == nil) then | |||
return AddPlayerChat(player, "Usage: /getdriver <vehicle>") | |||
end | |||
if (not IsValidVehicle(vehicle)) then | |||
return AddPlayerChat(player, "Vehicle (ID: "..vehicle..") does not exist") | |||
end | |||
local driver = GetVehicleDriver(vehicle) | |||
local name = GetPlayerName(driver) | |||
AddPlayerChat(player, "Vehicle "..vehicle.." driver is "..name.." ("..driver..")") | |||
end | |||
AddCommand("getdriver", cmd_getdriver) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{VehicleFunctions}} |
Revision as of 12:56, 22 March 2019
Description
Get the driver (player identifier) of a given vehicle.
Syntax
GetVehicleDriver(vehicle)
Parameters
- vehicle
The vehicle identifier.
Return Value
- The player identifier. Returns false on error.
Example
function cmd_getdriver(player, vehicle) if (vehicle == nil) then return AddPlayerChat(player, "Usage: /getdriver <vehicle>") end
if (not IsValidVehicle(vehicle)) then return AddPlayerChat(player, "Vehicle (ID: "..vehicle..") does not exist") end
local driver = GetVehicleDriver(vehicle) local name = GetPlayerName(driver) AddPlayerChat(player, "Vehicle "..vehicle.." driver is "..name.." ("..driver..")") end AddCommand("getdriver", cmd_getdriver) </syntaxhighlight>
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