Redox Posted August 16, 2010 Share Posted August 16, 2010 Hi, I started to do turn signal (or direction indicator) in my gamemode. On top script I placed timer: setTimer(Kierunek,500,0) Below I placed function: function Kierunek() if vehicleKierunekLewy[car] then --direction indicator left if not vehicleKierunek[car] then setVehicleLightState ( car, 0, 0 ) setVehicleLightState ( car, 3, 0 ) vehicleKierunek[car]=true else setVehicleLightState ( car, 0, 1 ) setVehicleLightState ( car, 3, 1 ) vehicleKierunek[car]=false end elseif vehicleKierunekPrawy[car] then --direction indicator right if not vehicleKierunek[car] then setVehicleLightState ( car, 1, 0 ) setVehicleLightState ( car, 2, 0 ) vehicleKierunek[car]=true else setVehicleLightState ( car, 1, 1 ) setVehicleLightState ( car, 2, 1 ) vehicleKierunek[car]=false end end end How can I do loop (like 'for') order this function work for all cars? I hope you know what I mean. Thanks for reading. Edit by varez: Changed code tags to lua tags. Use them next time Link to comment
dzek (varez) Posted August 16, 2010 Share Posted August 16, 2010 uhm.. you want one player to set turn signal in all cars? getElementsByType will get all cars, but this is not correct way to make indicators. btw: script like that should be in community? or i saw it somewhere else maybe? Link to comment
Redox Posted August 16, 2010 Author Share Posted August 16, 2010 (edited) This is the code fragmend. My all code: vehicleKierunek = { false } vehicleKierunekPrawy = { false } vehicleKierunekLewy = { false } function onPlayerJoin( ) bindKey ( source, "]", "down", KierunekPrawy ) bindKey ( source, "[", "down", KierunekLewy ) end function KierunekLewy(source) car = getPlayerOccupiedVehicle ( source ) if ( car ) then if not vehicleKierunekLewy[car] then vehicleKierunekPrawy[car]=false setVehicleLightState ( car, 1, 0 ) setVehicleLightState ( car, 2, 0 ) vehicleKierunekLewy[car]=true vehicleKierunek[car]=true else vehicleKierunekLewy[car]=false vehicleKierunek[car]=false setVehicleLightState ( car, 0, 0 ) setVehicleLightState ( car, 3, 0 ) end end end function KierunekPrawy(source) car = getPlayerOccupiedVehicle ( source ) if ( car ) then if not vehicleKierunekPrawy[car] then vehicleKierunekLewy[car]=false setVehicleLightState ( car, 0, 0 ) setVehicleLightState ( car, 3, 0 ) vehicleKierunekPrawy[car]=true vehicleKierunek[car]=true else vehicleKierunekPrawy[car]=false vehicleKierunek[car]=false setVehicleLightState ( car, 1, 0 ) setVehicleLightState ( car, 2, 0 ) end end end function Kierunek() if vehicleKierunekLewy[car] then if not vehicleKierunek[car] then setVehicleLightState ( car, 0, 0 ) setVehicleLightState ( car, 3, 0 ) vehicleKierunek[car]=true else setVehicleLightState ( car, 0, 1 ) setVehicleLightState ( car, 3, 1 ) vehicleKierunek[car]=false end elseif vehicleKierunekPrawy[car] then if not vehicleKierunek[car] then setVehicleLightState ( car, 1, 0 ) setVehicleLightState ( car, 2, 0 ) vehicleKierunek[car]=true else setVehicleLightState ( car, 1, 1 ) setVehicleLightState ( car, 2, 1 ) vehicleKierunek[car]=false end end end I try to do what you wrote. //Add Ok, thanks ;] It's working. Edit by varez: Same reason Edited August 16, 2010 by Guest Link to comment
dzek (varez) Posted August 16, 2010 Share Posted August 16, 2010 Use [lua][/lua] tags, not , thanks! Link to comment
TDK Posted August 18, 2010 Share Posted August 18, 2010 Use [lua /lua] tags, not , thanks![/quote] //he can simply select [code=text]code * and edit it to: [code=lua]"lua code" with replacing code=text to code=lua ))) 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