mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Using event listeners to change the job.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
local nearDoor = true
|
||||
|
||||
function drawText3D(coords, text)
|
||||
local onScreen, _x, _y = World3dToScreen2d(coords.x, coords.y, coords.z + 0.5)
|
||||
@@ -23,7 +22,6 @@ function getDoorText(locked)
|
||||
end
|
||||
|
||||
function isAuthorized(door)
|
||||
nearDoor = true
|
||||
for _, authorizedJob in pairs(door.authorizedJobs) do
|
||||
if job == authorizedJob then
|
||||
return true
|
||||
@@ -32,13 +30,20 @@ function isAuthorized(door)
|
||||
return false
|
||||
end
|
||||
|
||||
AddEventHandler("onResourceStart", function(resourceName)
|
||||
if (GetCurrentResourceName() ~= resourceName) then
|
||||
return
|
||||
end
|
||||
job = exports["ND_Core"]:getCharacterInfo().department
|
||||
end)
|
||||
|
||||
AddEventHandler("characterChanged", function(selectedCharacter)
|
||||
job = selectedCharacter.department
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
pedCoords = GetEntityCoords(PlayerPedId())
|
||||
if nearDoor then
|
||||
job = exports["ND_Core"]:getCharacterInfo().department
|
||||
nearDoor = false
|
||||
end
|
||||
Citizen.Wait(1000)
|
||||
end
|
||||
end)
|
||||
@@ -69,4 +74,4 @@ AddEventHandler("ND_Doorlocks:syncDoor", function(doorID, state)
|
||||
local entity = GetClosestObjectOfType(doors.coords.x, doors.coords.y, doors.coords.z, 1.0, doors.hash, false, false, false)
|
||||
SetEntityHeading(entity, doors.heading)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user