Admigo Posted February 4, 2012 Posted February 4, 2012 Dear scripters, I have a problem with this script: function setTheCarColors( ) local endteam = getTeamFromName( "END#" ) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local theplayer = getVehicleOccupant( car ) local nowteam = getPlayerTeam( theplayer ) if theplayer then if(nowteam == endteam) then setVehicleColor(car, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) end end end end addEvent("onVehColorChange",true) addEventHandler("onVehColorChange",getRootElement(),setTheCarColors) function timer() --Delay it a bit to allow players to warp in their vehicle... setTimer(setTheCarColors,500,0) end addEventHandler("onMapStarting",getRootElement(),timer) addCommandHandler ( "set_vehicle_color", setTheCarColors ) I want that players is admin team get a yellow carpaint with a time of 500 so its detecting it. But why this code dont work? Thanks Admigo
Kenix Posted February 4, 2012 Posted February 4, 2012 /debugscript 3 ? http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
arezu Posted February 4, 2012 Posted February 4, 2012 onMapStarting is a custom event so you need to add; addEvent too. But since you are never killing the timer, you dont need to put it inside that event. function setTheCarColors( ) local endteam = getTeamFromName( "END#" ) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local theplayer = getVehicleOccupant( car ) local nowteam = getPlayerTeam( theplayer ) if theplayer then if(nowteam == endteam) then setVehicleColor(car, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) end end end end addEvent("onVehColorChange",true) addEventHandler("onVehColorChange",getRootElement(),setTheCarColors) setTimer(setTheCarColors,500,0)
Kenix Posted February 5, 2012 Posted February 5, 2012 Server side. addEvent( "onVehColorChange",true ) addEvent( "onMapStarting",true ) function setTheCarColors( ) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local theplayer = getVehicleOccupant( car ) if isElement( theplayer ) then local nowteam = getPlayerTeam( theplayer ) local endteam = getTeamFromName( "END#" ) if nowteam == endteam then setVehicleColor( car, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) end end end end addEventHandler( "onVehColorChange",root,setTheCarColors ) function timer( ) --Delay it a bit to allow players to warp in their vehicle... setTimer( setTheCarColors,500,0 ) end addEventHandler("onMapStarting",root,timer ) addCommandHandler ( "set_vehicle_color", setTheCarColors ) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Admigo Posted February 5, 2012 Author Posted February 5, 2012 onMapStarting is a custom event so you need to add; addEvent too.But since you are never killing the timer, you dont need to put it inside that event. function setTheCarColors( ) local endteam = getTeamFromName( "END#" ) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local theplayer = getVehicleOccupant( car ) local nowteam = getPlayerTeam( theplayer ) if theplayer then if(nowteam == endteam) then setVehicleColor(car, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) end end end end addEvent("onVehColorChange",true) addEventHandler("onVehColorChange",getRootElement(),setTheCarColors) setTimer(setTheCarColors,500,0) I get spam error:bad argument@GetPlayerTeam How can i fix this?
Castillo Posted February 5, 2012 Posted February 5, 2012 addEvent( "onVehColorChange",true ) addEvent( "onMapStarting",true ) function setTheCarColors( ) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local theplayer = getVehicleController( car ) if (theplayer and isElement( theplayer )) then local nowteam = getPlayerTeam( theplayer ) local endteam = getTeamFromName( "END#" ) if (nowteam == endteam) then setVehicleColor( car, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) end end end end addEventHandler( "onVehColorChange",root,setTheCarColors ) function timer( ) --Delay it a bit to allow players to warp in their vehicle... setTimer( setTheCarColors,500,0 ) end addEventHandler("onMapStarting",root,timer ) addCommandHandler ( "set_vehicle_color", setTheCarColors ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted February 6, 2012 Posted February 6, 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