-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handcuffing and dependency checks
* fix(server/commands): usable * feat(server/main): dependency and version checks * fix(server/commands): job checks * fix(server/main): missing table initiation * feat: handcuffing * fix(server): event name * fix(client/interactions): adjust invBusy positioning * fix(server/interactions): unhandcuffed event * fix(client/interactions): remove wait for skillcheck * feat: config option to consume handcuffs
- Loading branch information
Showing
4 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
local disabledControls = { | ||
21, -- Sprint | ||
24, -- Attack | ||
257, -- Attack 2 | ||
25, -- Aim | ||
263, -- Melee Attack 1 | ||
45, -- Reload | ||
22, -- Jump | ||
44, -- Cover | ||
37, -- Select Weapon | ||
23, -- Enter vehicle | ||
288, -- Disable phone | ||
289, -- Inventory | ||
170, -- Animations | ||
167, -- Job | ||
26, -- Disable looking behind | ||
73, -- Disable clearing animation | ||
199, -- Disable pause screen | ||
59, -- Disable steering in vehicle | ||
71, -- Disable driving forward in vehicle | ||
72, -- Disable reversing in vehicle | ||
36, -- Disable going stealth | ||
264, -- Disable melee | ||
257, -- Disable melee | ||
140, -- Disable melee | ||
141, -- Disable melee | ||
142, -- Disable melee | ||
143, -- Disable melee | ||
75 -- Disable exit vehicle | ||
} | ||
|
||
lib.callback.register('qbx_police:client:getHandcuffed', function() | ||
ClearPedTasksImmediately(cache.ped) | ||
SetCurrentPedWeapon(cache.ped, `WEAPON_UNARMED`, true) | ||
FreezeEntityPosition(cache.ped, true) | ||
|
||
LocalPlayer.state.invBusy = true | ||
|
||
local success = lib.skillCheck('medium') | ||
|
||
lib.playAnim('mp_arrest_paired', 'crook_p2_back_right', 8.0, 8.0, 3750, 48, 0.0, false, 0, false) | ||
Wait(3750) | ||
|
||
if success then | ||
lib.disableControls:Add(disabledControls) | ||
lib.disableRadial(true) | ||
else | ||
LocalPlayer.state.invBusy = false | ||
end | ||
|
||
FreezeEntityPosition(cache.ped, false) | ||
|
||
return not success | ||
end) | ||
|
||
RegisterNetEvent('qbx_police:client:handcuffPlayer', function() | ||
SetCurrentPedWeapon(cache.ped, `WEAPON_UNARMED`, true) | ||
FreezeEntityPosition(cache.ped, true) | ||
|
||
lib.playAnim('mp_arrest_paired', 'cop_p2_back_right', 8.0, 8.0, 3750, 48, 0.0, false, 0, false) | ||
Wait(3750) | ||
|
||
FreezeEntityPosition(cache.ped, false) | ||
end) | ||
|
||
RegisterNetEvent('qbx_police:client:getUnhandcuffed', function() | ||
FreezeEntityPosition(cache.ped, true) | ||
|
||
lib.playAnim('mp_arresting', 'b_uncuff', 8.0, 8.0, 5500, 48, 0.0, false, 0, false) | ||
Wait(5500) | ||
|
||
lib.disableControls:Remove(disabledControls) | ||
lib.disableRadial(false) | ||
|
||
LocalPlayer.state.invBusy = false | ||
|
||
FreezeEntityPosition(cache.ped, false) | ||
end) | ||
|
||
RegisterNetEvent('qbx_police:client:unhandcuffPlayer', function() | ||
SetCurrentPedWeapon(cache.ped, `WEAPON_UNARMED`, true) | ||
FreezeEntityPosition(cache.ped, true) | ||
|
||
lib.playAnim('mp_arresting', 'a_uncuff', 8.0, 8.0, 3750, 48, 0.0, false, 0, false) | ||
Wait(3750) | ||
|
||
FreezeEntityPosition(cache.ped, false) | ||
end) | ||
|
||
CreateThread(function() | ||
while LocalPlayer.state.handcuffed do | ||
if not IsEntityPlayingAnim(cache.ped, 'mp_arresting', 'idle', 3) then | ||
lib.playAnim('mp_arresting', 'idle', 8.0, 8.0, -1, 48, 0.0, false, 0, false) | ||
end | ||
|
||
lib.disableControls() | ||
|
||
Wait(0) | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
local config = require 'config.server' | ||
|
||
local function handcuff(source) | ||
local playerPed = GetPlayerPed(source) | ||
local playerCoords = GetEntityCoords(playerPed) | ||
local targetId, _, _ = lib.getClosestPlayer(playerCoords, 1.0) | ||
|
||
if not targetId or Player(targetId).state.handcuffed then return end | ||
|
||
TriggerClientEvent('qbx_police:client:handcuffPlayer', source) | ||
|
||
local targetCuffed = lib.callback.await('qbx_police:client:getHandcuffed', targetId) | ||
|
||
if not targetCuffed then return end | ||
|
||
if config.consumeHandcuffs then | ||
exports.ox_inventory:RemoveItem(source, 'handcuffs', 1) | ||
end | ||
|
||
Player(targetId).state:set('handcuffed', true, true) | ||
exports.qbx_core:SetMetadata(targetId, 'handcuffed', true) | ||
end | ||
|
||
exports.qbx_core:CreateUseableItem('handcuffs', handcuff) | ||
|
||
local function unhandcuff(source) | ||
local playerPed = GetPlayerPed(source) | ||
local playerCoords = GetEntityCoords(playerPed) | ||
local targetId, _, _ = lib.getClosestPlayer(playerCoords, 1.0) | ||
|
||
if not targetId or not Player(targetId).state.handcuffed then return end | ||
|
||
TriggerClientEvent('qbx_police:client:unhandcuffPlayer', source) | ||
TriggerClientEvent('qbx_police:client:getUnhandcuffed', targetId) | ||
|
||
if config.consumeHandcuffs then | ||
exports.ox_inventory:AddItem(source, 'handcuffs', 1) | ||
end | ||
|
||
Player(targetId).state:set('handcuffed', true, true) | ||
exports.qbx_core:SetMetadata(targetId, 'handcuffed', false) | ||
end | ||
|
||
exports.qbx_core:CreateUseableItem('handcuff_key', unhandcuff) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters