SetVehicleColor: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetVehicleColor(vehicle, HexColor)}} {{FuncParameters}} {{FuncParam|vehicle|__EDIT_ME__}} {{FuncPa..." |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Sets the color of a given vehicle.}} | ||
{{FuncSyntax|SetVehicleColor(vehicle, HexColor)}} | {{FuncSyntax|SetVehicleColor(vehicle, HexColor)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|vehicle| | {{FuncParam|vehicle|The vehicle to change the color of.}} | ||
{{FuncParam|HexColor| | {{FuncParam|HexColor|The color in hex format. Use [[RGB]] to convert RGB codes to hex.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns '''true''' on success, '''false''' on error.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function cmd_vcolor(player, r, g, b) | |||
if (r == nil or g == nil or b == nil) then | |||
return AddPlayerChat(player, "Usage: /vcolor <r> <g> <b>") | |||
end | |||
local vehicle = GetPlayerVehicle(player) | |||
if (vehicle == 0) then | |||
return AddPlayerChat(player, "You must be in a vehicle") | |||
end | |||
if (GetPlayerVehicleSeat(player) ~= 1) then | |||
return AddPlayerChat(player, "You must be the driver of the vehicle") | |||
end | |||
SetVehicleColor(vehicle, RGB(r, g, b)) | |||
AddPlayerChat(player, "New vehicle color set (HEX: "..GetVehicleColor(vehicle)..")") | |||
end | |||
AddCommand("vcolor", cmd_vcolor) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{VehicleFunctions}} |
Revision as of 13:13, 22 March 2019
Description
Sets the color of a given vehicle.
Syntax
SetVehicleColor(vehicle, HexColor)
Parameters
- vehicle
The vehicle to change the color of. - HexColor
The color in hex format. Use RGB to convert RGB codes to hex.
Return Value
- Returns true on success, false on error.
Example
function cmd_vcolor(player, r, g, b)
if (r == nil or g == nil or b == nil) then
return AddPlayerChat(player, "Usage: /vcolor <r> <g> <b>")
end
local vehicle = GetPlayerVehicle(player)
if (vehicle == 0) then
return AddPlayerChat(player, "You must be in a vehicle")
end
if (GetPlayerVehicleSeat(player) ~= 1) then
return AddPlayerChat(player, "You must be the driver of the vehicle")
end
SetVehicleColor(vehicle, RGB(r, g, b))
AddPlayerChat(player, "New vehicle color set (HEX: "..GetVehicleColor(vehicle)..")")
end
AddCommand("vcolor", cmd_vcolor)
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