mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat: improved RedM support (#162)
* Improvements + remove redm keybind system as it's pointless
This commit is contained in:
@@ -15,7 +15,7 @@ description 'A library of shared functions to utilise in other resources.'
|
||||
|
||||
--[[ Manifest ]]--
|
||||
dependencies {
|
||||
'/server:5104',
|
||||
'/server:5848',
|
||||
'/onesync',
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
if cache.game == 'redm' then return end
|
||||
|
||||
---@class KeybindProps
|
||||
---@field name string
|
||||
---@field description string
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
if cache.game == 'redm' then return end
|
||||
if not lib.player then lib.player() end
|
||||
|
||||
return function(resource)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
if cache.game == 'redm' then return end
|
||||
if not lib.player then lib.player() end
|
||||
|
||||
return function(resource)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
if cache.game == 'redm' then return end
|
||||
if not lib.player then lib.player() end
|
||||
|
||||
return function(resource)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
if cache.game == 'redm' then return end
|
||||
if not lib.player then lib.player() end
|
||||
|
||||
return function(resource)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
if cache.game == 'redm' then return end
|
||||
--[[
|
||||
This module was experimental and won't be worked on or used further.
|
||||
May be removed in the future.
|
||||
|
||||
2
init.lua
2
init.lua
@@ -144,7 +144,7 @@ end
|
||||
-- Cache
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
cache = { resource = GetCurrentResourceName() }
|
||||
cache = { game = GetGameName(), resource = GetCurrentResourceName() }
|
||||
|
||||
if context == 'client' then
|
||||
setmetatable(cache, {
|
||||
|
||||
8
resource/cache/client.lua
vendored
8
resource/cache/client.lua
vendored
@@ -13,6 +13,8 @@ end
|
||||
local GetVehiclePedIsIn = GetVehiclePedIsIn
|
||||
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
||||
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
|
||||
local GetMount = GetMount
|
||||
local IsPedOnMount = IsPedOnMount
|
||||
local GetCurrentPedWeapon = GetCurrentPedWeapon
|
||||
|
||||
CreateThread(function()
|
||||
@@ -38,6 +40,12 @@ CreateThread(function()
|
||||
cache:set('seat', false)
|
||||
end
|
||||
|
||||
if cache.game == 'redm' then
|
||||
local mount = GetMount(ped)
|
||||
local onMount = IsPedOnMount(ped)
|
||||
cache:set('mount', onMount and mount or false)
|
||||
end
|
||||
|
||||
local hasWeapon, currentWeapon = GetCurrentPedWeapon(ped, true)
|
||||
|
||||
cache:set('weapon', hasWeapon and currentWeapon or false)
|
||||
|
||||
@@ -50,12 +50,13 @@ function lib.showMenu(id, startIndex)
|
||||
end
|
||||
|
||||
if not openMenu then
|
||||
local control = cache.game == 'fivem' and 140 or 0xE30CD707
|
||||
CreateThread(function()
|
||||
while openMenu do
|
||||
if openMenu.disableInput == nil or openMenu.disableInput then
|
||||
DisablePlayerFiring(cache.playerId, true)
|
||||
HudWeaponWheelIgnoreSelection()
|
||||
DisableControlAction(0, 140, true)
|
||||
DisableControlAction(0, control, true)
|
||||
end
|
||||
|
||||
Wait(0)
|
||||
|
||||
@@ -74,32 +74,48 @@ local function startProgress(data)
|
||||
end
|
||||
|
||||
local disable = data.disable
|
||||
local isFivem = cache.game == 'fivem'
|
||||
local controls = {
|
||||
['INPUT_LOOK_LR'] = isFivem and 1 or 0xA987235F,
|
||||
['INPUT_LOOK_UD'] = isFivem and 2 or 0xD2047988,
|
||||
['INPUT_SPRINT'] = isFivem and 21 or 0x8FFC75D6,
|
||||
['INPUT_AIM'] = isFivem and 25 or 0xF84FA74F,
|
||||
['INPUT_MOVE_LR'] = isFivem and 30 or 0x4D8FB4C1,
|
||||
['INPUT_MOVE_UD'] = isFivem and 31 or 0xFDA83190,
|
||||
['INPUT_DUCK'] = isFivem and 36 or 0xDB096B85,
|
||||
['INPUT_VEH_MOVE_LEFT_ONLY'] = isFivem and 63 or 0x9DF54706,
|
||||
['INPUT_VEH_MOVE_RIGHT_ONLY'] = isFivem and 64 or 0x97A8FD98,
|
||||
['INPUT_VEH_ACCELERATE'] = isFivem and 71 or 0x5B9FD4E2,
|
||||
['INPUT_VEH_BRAKE'] = isFivem and 72 or 0x6E1F639B,
|
||||
['INPUT_VEH_EXIT'] = isFivem and 75 or 0xFEFAB9B4,
|
||||
['INPUT_VEH_MOUSE_CONTROL_OVERRIDE'] = isFivem and 106 or 0x39CCABD5
|
||||
}
|
||||
|
||||
while progress do
|
||||
if disable then
|
||||
if disable.mouse then
|
||||
DisableControlAction(0, 1, true)
|
||||
DisableControlAction(0, 2, true)
|
||||
DisableControlAction(0, 106, true)
|
||||
DisableControlAction(0, controls['INPUT_LOOK_LR'], true)
|
||||
DisableControlAction(0, controls['INPUT_LOOK_UD'], true)
|
||||
DisableControlAction(0, controls['INPUT_VEH_MOUSE_CONTROL_OVERRIDE'], true)
|
||||
end
|
||||
|
||||
if disable.move then
|
||||
DisableControlAction(0, 21, true)
|
||||
DisableControlAction(0, 30, true)
|
||||
DisableControlAction(0, 31, true)
|
||||
DisableControlAction(0, 36, true)
|
||||
DisableControlAction(0, controls['INPUT_SPRINT'], true)
|
||||
DisableControlAction(0, controls['INPUT_MOVE_LR'], true)
|
||||
DisableControlAction(0, controls['INPUT_MOVE_UD'], true)
|
||||
DisableControlAction(0, controls['INPUT_DUCK'], true)
|
||||
end
|
||||
|
||||
if disable.car then
|
||||
DisableControlAction(0, 63, true)
|
||||
DisableControlAction(0, 64, true)
|
||||
DisableControlAction(0, 71, true)
|
||||
DisableControlAction(0, 72, true)
|
||||
DisableControlAction(0, 75, true)
|
||||
DisableControlAction(0, controls['INPUT_VEH_MOVE_LEFT_ONLY'], true)
|
||||
DisableControlAction(0, controls['INPUT_VEH_MOVE_RIGHT_ONLY'], true)
|
||||
DisableControlAction(0, controls['INPUT_VEH_ACCELERATE'], true)
|
||||
DisableControlAction(0, controls['INPUT_VEH_BRAKE'], true)
|
||||
DisableControlAction(0, controls['INPUT_VEH_EXIT'], true)
|
||||
end
|
||||
|
||||
if disable.combat then
|
||||
DisableControlAction(0, 25, true)
|
||||
DisableControlAction(0, controls['INPUT_AIM'], true)
|
||||
DisablePlayerFiring(cache.playerId, true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
if cache.game == 'redm' then return end
|
||||
|
||||
---@class VehicleProperties
|
||||
---@field model? string
|
||||
---@field plate? string
|
||||
|
||||
@@ -136,6 +136,13 @@ local function drawLines()
|
||||
end
|
||||
end
|
||||
|
||||
local isFivem = cache.game == 'fivem'
|
||||
local controls = {
|
||||
['INPUT_LOOK_LR'] = isFivem and 1 or 0xA987235F,
|
||||
['INPUT_LOOK_UD'] = isFivem and 2 or 0xD2047988,
|
||||
['INPUT_MP_TEXT_CHAT_ALL'] = isFivem and 245 or 0x9720FCEE
|
||||
}
|
||||
|
||||
local function startCreator(arg)
|
||||
creatorActive = true
|
||||
controlsActive = true
|
||||
@@ -191,9 +198,9 @@ local function startCreator(arg)
|
||||
|
||||
if controlsActive then
|
||||
DisableAllControlActions()
|
||||
EnableControlAction(0, 1, true)
|
||||
EnableControlAction(0, 2, true)
|
||||
EnableControlAction(0, 245, true) -- t
|
||||
EnableControlAction(0, controls['INPUT_LOOK_LR'], true)
|
||||
EnableControlAction(0, controls['INPUT_LOOK_UD'], true)
|
||||
EnableControlAction(0, controls['INPUT_MP_TEXT_CHAT_ALL'], true)
|
||||
local change = false
|
||||
local lStep = steps[1][step]
|
||||
local rStep = steps[2][step]
|
||||
|
||||
Reference in New Issue
Block a user