extlatvia Posted March 25, 2012 Posted March 25, 2012 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.
Kenix Posted March 25, 2012 Posted March 25, 2012 (edited) You have syntax errors. Learn lua. viewtopic.php?f=148&t=40809 Or it's part code command handler function? Edited March 25, 2012 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Jaysds1 Posted March 25, 2012 Posted March 25, 2012 (edited) try this: addEventHandler("onVehicleEnter",root,function(plyer,seat,jacked) if(plyer)then if(seat == 0) then r,g,b=getTeamColor(getPlayerTeam(plyer)) setVehicleColor(getPedOccupiedVehicle(plyer),r,g,b) end end end) Edited March 25, 2012 by Guest My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted March 25, 2012 Posted March 25, 2012 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",root, vehiclepaint ) addEvent ( "onPlayerPickUpRacePickup", true ) addEventHandler ( "onPlayerPickUpRacePickup", root, function ( pickupID, pickupType, vehicleModel ) if ( pickupType == "vehiclechange" and getPlayerTeam ( source ) ) then local r, g, b = getTeamColor ( getPlayerTeam ( source ) ) setVehicleColor ( getPedOccupiedVehicle ( source ), r, g, b, 0, 0, 0 ) end end ) 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 end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted March 25, 2012 Posted March 25, 2012 Soil tnq. work. Sorry, I didn't seen when you edited it My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Kenix Posted March 25, 2012 Posted March 25, 2012 (edited) Soil tnq. work. Good idea copy paste all code. Good luck. Edited March 25, 2012 by Guest http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Castillo Posted March 25, 2012 Posted March 25, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now