I made this simple script for freeroam servers. This lets you change the color of a players vehicle. Either with command or gui. I hope you enjoy
(Server-sided only! NOT TESTED!)
server.lua -
local command = 'vehcolor'
function vehColor(element,_,r,g,b)
if getElementType(element) == 'player' then
local v = getPedOccupiedVehicle(element)
if v then
if getVehicleOccupant(v,0) == element then
vehicle = v
end
end
elseif getElementType(element) == 'vehicle' then
vehicle = element
end
if vehicle then
if r then
if g then
if b then
if tonumber(b) then
setVehicleColor(vehicle,tonumber(r),tonumber(g),tonumber(b))
end
else
if tonumber(g) then
setVehicleColor(vehicle,tonumber(r),tonumber(g),0)
end
end
else
if tonumber(r) then
setVehicleColor(vehicle,tonumber(r),0,0)
end
end
else
setVehicleColor(vehicle,0,0,0)
end
end
end
addEvent('setVehicleColor',true)
addEventHandler('setVehicleColor',root,vehColor)
addCommandHandler(command,vehColor)
--[[ Event Triggers
triggerEvent('setVehicleColor',root,vehicle,_,r,g,b)
triggerServerEvent('setVehicleColor',root,vehicle,_,r,g,b)
triggerEvent('setVehicleColor',root,player,_,r,g,b)
triggerServerEvent('setVehicleColor',root,player,_,r,g,b)
]]