Jump to content

Turn signal


Redox

Recommended Posts

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

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 by Guest
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...