Hello guys ive seen many struggling with blocking the combatroll and ive got the best performed way for you to block it.
Simply add this code in any client.lua
CreateThread(function()
while true do
local wait_time = 1000
if IsPedArmed(PlayerPedId(), 4 or 2) and IsPlayerFreeAiming(PlayerId()) then
wait_time = 0
DisableControlAction(0, 22, true)
end
Wait(wait_time)
end
end)
there is a problem in your snippet if i am armed i cant jump, you should check if player is armed and then check if player is aiming then block the key not when player is armed
Citizen.CreateThread(function()
while true do
Citizen.Wait(5)
if IsPedArmed(GetPlayerPed(-1), 4 | 2) then
DisableControlAction(0, 22, true)
end
end
end)
Alternatively as of f2f9858 you are able to now directly see if a ped is doing CTaskCombatRoll.
You may run another thread as a failsafe if they managed to get past the disabled control:
Citizen.CreateThread(function()
while true do
local playerPed = PlayerPedId()
local isCombatRolling = GetIsTaskActive(playerPed, 3)
if isCombatRolling then
ClearPedTasksImmediately(playerPed)
end
Citizen.Wait(100) -- Short Enough
end
end)
There is probably a more professional way of doing this, but it’s good enough.