mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
159 lines
4.4 KiB
Lua
159 lines
4.4 KiB
Lua
local self = ESX.Modules['job_police']
|
|
|
|
-- Init
|
|
self.Init()
|
|
|
|
-- Drag
|
|
Citizen.CreateThread(function()
|
|
|
|
local wasDragged = false
|
|
|
|
while true do
|
|
Citizen.Wait(0)
|
|
local playerPed = PlayerPedId()
|
|
|
|
if self.IsHandcuffed and self.DragStatus.isDragged then
|
|
|
|
local targetPed = GetPlayerPed(GetPlayerFromServerId(self.DragStatus.CopId))
|
|
|
|
if DoesEntityExist(targetPed) and IsPedOnFoot(targetPed) and not IsPedDeadOrDying(targetPed, true) then
|
|
|
|
if not wasDragged then
|
|
AttachEntityToEntity(playerPed, targetPed, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
|
|
wasDragged = true
|
|
else
|
|
Citizen.Wait(1000)
|
|
end
|
|
|
|
else
|
|
|
|
wasDragged = false
|
|
self.DragStatus.isDragged = false
|
|
DetachEntity(playerPed, true, false)
|
|
|
|
end
|
|
|
|
elseif wasDragged then
|
|
|
|
wasDragged = false
|
|
DetachEntity(playerPed, true, false)
|
|
|
|
else
|
|
|
|
Citizen.Wait(500)
|
|
|
|
end
|
|
|
|
end
|
|
end)
|
|
|
|
-- Handcuff
|
|
Citizen.CreateThread(function()
|
|
while true do
|
|
Citizen.Wait(0)
|
|
local playerPed = PlayerPedId()
|
|
|
|
if self.IsHandcuffed then
|
|
DisableControlAction(0, 1, true) -- Disable pan
|
|
DisableControlAction(0, 2, true) -- Disable tilt
|
|
DisableControlAction(0, 24, true) -- Attack
|
|
DisableControlAction(0, 257, true) -- Attack 2
|
|
DisableControlAction(0, 25, true) -- Aim
|
|
DisableControlAction(0, 263, true) -- Melee Attack 1
|
|
DisableControlAction(0, 32, true) -- W
|
|
DisableControlAction(0, 34, true) -- A
|
|
DisableControlAction(0, 31, true) -- S
|
|
DisableControlAction(0, 30, true) -- D
|
|
|
|
DisableControlAction(0, 45, true) -- Reload
|
|
DisableControlAction(0, 22, true) -- Jump
|
|
DisableControlAction(0, 44, true) -- Cover
|
|
DisableControlAction(0, 37, true) -- Select Weapon
|
|
DisableControlAction(0, 23, true) -- Also 'enter'?
|
|
|
|
DisableControlAction(0, 288, true) -- Disable phone
|
|
DisableControlAction(0, 289, true) -- Inventory
|
|
DisableControlAction(0, 170, true) -- Animations
|
|
DisableControlAction(0, 167, true) -- Job
|
|
|
|
DisableControlAction(0, 0, true) -- Disable changing view
|
|
DisableControlAction(0, 26, true) -- Disable looking behind
|
|
DisableControlAction(0, 73, true) -- Disable clearing animation
|
|
DisableControlAction(2, 199, true) -- Disable pause screen
|
|
|
|
DisableControlAction(0, 59, true) -- Disable steering in vehicle
|
|
DisableControlAction(0, 71, true) -- Disable driving forward in vehicle
|
|
DisableControlAction(0, 72, true) -- Disable reversing in vehicle
|
|
|
|
DisableControlAction(2, 36, true) -- Disable going stealth
|
|
|
|
DisableControlAction(0, 47, true) -- Disable weapon
|
|
DisableControlAction(0, 264, true) -- Disable melee
|
|
DisableControlAction(0, 257, true) -- Disable melee
|
|
DisableControlAction(0, 140, true) -- Disable melee
|
|
DisableControlAction(0, 141, true) -- Disable melee
|
|
DisableControlAction(0, 142, true) -- Disable melee
|
|
DisableControlAction(0, 143, true) -- Disable melee
|
|
DisableControlAction(0, 75, true) -- Disable exit vehicle
|
|
DisableControlAction(27, 75, true) -- Disable exit vehicle
|
|
|
|
if IsEntityPlayingAnim(playerPed, 'mp_arresting', 'idle', 3) ~= 1 then
|
|
ESX.Streaming.RequestAnimDict('mp_arresting', function()
|
|
TaskPlayAnim(playerPed, 'mp_arresting', 'idle', 8.0, -8, -1, 49, 0.0, false, false, false)
|
|
end)
|
|
end
|
|
else
|
|
Citizen.Wait(500)
|
|
end
|
|
end
|
|
end)
|
|
|
|
--[[
|
|
-- Enter / Exit entity zone events
|
|
Citizen.CreateThread(function()
|
|
local trackedEntities = {
|
|
'prop_roadcone02a',
|
|
'prop_barrier_work05',
|
|
'p_ld_stinger_s',
|
|
'prop_boxpile_07d',
|
|
'hei_prop_cash_crate_half_full'
|
|
}
|
|
|
|
while true do
|
|
Citizen.Wait(500)
|
|
|
|
local playerPed = PlayerPedId()
|
|
local playerCoords = GetEntityCoords(playerPed)
|
|
|
|
local closestDistance = -1
|
|
local closestEntity = nil
|
|
|
|
for i=1, #trackedEntities, 1 do
|
|
local object = GetClosestObjectOfType(playerCoords, 3.0, GetHashKey(trackedEntities[i]), false, false, false)
|
|
|
|
if DoesEntityExist(object) then
|
|
local objCoords = GetEntityCoords(object)
|
|
local distance = #(playerCoords - objCoords)
|
|
|
|
if closestDistance == -1 or closestDistance > distance then
|
|
closestDistance = distance
|
|
closestEntity = object
|
|
end
|
|
end
|
|
end
|
|
|
|
if closestDistance ~= -1 and closestDistance <= 3.0 then
|
|
if LastEntity ~= closestEntity then
|
|
TriggerEvent('esx_policejob:hasEnteredEntityZone', closestEntity)
|
|
LastEntity = closestEntity
|
|
end
|
|
else
|
|
if LastEntity then
|
|
TriggerEvent('esx_policejob:hasExitedEntityZone', LastEntity)
|
|
LastEntity = nil
|
|
end
|
|
end
|
|
end
|
|
end)
|
|
]]--
|