feat: improved RedM support (#162)

* Improvements + remove redm keybind system as it's pointless
This commit is contained in:
Scully
2022-11-25 18:05:55 -08:00
committed by GitHub
parent ed7c04ac9c
commit 231d1c3c77
13 changed files with 60 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ description 'A library of shared functions to utilise in other resources.'
--[[ Manifest ]]-- --[[ Manifest ]]--
dependencies { dependencies {
'/server:5104', '/server:5848',
'/onesync', '/onesync',
} }

View File

@@ -1,3 +1,5 @@
if cache.game == 'redm' then return end
---@class KeybindProps ---@class KeybindProps
---@field name string ---@field name string
---@field description string ---@field description string

View File

@@ -1,3 +1,4 @@
if cache.game == 'redm' then return end
if not lib.player then lib.player() end if not lib.player then lib.player() end
return function(resource) return function(resource)

View File

@@ -1,3 +1,4 @@
if cache.game == 'redm' then return end
if not lib.player then lib.player() end if not lib.player then lib.player() end
return function(resource) return function(resource)

View File

@@ -1,3 +1,4 @@
if cache.game == 'redm' then return end
if not lib.player then lib.player() end if not lib.player then lib.player() end
return function(resource) return function(resource)

View File

@@ -1,3 +1,4 @@
if cache.game == 'redm' then return end
if not lib.player then lib.player() end if not lib.player then lib.player() end
return function(resource) return function(resource)

View File

@@ -1,3 +1,4 @@
if cache.game == 'redm' then return end
--[[ --[[
This module was experimental and won't be worked on or used further. This module was experimental and won't be worked on or used further.
May be removed in the future. May be removed in the future.

View File

@@ -144,7 +144,7 @@ end
-- Cache -- Cache
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
cache = { resource = GetCurrentResourceName() } cache = { game = GetGameName(), resource = GetCurrentResourceName() }
if context == 'client' then if context == 'client' then
setmetatable(cache, { setmetatable(cache, {

View File

@@ -13,6 +13,8 @@ end
local GetVehiclePedIsIn = GetVehiclePedIsIn local GetVehiclePedIsIn = GetVehiclePedIsIn
local GetPedInVehicleSeat = GetPedInVehicleSeat local GetPedInVehicleSeat = GetPedInVehicleSeat
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
local GetMount = GetMount
local IsPedOnMount = IsPedOnMount
local GetCurrentPedWeapon = GetCurrentPedWeapon local GetCurrentPedWeapon = GetCurrentPedWeapon
CreateThread(function() CreateThread(function()
@@ -38,6 +40,12 @@ CreateThread(function()
cache:set('seat', false) cache:set('seat', false)
end 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) local hasWeapon, currentWeapon = GetCurrentPedWeapon(ped, true)
cache:set('weapon', hasWeapon and currentWeapon or false) cache:set('weapon', hasWeapon and currentWeapon or false)

View File

@@ -50,12 +50,13 @@ function lib.showMenu(id, startIndex)
end end
if not openMenu then if not openMenu then
local control = cache.game == 'fivem' and 140 or 0xE30CD707
CreateThread(function() CreateThread(function()
while openMenu do while openMenu do
if openMenu.disableInput == nil or openMenu.disableInput then if openMenu.disableInput == nil or openMenu.disableInput then
DisablePlayerFiring(cache.playerId, true) DisablePlayerFiring(cache.playerId, true)
HudWeaponWheelIgnoreSelection() HudWeaponWheelIgnoreSelection()
DisableControlAction(0, 140, true) DisableControlAction(0, control, true)
end end
Wait(0) Wait(0)

View File

@@ -74,32 +74,48 @@ local function startProgress(data)
end end
local disable = data.disable 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 while progress do
if disable then if disable then
if disable.mouse then if disable.mouse then
DisableControlAction(0, 1, true) DisableControlAction(0, controls['INPUT_LOOK_LR'], true)
DisableControlAction(0, 2, true) DisableControlAction(0, controls['INPUT_LOOK_UD'], true)
DisableControlAction(0, 106, true) DisableControlAction(0, controls['INPUT_VEH_MOUSE_CONTROL_OVERRIDE'], true)
end end
if disable.move then if disable.move then
DisableControlAction(0, 21, true) DisableControlAction(0, controls['INPUT_SPRINT'], true)
DisableControlAction(0, 30, true) DisableControlAction(0, controls['INPUT_MOVE_LR'], true)
DisableControlAction(0, 31, true) DisableControlAction(0, controls['INPUT_MOVE_UD'], true)
DisableControlAction(0, 36, true) DisableControlAction(0, controls['INPUT_DUCK'], true)
end end
if disable.car then if disable.car then
DisableControlAction(0, 63, true) DisableControlAction(0, controls['INPUT_VEH_MOVE_LEFT_ONLY'], true)
DisableControlAction(0, 64, true) DisableControlAction(0, controls['INPUT_VEH_MOVE_RIGHT_ONLY'], true)
DisableControlAction(0, 71, true) DisableControlAction(0, controls['INPUT_VEH_ACCELERATE'], true)
DisableControlAction(0, 72, true) DisableControlAction(0, controls['INPUT_VEH_BRAKE'], true)
DisableControlAction(0, 75, true) DisableControlAction(0, controls['INPUT_VEH_EXIT'], true)
end end
if disable.combat then if disable.combat then
DisableControlAction(0, 25, true) DisableControlAction(0, controls['INPUT_AIM'], true)
DisablePlayerFiring(cache.playerId, true) DisablePlayerFiring(cache.playerId, true)
end end
end end

View File

@@ -1,3 +1,5 @@
if cache.game == 'redm' then return end
---@class VehicleProperties ---@class VehicleProperties
---@field model? string ---@field model? string
---@field plate? string ---@field plate? string

View File

@@ -136,6 +136,13 @@ local function drawLines()
end end
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) local function startCreator(arg)
creatorActive = true creatorActive = true
controlsActive = true controlsActive = true
@@ -191,9 +198,9 @@ local function startCreator(arg)
if controlsActive then if controlsActive then
DisableAllControlActions() DisableAllControlActions()
EnableControlAction(0, 1, true) EnableControlAction(0, controls['INPUT_LOOK_LR'], true)
EnableControlAction(0, 2, true) EnableControlAction(0, controls['INPUT_LOOK_UD'], true)
EnableControlAction(0, 245, true) -- t EnableControlAction(0, controls['INPUT_MP_TEXT_CHAT_ALL'], true)
local change = false local change = false
local lStep = steps[1][step] local lStep = steps[1][step]
local rStep = steps[2][step] local rStep = steps[2][step]