Sign in to follow this  
Tony Brand

Probelm with setVehicleEngine and SetVehicleLocked in OnVehicleExit

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

Share this post


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

 

Share this post


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

Share this post


Link to post

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.

Share this post


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

Share this post


Link to post

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)

 

Share this post


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

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.