GetPlayerVehicle: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetPlayerVehicle(player)}} {{FuncParameters}} {{FuncParam|player|__EDIT_ME__}} {{FuncReturnValue|..." |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Returns the vehicle identifier the player is in.}} | ||
{{FuncSyntax|GetPlayerVehicle(player)}} | {{FuncSyntax|GetPlayerVehicle(player)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|player| | {{FuncParam|player|The player identifier.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns the vehicle identifier the player is in. Returns '''0''' if not in any vehicle.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua> | |||
AddCommand("colorv", function(playerid, red, green, blue) | |||
local vehicleid = GetPlayerVehicle(playerid) | |||
if vehicleid == 0 then | |||
AddPlayerChat(playerid, "You must be in a vehicle...") | |||
return | |||
end | |||
red = tonumber(red) | |||
green = tonumber(green) | |||
blue = tonumber(blue) | |||
if red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 then | |||
AddPlayerChat(playerid, "Usage: /colorv <red> <green> <blue>") | |||
return | |||
end | |||
SetVehicleColor(vehicleid, RGB(red, green, blue, 255)) | |||
end) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{Template:VehicleFunctions}} |
Latest revision as of 09:58, 12 December 2019
Description
Returns the vehicle identifier the player is in.
Syntax
GetPlayerVehicle(player)
Parameters
- player
The player identifier.
Return Value
- Returns the vehicle identifier the player is in. Returns 0 if not in any vehicle.
Example
AddCommand("colorv", function(playerid, red, green, blue)
local vehicleid = GetPlayerVehicle(playerid)
if vehicleid == 0 then
AddPlayerChat(playerid, "You must be in a vehicle...")
return
end
red = tonumber(red)
green = tonumber(green)
blue = tonumber(blue)
if red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 then
AddPlayerChat(playerid, "Usage: /colorv <red> <green> <blue>")
return
end
SetVehicleColor(vehicleid, RGB(red, green, blue, 255))
end)
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