Hey, i want set to my team car color . i use auto teams.
And i want a set car color for me only or other player. can give or tell how make that.?
function vehiclepaint(player,seat)
if (seat == 0 and getPlayerTeam(player)) then
local r,g,b = getTeamColor(getPlayerTeam(player))
setVehicleColor(source,r,g,b,0,0,0)
end
end
addEventHandler("onVehicleEnter",getRootElement(),vehiclepaint)
addCommandHandler("addteam",
function(source, cmd, clantag, color, ...)
local name = {...}
if not name[1] then
outputChatBox("syntax: "..cmd.." ", source)
return
end
local r,g,b = getColorFromString(color)
if not r then
outputChatBox(cmd..": invalid color code", source)
return
end
name = table.concat(name, ' ')
local config = xmlLoadFile("config.xml")
-- local config = getResourceConfig("config.xml")
local teamset, teamname
for name,settings in next,teams do
if settings.tag == clantag then
teamset, teamname = settings, name
break
end
end
if teamset then
local name_differs, color_differs
local c = teamset.color
local t = getTeamFromName(teamname)
if c[1] ~= r or c[2] ~= g or c[3] ~= b then
teamset.color = {r,g,b}
color_differs = true
if t then setTeamColor(t, r, g, b)end
end
if teamname ~= name then
name_differs = true
end
if color_differs or name_differs then
for k,child in next,xmlNodeGetChildren(config)do
if xmlNodeGetAttribute(child, "tag") == clantag then
if color_differs then
xmlNodeSetAttribute(child, "color", string.format("#%02X%02X%02X", r, g, b))
end
if name_differs then
xmlNodeSetAttribute(child, "name", name)
end
break
end
end
end
Here is code from script. And when start map in Race gamemode i have car color gold and black, but when i change car its a some other color and i want to gold and black color stay all time.