Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set certain doors to Vehicles only #34

Open
HumanTree92 opened this issue Apr 13, 2020 · 1 comment
Open

How to set certain doors to Vehicles only #34

HumanTree92 opened this issue Apr 13, 2020 · 1 comment

Comments

@HumanTree92
Copy link

This isn't an issue but just want to show what i have done to only allow certain doors to be locked/unlocked if your in a Vehicle & have certain ones not lock/unlock if in a vehicle. I have done this b/c i was sick of Vehicle Garage Doors being so close to other doors that when you went to unlock/lock a non vehicle garage door it would lock/unlock both.

  • In config.lua under the locked add vehicle = false,
  • I have set in the en.lua ['press_button_player'] = 'Player | [E] %s', & ['press_button_vehicle'] = 'Vehicle | [E] %s', this isn't really necessary but optional.
  • I have add this
				if v.isAuthorized and v.vehicle then
					local ped = GetPlayerPed(-1)
					if IsPedInAnyVehicle(ped, false) then
						displayText = _U('press_button_vehicle', displayText)
					end
				elseif v.isAuthorized and v.vehicle == false then
					local ped = GetPlayerPed(-1)
					if IsPedInAnyVehicle(ped, false) == false then
						displayText = _U('press_button_player', displayText)
					end
				end

UNDER

if v.locked then displayText = _U('locked') end
  • Then i added this
				if IsControlJustReleased(0, 38) then
					if v.isAuthorized and v.vehicle then
						local ped = GetPlayerPed(-1)
						if IsPedInAnyVehicle(ped, false) then
							v.locked = not v.locked
							TriggerServerEvent('esx_doorlock:updateState', k, v.locked) -- broadcast new state of the door to everyone
						end
					elseif v.isAuthorized and v.vehicle == false then
						local ped = GetPlayerPed(-1)
						if IsPedInAnyVehicle(ped, false) == false then
							v.locked = not v.locked
							TriggerServerEvent('esx_doorlock:updateState', k, v.locked) -- broadcast new state of the door to everyone
						end
					end
				end
@HumanTree92
Copy link
Author

There is probably a better way of doing this but this is just what i have done. I think something like this would be nice to have implemented by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant