Skip to content

Commit

Permalink
feat: prevent seat switching when handcuffed or fastened
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
artur-michalak and xhorntail authored May 16, 2024
1 parent 8943b42 commit 2215622
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 5 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 12 additions & 2 deletions qbx_noshuff/client.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local config = lib.loadJson('qbx_noshuff.config')

---Disables auto seat switching
---@param seatIndex number
local function disableAutoShuffle(seatIndex)
Expand All @@ -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)
Expand All @@ -24,7 +34,7 @@ end

lib.addKeybind({
name = 'shuffleSeat',
description = '',
defaultKey = 'O',
description = locale('info.shuffleSeat'),
defaultKey = config.shuffleSeatKey,
onPressed = shuffleSeat
})
3 changes: 3 additions & 0 deletions qbx_noshuff/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"shuffleSeatKey": "O"
}

0 comments on commit 2215622

Please sign in to comment.