Sign in to follow this  
Redox

Turn signal

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 :)

Share this post


Link to post

uhm.. you want one player to set turn signal in all cars? :P

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?

Share this post


Link to post

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

Share this post


Link to post
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 )))

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.