vMenu icon indicating copy to clipboard operation
vMenu copied to clipboard

Fix car locking mechanism not working (player will break glass)

Open megavirus11 opened this issue 3 years ago • 2 comments

megavirus11 avatar Sep 29 '20 17:09 megavirus11

Please make separate pull requests for each change. Fixing something is one thing, but adding a new feature (cruise control) is another. I can't merge this PR because I can't review them individually.

TomGrobbe avatar Oct 25 '20 11:10 TomGrobbe

Definitly don't use SetVehicleDoorsLocked(), SetVehicleDoorsLockedForAllPlayers() is better, can't remember why. To fix people from smashing doors just use this loop:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		local playerPed = PlayerPedId()
		local vehicleHandle = GetVehiclePedIsTryingToEnter(playerPed)

		if DoesEntityExist(vehicleHandle) then
			if GetVehicleDoorsLockedForPlayer(vehicleHandle, playerPed) then
				ESX.ShowNotification('This vehicle is locked')
				ClearPedTasks(playerPed)
			end
		end
	end
end)

It probably has to be run every frame or else GetVehiclePedIsTryingToEnter() wont work. Works flawlessly for us, but I saw that vMenu doesn't have the code that checks ownership of the vehicle. You can't set GetVehicleDoorsLockedForPlayer() on a vehicle entity you don't own, so either run the code on the player who owns it, or request entity ownership which is buggy.

ElPumpo avatar Jan 24 '21 20:01 ElPumpo

Closing PR because it's abandoned.

TomGrobbe avatar Mar 04 '23 17:03 TomGrobbe