Jump to content

Car Lock System - onVehicleStartExit


Cronoss

Recommended Posts

Well, I'm trying to make something like this; if the owner locked his vehicle, then he CAN'T get out of the car. The problem with this is that when I use "cancelEvent()" for it, the script also stops the event for "car jack", so if another player tries to steal a locked car with the owner inside, the server doesn't show the "try to enter in a vehicle" animation and the car-lock system stops working correctly

Code in server side:

function blockExit()
	local playerInside = getVehicleOccupant(source) -------I added this recently, because I want to figure out how to make only the player inside get the "cancel event" and not the player outside the vehicle
	if(isVehicleLocked(source)) then -----if veh locked
        cancelEvent() ----cancels the event but it also cancels the carjack animation and gets me an annoying bug
	end
end
addEventHandler("onVehicleStartExit", getRootElement(), blockExit)

 

 

Link to comment

maybe you can do it like this to accept the animation of others entering the car

function blockExit(exitingPed, seat, jacked, door)
   if(isVehicleLocked(source)) then 
      if(not jacked) then --cancel if car is not jacked
         cancelEvent()
      end
   end
end
addEventHandler("onVehicleStartExit", getRootElement(), blockExit)
Edited by Burak5312
  • Like 1
  • Thanks 1
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...