Spyke25 Posted October 5, 2011 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.
^Dev-PoinT^ Posted October 5, 2011 Posted October 5, 2011 use This https://wiki.multitheftauto.com/wiki/SetVehicleColor
Spyke25 Posted October 5, 2011 Author 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 )
CapY Posted October 5, 2011 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
codeluaeveryday Posted October 5, 2011 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. Tutorials: => getOnlineAdmins() => [TUT] Better Join Country => [TUT] Updating admin countries => [TUT] Updating admin flags Server: K@N Zombies / Freeroam
Kenix Posted October 5, 2011 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 http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Spyke25 Posted October 5, 2011 Author Posted October 5, 2011 Thanks Kenix, but in ( col1, col2, col3 ) I need to put rgb colors? ( 255, 0, 0 ) or what?
Kenix Posted October 5, 2011 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? http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Spyke25 Posted October 5, 2011 Author 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?
CapY Posted October 5, 2011 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 ?
Kenix Posted October 5, 2011 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 ) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Spyke25 Posted October 5, 2011 Author 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 )
Kenix Posted October 5, 2011 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 ) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Spyke25 Posted October 5, 2011 Author Posted October 5, 2011 Yes but i haven't understand what i must change for set the color i want.
JR10 Posted October 5, 2011 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 ) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
^Dev-PoinT^ Posted October 5, 2011 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.
Spyke25 Posted October 5, 2011 Author Posted October 5, 2011 So, ( col1, col2, col3 ) mean ( r, g, b ) ? Sorry for the much quests but i want to learn good
JR10 Posted October 5, 2011 Posted October 5, 2011 Yea. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Spyke25 Posted October 5, 2011 Author 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 ?
JR10 Posted October 5, 2011 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 ) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Spyke25 Posted October 5, 2011 Author 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 )
Castillo Posted October 5, 2011 Posted October 5, 2011 Where's teamVehicles table? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
JR10 Posted October 5, 2011 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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Spyke25 Posted October 5, 2011 Author Posted October 5, 2011 I have only that script about this team.
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