From 221562208ea45613d3e07405b1e79f5cfec0992e Mon Sep 17 00:00:00 2001 From: HC DEV <36608116+ArturMichalak@users.noreply.github.com> Date: Thu, 16 May 2024 16:52:26 +0200 Subject: [PATCH] feat: prevent seat switching when handcuffed or fastened * feat: debug thrist and hunger commands refactor: rename addHunger, addThirst to setHunger, setThirst, remove redundant code fix: hotfix qbx_core #457 * refactor: remove debug codes * fix: remove debug commands * feat: server use of the event * feat: exports for serwer side functions refactor: fix to own function chore: thirst and hunger summaries fix * revisions for `ox_inventory` QB bridge compatibility * feat: restore server side events trigger and hotfix * feat: conditional shuffle seat --------- Co-authored-by: xHorntail --- locales/en.json | 7 +++++-- qbx_noshuff/client.lua | 14 ++++++++++++-- qbx_noshuff/config.json | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 qbx_noshuff/config.json diff --git a/locales/en.json b/locales/en.json index b0db574..df401bb 100644 --- a/locales/en.json +++ b/locales/en.json @@ -6,7 +6,9 @@ "deleted_recording": "Deleted Recording!", "later_aligator": "Later aligator!", "stress_gain": "Feeling More Stressed!", - "no_vehicle_nearby": "No Vehicle Nearby For Flipping." + "no_vehicle_nearby": "No Vehicle Nearby For Flipping.", + "is_handcuffed": "You are handcuffed.", + "is_fastened": "You wear a seat belt." }, "success": { "cruise_control_enabled": "Cruise control enabled", @@ -30,7 +32,8 @@ }, "info": { "minutes": "minutes", - "seconds": "seconds.." + "seconds": "seconds..", + "shuffleSeat": "Shuffle seat" }, "actions": { "push_vehicle": "Press [~g~SHIFT~w~] and [~g~E~w~] to push the vehicle until [~g~SHIFT~w~] release", diff --git a/qbx_noshuff/client.lua b/qbx_noshuff/client.lua index e16fd75..68f0f25 100644 --- a/qbx_noshuff/client.lua +++ b/qbx_noshuff/client.lua @@ -1,3 +1,5 @@ +local config = lib.loadJson('qbx_noshuff.config') + ---Disables auto seat switching ---@param seatIndex number local function disableAutoShuffle(seatIndex) @@ -12,6 +14,14 @@ lib.onCache('seat', disableAutoShuffle) ---Makes the player ped shuffle to the next vehicle seat. local function shuffleSeat(self) + if QBX.PlayerData.metadata.ishandcuffed then + return exports.qbx_core:Notify(locale('error.is_handcuffed'), 'error') + end + + if LocalPlayer.state.seatbelt then + return exports.qbx_core:Notify(locale('error.is_fastened'), 'error') + end + self:disable(true) if cache.vehicle and cache.seat then TaskShuffleToNextVehicleSeat(cache.ped, cache.vehicle) @@ -24,7 +34,7 @@ end lib.addKeybind({ name = 'shuffleSeat', - description = '', - defaultKey = 'O', + description = locale('info.shuffleSeat'), + defaultKey = config.shuffleSeatKey, onPressed = shuffleSeat }) diff --git a/qbx_noshuff/config.json b/qbx_noshuff/config.json new file mode 100644 index 0000000..5bf3f2f --- /dev/null +++ b/qbx_noshuff/config.json @@ -0,0 +1,3 @@ +{ + "shuffleSeatKey": "O" +}