Spyke25 Posted October 5, 2011 Share Posted October 5, 2011 Hello. I made a script it make 2 teams. I would to know how i can set a color at the car when a player join the team. For example, i have a red team, when i join this team i will have a red car automatically ( race server ). Can someone help me ? Thanks in advance. Link to comment
^Dev-PoinT^ Posted October 5, 2011 Share Posted October 5, 2011 use This https://wiki.multitheftauto.com/wiki/SetVehicleColor Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 Ok, thanks. But im a beginner of lua scripting, so i ask you if that's right : teamName = createTeam ( "Name", 255, 0, 0 ) setVehicleColor ( playerVehicle, col1, col2, col3, col4 ) Link to comment
CapY Posted October 5, 2011 Share Posted October 5, 2011 Ok, thanks.But im a beginner of lua scripting, so i ask you if that's right : teamName = createTeam ( "Name", 255, 0, 0 ) setVehicleColor ( playerVehicle, col1, col2, col3, col4 ) Try it and you will know, if you got any errors , post them here Link to comment
codeluaeveryday Posted October 5, 2011 Share Posted October 5, 2011 Ok, thanks.But im a beginner of lua scripting, so i ask you if that's right : teamName = createTeam ( "Name", 255, 0, 0 ) setVehicleColor ( playerVehicle, col1, col2, col3, col4 ) Sorry, i can't let him fail, that Won't do as you want, sorry capy, but he had to know one way or another. Link to comment
Kenix Posted October 5, 2011 Share Posted October 5, 2011 (edited) You mean this? local teamName teamName = createTeam ( "Name", 255, 0, 0 ) col1, col2, col3 = getTeamColor ( teamName ) setVehicleColor ( playerVehicle, col1 or 0, col2 or 0, col3 or 0 , 0 ) Example: local teamName,col1,col2,col3 teamName = createTeam ( "Name", 255, 0, 0 ) function setColors() for i, car in ipairs( getElementsByType( "vehicle" ) ) do local col1,col2,col3 col1, col2, col3 = getTeamColor ( teamName ) setVehicleColor ( car, col1 or 0, col2 or 0, col3 or 0 , 0 ) end end setTimer( setColors, 500, 0 ) Edited October 5, 2011 by Guest Link to comment
^Dev-PoinT^ Posted October 5, 2011 Share Posted October 5, 2011 yes Kenix Nice Scripting lol Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 Thanks Kenix, but in ( col1, col2, col3 ) I need to put rgb colors? ( 255, 0, 0 ) or what? Link to comment
Kenix Posted October 5, 2011 Share Posted October 5, 2011 Thanks Kenix, but in ( col1, col2, col3 ) I need to put rgb colors? ( 255, 0, 0 ) or what? Not understand .What you need? Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 How i can set the color i want? For example, if i want to give a yellow color at car, what i need to change in your code? Link to comment
CapY Posted October 5, 2011 Share Posted October 5, 2011 Ok, thanks.But im a beginner of lua scripting, so i ask you if that's right : teamName = createTeam ( "Name", 255, 0, 0 ) setVehicleColor ( playerVehicle, col1, col2, col3, col4 ) Sorry, i can't let him fail, that Won't do as you want, sorry capy, but he had to know one way or another. Umm, what ? Link to comment
Kenix Posted October 5, 2011 Share Posted October 5, 2011 How i can set the color i want? For example, if i want to give a yellow color at car, what i need to change in your code? setVehicleColor( car, -- vehicle variable 255, -- color red 255, -- color green 0, -- color blue 0 ) Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 Ok then, is this right? function createTeamsOnStart () local teamName,col1,col2,col3 teamGyg = createTeam ( "~GYG~", 255, 255, 0 ) function setColors() for i, car in ipairs( getElementsByType( "vehicle" ) ) do local col1,col2,col3 col1, col2, col3 = getTeamColor ( teamName ) setVehicleColor ( car, 255, 255, 0 , 0 ) end end setTimer( setColors, 500, 0 ) Link to comment
Kenix Posted October 5, 2011 Share Posted October 5, 2011 This correct local teamGyg teamGyg = createTeam ( "~GYG~", 255, 255, 0 ) function setColors() for i, car in ipairs( getElementsByType( "vehicle" ) ) do local col1,col2,col3 col1, col2, col3 = getTeamColor ( teamGyg ) setVehicleColor ( car, col1 or 0, col2 or 0, col3 or 0, 0 ) end end setTimer( setColors, 500, 0 ) Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 Yes but i haven't understand what i must change for set the color i want. Link to comment
JR10 Posted October 5, 2011 Share Posted October 5, 2011 Syntax: bool setVehicleColor ( vehicle theVehicle, int r1, int g1, int b1 ) r1, g1, b1: Three integers indicating the red, green and blue components of the first (main) color for the vehicle So yellow is 255 , 255 , 0 local teamGyg = createTeam ( "~GYG~", 255, 255, 0 ) function setColors() for i, car in ipairs( getElementsByType( "vehicle" ) ) do --local col1, col2, col3 = getTeamColor ( teamGyg ) setVehicleColor ( car, 255 , 255 , 0 ) end end setTimer( setColors, 500, 0 ) Link to comment
^Dev-PoinT^ Posted October 5, 2011 Share Posted October 5, 2011 For example function randomVehColors() for i, car in ipairs( getElementsByType( "vehicle" ) ) do local color = {} color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126 color[2] = math.random(0,126) color[3] = math.random(0,126) color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle end end setTimer( randomVehColors, 500, 0 ) -- timer changes all vehicles colors to random every 0.5 sec. Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 So, ( col1, col2, col3 ) mean ( r, g, b ) ? Sorry for the much quests but i want to learn good Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 Ok thanks, but with this code : local teamGyg = createTeam ( "~GYG~", 255, 255, 0 ) function setColors() for i, car in ipairs( getElementsByType( "vehicle" ) ) do --local col1, col2, col3 = getTeamColor ( teamGyg ) setVehicleColor ( car, 255 , 255 , 0 ) end end setTimer( setColors, 500, 0 ) ALL the vehicles are yellow and black, and not ONLY the vehicles of the team member. How i can fix ? Link to comment
JR10 Posted October 5, 2011 Share Posted October 5, 2011 You must get the team vehicles variable, ways of doing this: getElementByID -- setElementData getElementData If you have a table with the team vehicles then: function setColors() for i, car in ipairs( teamVehicles ) do setVehicleColor ( car, 255 , 255 , 0 ) end end setColors() --setTimer( setColors, 500, 0 ) Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 I have errors with this : local teamGyg = createTeam ( "~GYG~", 255, 255, 0 ) function setColors() for i, car in ipairs( teamVehicles ) do --local col1, col2, col3 = getTeamColor ( teamGyg ) setVehicleColor ( car, 255 , 255 , 0 ) end end setTimer( setColors, 500, 0 ) Link to comment
Castillo Posted October 5, 2011 Share Posted October 5, 2011 Where's teamVehicles table? Link to comment
JR10 Posted October 5, 2011 Share Posted October 5, 2011 If you have a table with the team vehicles then: You must get the team vehicles some how. Do you have them in a .map? post the part where there is the team vehicles. Link to comment
Spyke25 Posted October 5, 2011 Author Share Posted October 5, 2011 I have only that script about this team. Link to comment
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