Cannot disable weapon scroll in vehicle

Hello, I tried to remove the weapon scroll when in a vehicle, but it does not work.
Here is my code:

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5)
        DisableControlAction(0, 16, true)
        DisableControlAction(0, 17, true)
        DisableControlAction(0, 99, true)
        DisableControlAction(0, 100, true)
        DisableControlAction(0, 115, true)
        DisableControlAction(0, 116, true)
        DisableControlAction(0, 261, true)
        DisableControlAction(0, 262, true)
        DisableInputGroup(24)
    end
end

this scrip make player can use weapons in vehicle

Citizen.CreateThread(function()
while true do
  Citizen.Wait(0)
local player = GetPlayerPed(-1)

if IsPedInAnyVehicle(player, false) then
    SetPlayerCanDoDriveBy(PlayerId(), false)
else
 Citizen.Wait(500) --Just for optimize
end

end
end)

Players can already shoot out of the vehicles, but I want to disable the scroll keys, currently I have a key setup that changes the state of the engine by using the mouse scroll.

try this

Citizen.CreateThread(function()
while true do
  Citizen.Wait(0)
local player = GetPlayerPed(-1)

if IsPedInAnyVehicle(player, false) then
        HideHudComponentThisFrame(19)
        DisableControlAction(0, 16, true)
        DisableControlAction(0, 17, true)
        DisableControlAction(0, 99, true)
        DisableControlAction(0, 100, true)
        DisableControlAction(0, 115, true)
        DisableControlAction(0, 116, true)
        DisableControlAction(0, 261, true)
        DisableControlAction(0, 262, true)
        DisableInputGroup(24)
else
 Citizen.Wait(500) --Just for optimize
end

end
end)

Thank you! This worked for me, but I have 1 question, it also disabled the TAB key, is it possible to enable the TAB key and disable the mouse scroll?

The code that is working:

Citizen.CreateThread(function()
    while true do
      Citizen.Wait(0)
    local player = GetPlayerPed(-1)
    
    if IsPedInAnyVehicle(player, false) then
            DisableControlAction(0, 99, true)
    else
     Citizen.Wait(500) --Just for optimize
    end
    
    end
    end)

use DisableControlAction

INPUT_WEAPON_WHEEL_NEXT
INPUT_WEAPON_WHEEL_PREV
INPUT_SELECT_NEXT_WEAPON
INPUT_SELECT_PREV_WEAPON
DisableControlAction(14,true)
DisableControlAction(15,true)
DisableControlAction(16,true)
DisableControlAction(17,true)

ref : https://docs.fivem.net/docs/game-references/controls/#controls

Sorry for the late reaction, I tried using those 4 lines but then I could not move the camera and its still showing the weapons.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.