Updated 2.1.0

Updated everything to new format, N1K0 is about to work on some more stuff.
This commit is contained in:
Andyyy7666
2022-07-16 04:46:27 +02:00
parent e25da65776
commit 96f89d60ff
37 changed files with 924 additions and 854 deletions

View File

@@ -1,4 +1,7 @@
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
NDCore = exports["ND_Core"]:GetCoreObject()
local job = NDCore.functions:getSelectedCharacter().job
local hasAccess = false
function drawText3D(coords, text)
@@ -17,9 +20,17 @@ end
function getDoorText(locked)
if locked then
return "Locked [E]"
if hasAccess then
return "Locked [E]"
else
return "Locked"
end
end
if hasAccess then
return "Unlocked [E]"
else
return ""
end
return "Unlocked [E]"
end
function isAuthorized(door)
@@ -31,21 +42,15 @@ function isAuthorized(door)
return false
end
RegisterNetEvent("ND:setCharacter")
AddEventHandler("ND:setCharacter", function(character)
job = character.job
end)
AddEventHandler("playerSpawned", function()
TriggerServerEvent("ND_Doorlocks:getDoors")
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())
@@ -58,9 +63,7 @@ Citizen.CreateThread(function()
for doorID, door in pairs(doorList) do
if #(pedCoords - door.textCoords) < door.accessDistance then
hasAccess = isAuthorized(door)
if hasAccess then
drawText3D(door.textCoords, getDoorText(door.locked))
end
drawText3D(door.textCoords, getDoorText(door.locked))
for _, doors in pairs(door.doors) do
local entity = GetClosestObjectOfType(doors.coords.x, doors.coords.y, doors.coords.z, 1.0, doors.hash, false, false, false)
FreezeEntityPosition(entity, door.locked)
@@ -97,4 +100,4 @@ AddEventHandler("ND_Doorlocks:returnDoors", function(updatedDoors)
FreezeEntityPosition(entity, state)
end
end
end)
end)

View File

@@ -1,4 +1,8 @@
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
NDCore = exports["ND_Core"]:GetCoreObject()
NDCore.functions:versionChecker("ND_Doorlocks", GetCurrentResourceName(), "https://github.com/Andyyy7666/ND_Framework", "https://raw.githubusercontent.com/Andyyy7666/ND_Framework/main/ND_Doorlocks/fxmanifest.lua")
local updatedDoors = {}
RegisterNetEvent("ND_Doorlocks:syncDoor")
@@ -11,4 +15,4 @@ RegisterNetEvent("ND_Doorlocks:getDoors")
AddEventHandler("ND_Doorlocks:getDoors", function()
local player = source
TriggerClientEvent("ND_Doorlocks:returnDoors", player, updatedDoors)
end)
end)