mirror of
https://github.com/ND-Framework/ND_Core.git
synced 2026-08-17 05:56:01 +01:00
Add files via upload
This commit is contained in:
38
ND_Doorlocks/config.lua
Normal file
38
ND_Doorlocks/config.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
doorList = {
|
||||
-- Sandy Shores Sheriff office front door.
|
||||
{
|
||||
textCoords = vector3(1855.1896, 3683.4507, 34.2675),
|
||||
authorizedJobs = {"BCSO", "LSPD", "BCSO"},
|
||||
locked = true,
|
||||
accessDistance = 1.5,
|
||||
doors = {
|
||||
{hash = -1765048490, coords = vector3(1855.4108, 3683.3062, 34.2675), heading = 29.9}
|
||||
}
|
||||
},
|
||||
|
||||
-- Paleto bay Sheriff office office front doors.
|
||||
{
|
||||
textCoords = vector3(-443.6129, 6016.0483, 31.7164),
|
||||
authorizedJobs = {"BCSO", "LSPD", "BCSO"},
|
||||
locked = true,
|
||||
accessDistance = 1.5,
|
||||
doors = {
|
||||
{hash = -1501157055, coords = vector3(-443.1538, 6015.5649, 31.7164), heading = 315.0},
|
||||
{hash = -1501157055, coords = vector3(-444.1442, 6016.6621, 31.7164), heading = 135.0}
|
||||
}
|
||||
},
|
||||
|
||||
-- Mission Row Police Station front doors.
|
||||
{
|
||||
textCoords = vector3(434.7345, -981.9468, 30.7102),
|
||||
authorizedJobs = {"BCSO", "LSPD", "BCSO"},
|
||||
locked = true,
|
||||
accessDistance = 1.5,
|
||||
doors = {
|
||||
{hash = -1215222675, coords = vector3(434.8228, -981.1198, 30.6896), heading = 268.0},
|
||||
{hash = 320433149, coords = vector3(434.8228, -982.7103, 30.6896), heading = 272.0}
|
||||
}
|
||||
},
|
||||
}
|
||||
17
ND_Doorlocks/fxmanifest.lua
Normal file
17
ND_Doorlocks/fxmanifest.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
|
||||
author "Andyyy#7666"
|
||||
description "ND Framework Doorlocks for buildings"
|
||||
version "2.0.0"
|
||||
|
||||
fx_version "cerulean"
|
||||
game "gta5"
|
||||
lua54 "yes"
|
||||
|
||||
client_scripts {
|
||||
"config.lua",
|
||||
"source/client.lua"
|
||||
}
|
||||
server_script "source/server.lua"
|
||||
|
||||
dependency "ND_Core"
|
||||
72
ND_Doorlocks/source/client.lua
Normal file
72
ND_Doorlocks/source/client.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
-- 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)
|
||||
local pX, pY, pZ = table.unpack(GetGameplayCamCoords())
|
||||
SetTextScale(0.4, 0.4)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextEntry("STRING")
|
||||
SetTextCentre(true)
|
||||
SetTextColour(255, 255, 255, 255)
|
||||
SetTextOutline()
|
||||
AddTextComponentString(text)
|
||||
DrawText(_x, _y)
|
||||
end
|
||||
|
||||
function getDoorText(locked)
|
||||
if locked then
|
||||
return "Locked [E]"
|
||||
end
|
||||
return "Unlocked [E]"
|
||||
end
|
||||
|
||||
function isAuthorized(door)
|
||||
nearDoor = true
|
||||
for _, authorizedJob in pairs(door.authorizedJobs) do
|
||||
if job == authorizedJob then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
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)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
for doorID, door in pairs(doorList) do
|
||||
if #(pedCoords - door.textCoords) < door.accessDistance and isAuthorized(door) then
|
||||
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)
|
||||
end
|
||||
end
|
||||
if IsControlJustPressed(0, 51) then
|
||||
door.locked = not door.locked
|
||||
TriggerServerEvent("ND_Doorlocks:syncDoor", doorID, door.locked)
|
||||
end
|
||||
end
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("ND_Doorlocks:syncDoor")
|
||||
AddEventHandler("ND_Doorlocks:syncDoor", function(doorID, state)
|
||||
doorList[doorID].locked = state
|
||||
for _, doors in pairs(doorList[doorID].doors) do
|
||||
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)
|
||||
5
ND_Doorlocks/source/server.lua
Normal file
5
ND_Doorlocks/source/server.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
-- For support join my discord: https://discord.gg/Z9Mxu72zZ6
|
||||
RegisterNetEvent("ND_Doorlocks:syncDoor")
|
||||
AddEventHandler("ND_Doorlocks:syncDoor", function(doorID, state)
|
||||
TriggerClientEvent("ND_Doorlocks:syncDoor", -1, doorID, state)
|
||||
end)
|
||||
Reference in New Issue
Block a user