Jump to content

[HELP] Vehicle light


xXGhostXx

Recommended Posts

Hi .

What problem my code for on or off vehicle light with bind Key ?

Client :

bindKey ("5", "down",
function()
	if isPedInVehicle (localPlayer) then
		local veh = getPedOccupiedVehicle(localPlayer)
		local id = getElementModel(veh)
		triggerServerEvent("cheraq", getLocalPlayer())
	else
		--
	end
end
)

Server :

function light (thePlayer)
local playerVehicle = getPedOccupiedVehicle (thePlayer)
setVehicleOverrideLights (playerVehicle, 2)
triggerClientEvent ( playerVehicle, "cheraq" )
end

@iMr.WiFi..! Please help me !

Edited by xXGhostXx
Link to comment

there some mistakes any ways, i made it for you :


Client side :-

bindKey ("5", "down",
	function()
    		if isPedInVehicle( localPlayer ) then
			triggerServerEvent("cheraq", localPlayer)
		end
	end
)


Server Side :-
 

function light ()
	local playerVehicle = getPedOccupiedVehicle (source)
	setVehicleOverrideLights (playerVehicle, 2)
end

addEvent( "cheraq", true )
addEventHandler( "cheraq", root, light )

 

Link to comment
7 minutes ago, iMr.WiFi..! said:

there some mistakes any ways, i made it for you :


Client side :-


bindKey ("5", "down",
	function()
    		if isPedInVehicle( localPlayer ) then
			triggerServerEvent("cheraq", localPlayer)
		end
	end
)


Server Side :-
 


function light ()
	local playerVehicle = getPedOccupiedVehicle (source)
	setVehicleOverrideLights (playerVehicle, 2)
end

addEvent( "cheraq", true )
addEventHandler( "cheraq", root, light )

 

Thanks but cant off light !

@iMr.WiFi..! Help me

Edited by xXGhostXx
Link to comment
12 minutes ago, xXGhostXx said:

Thanks but cant off light !

So you want to make it toggle ?

Change the server side to :-

 

function light ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if getVehicleOverrideLights (playerVehicle) < 2 then
	setVehicleOverrideLights (playerVehicle, 2)
		else
	setVehicleOverrideLights (playerVehicle, 0)
	end
end

addEvent( "cheraq", true )
addEventHandler( "cheraq", root, light )

 

Edited by iMr.WiFi..!
Link to comment
2 minutes ago, iMr.WiFi..! said:

So you want to make it toggle ?

Change the server side to :-

 


function light ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if getVehicleOverrideLights (playerVehicle) > 2 then
	setVehicleOverrideLights (playerVehicle, 2)
		else
	setVehicleOverrideLights (playerVehicle, 0)
	end
end

addEvent( "cheraq", true )
addEventHandler( "cheraq", root, light )

 

Not work @iMr.WiFi..!

Edited by xXGhostXx
Link to comment
function light ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  
		setVehicleOverrideLights ( playerVehicle, 2 )           
	else
		setVehicleOverrideLights ( playerVehicle, 1 )          
	end
end

addEvent( "cheraq", true )
addEventHandler( "cheraq", root, light )

 

Edited by iMr.WiFi..!
Link to comment
3 minutes ago, iMr.WiFi..! said:

function light ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then  
		setVehicleOverrideLights ( playerVehicle, 2 )           
	else
		setVehicleOverrideLights ( playerVehicle, 1 )          
	end
end

addEvent( "cheraq", true )
addEventHandler( "cheraq", root, light )

 

Thanks !

Can you give me function for make script engine and hand brake and open door vehicle

Link to comment
4 minutes ago, Gordon_G said:

@iMr.WiFi..! a bit off topic but why you made it for him without even let him try ? You're not helping when you give the entire script

Please do not interfere !

10 minutes ago, iMr.WiFi..! said:

And the code he did send is not a try?

Sorry men !

I have a question !

function engine ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleEngineState ( playerVehicle ) ~= 2 ) then  
		setVehicleEngineState ( playerVehicle, true )           
	else
		setVehicleEngineState ( playerVehicle, false )          
	end
end

addEvent( "roshan", true )
addEventHandler( "roshan", root, engine )

What is problem ?!

I want turn on engine vehicle and turn off engine vehicle like light !

Link to comment
9 minutes ago, xXGhostXx said:

Please do not interfere !

Sorry men !

I have a question !


function engine ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleEngineState ( playerVehicle ) ~= 2 ) then  
		setVehicleEngineState ( playerVehicle, true )           
	else
		setVehicleEngineState ( playerVehicle, false )          
	end
end

addEvent( "roshan", true )
addEventHandler( "roshan", root, engine )

What is problem ?!

I want turn on engine vehicle and turn off engine vehicle like light !

You need to check if it false or not . not  to check if it not a number.

Edited by iMr.WiFi..!
Link to comment
1 minute ago, iMr.WiFi..! said:

You need to check if it false or not . not 

function engine ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleEngineState ( playerVehicle ) ~= 2 ) then  
		setVehicleEngineState ( playerVehicle, false )           
	else
		setVehicleEngineState ( playerVehicle, true )          
	end
end

addEvent( "roshan", true )
addEventHandler( "roshan", root, engine )

Not work :(

Link to comment
Just now, xXGhostXx said:

function engine ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleEngineState ( playerVehicle ) ~= 2 ) then  
		setVehicleEngineState ( playerVehicle, false )           
	else
		setVehicleEngineState ( playerVehicle, true )          
	end
end

addEvent( "roshan", true )
addEventHandler( "roshan", root, engine )

Not work :(

I mean in line 3 not line 4 or 6

Link to comment
16 minutes ago, xXGhostXx said:

Please do not interfere !

Sorry men !

I have a question !


function engine ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleEngineState ( playerVehicle ) ~= 2 ) then  
		setVehicleEngineState ( playerVehicle, true )           
	else
		setVehicleEngineState ( playerVehicle, false )          
	end
end

addEvent( "roshan", true )
addEventHandler( "roshan", root, engine )

What is problem ?!

I want turn on engine vehicle and turn off engine vehicle like light !

You need just to change in line 3, " ~= 2 " to " ~= false "
And it will work.

Link to comment
25 minutes ago, iMr.WiFi..! said:

You need just to change in line 3, " ~= 2 " to " ~= false "
And it will work.

Thanks !

I have a problem for set hood vehicle door !

function kapootmashin ()
	local playerVehicle = getPedOccupiedVehicle (source)
	if ( getVehicleDoorState ( playerVehicle ) ~= false ) then  
		setVehicleDoorState ( playerVehicle, 0, true )           
	else
		setVehicleDoorState ( playerVehicle, 0, false )          
	end
end

addEvent( "kapoot", true )
addEventHandler( "kapoot", root, kapootmashin )

What is problem ?!

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...