mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-19 14:56:02 +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
|
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||||
local nearDoor = true
|
|
||||||
|
|
||||||
function drawText3D(coords, text)
|
function drawText3D(coords, text)
|
||||||
local onScreen, _x, _y = World3dToScreen2d(coords.x, coords.y, coords.z + 0.5)
|
local onScreen, _x, _y = World3dToScreen2d(coords.x, coords.y, coords.z + 0.5)
|
||||||
@@ -23,7 +22,6 @@ function getDoorText(locked)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function isAuthorized(door)
|
function isAuthorized(door)
|
||||||
nearDoor = true
|
|
||||||
for _, authorizedJob in pairs(door.authorizedJobs) do
|
for _, authorizedJob in pairs(door.authorizedJobs) do
|
||||||
if job == authorizedJob then
|
if job == authorizedJob then
|
||||||
return true
|
return true
|
||||||
@@ -32,13 +30,20 @@ function isAuthorized(door)
|
|||||||
return false
|
return false
|
||||||
end
|
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()
|
Citizen.CreateThread(function()
|
||||||
while true do
|
while true do
|
||||||
pedCoords = GetEntityCoords(PlayerPedId())
|
pedCoords = GetEntityCoords(PlayerPedId())
|
||||||
if nearDoor then
|
|
||||||
job = exports["ND_Core"]:getCharacterInfo().department
|
|
||||||
nearDoor = false
|
|
||||||
end
|
|
||||||
Citizen.Wait(1000)
|
Citizen.Wait(1000)
|
||||||
end
|
end
|
||||||
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)
|
local entity = GetClosestObjectOfType(doors.coords.x, doors.coords.y, doors.coords.z, 1.0, doors.hash, false, false, false)
|
||||||
SetEntityHeading(entity, doors.heading)
|
SetEntityHeading(entity, doors.heading)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user