Jump to content

Probelm with setVehicleEngine and SetVehicleLocked in OnVehicleExit


Tony Brand

Recommended Posts

hi, i want to make a system that when player leaves a vehicle, engine turns off and if Vehicle was locked, it gets Unlocked!
so i made this in Server Side:
 

addEventHandler ("onPlayerVehicleExit", getRootElement(), function(theVehicle, leftSeat, jackerPlayer)
	if leftSeat == 0 and not jackerPlayer then
		setVehicleEngineState(theVehicle, false )
		setVehicleLocked(theVehicle, false)
    end
end)

but it doesn't work(without any warning or error) and Vehicle is still locked and Engine is on when you  enter the vehicle!
do you know what i must do? tnx

Link to comment
3 minutes ago, Dimos7 said:

addEventHandler("onVehicleExit", root,      function (thePlayer, seat, jacked) 
    if seat ==0 and not jacked then 
      setVehicleEngineState(source, false) 
      setVehicleLocked(source, false) 
      end 
   end
) 

 

it is client side then?

Link to comment
On 15/11/2018 at 01:40, mazarati21 said:

This code works fine here.


function engineoff (thePlayer, seat, jacked)      
    if seat ==0 and not jacked then 
      setVehicleEngineState(source, false) 
      setVehicleLocked(source, false) 
      end 
   end
addEventHandler("onVehicleExit", root, engineoff)

Server side.

not working!without any error or warning

Link to comment

Create a folder.

Then create a meta.xml 

<meta>
    <info author="Name" description="Engineoff" version="1.0" type="script" />
    <script src="server.lua" type="server" />
</meta>

and create another file server.lua 

function engineoff (thePlayer, seat, jacked)      
    if seat ==0 and not jacked then 
      setVehicleEngineState(source, false) 
      setVehicleLocked(source, false) 
      end 
   end
addEventHandler("onVehicleExit", root, engineoff)

 

Link to comment
22 hours ago, mazarati21 said:

Create a folder.

Then create a meta.xml 


<meta>
    <info author="Name" description="Engineoff" version="1.0" type="script" />
    <script src="server.lua" type="server" />
</meta>

and create another file server.lua 


function engineoff (thePlayer, seat, jacked)      
    if seat ==0 and not jacked then 
      setVehicleEngineState(source, false) 
      setVehicleLocked(source, false) 
      end 
   end
addEventHandler("onVehicleExit", root, engineoff)

 

not working!!

i solved Engine problem with this code:

 

function engine(player)
	local veh = getPedOccupiedVehicle (player)
	setVehicleEngineState ( veh, false )
end
addEventHandler("onVehicleEnter", getRootElement(), engine)


but i don't have any idea about car locks!it is so crazy that a player can leave a vehicle while it is locked and it doesn't get unlocked!

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