Disable Leaning

I would like to disable lean firing when taking cover or pressing “Q” against a cover. Here’s a code of mine. I am really new to Lua.

function disableLean(GetPlayerPed)
SetPlayerCanUseCover(GetPlayerPed(-1), false)
end

That would probably make it unable to even take cover when pressing Q (hiding behind a object) so instead this might work:

CreateThread(function()

SetPedCanPeekInCover(GetPlayerPed(-1),false)

end)

There is no need to put that in a loop, but if you want to disable it completly use the function you mentioned above SetPlayerCanUseCover

1 Like

I really want to disable the “Q” completely, so I will be using my code above correct?

yes it is correct

I’ve tried this ingame and I can still use “Q” or lean against an object. Why is it still working despite running the script already?

P.S tried this on localhost server

Do something like:

Citizen.CreateThread(function()
  while true do
    Citizen.Wait(5)
    SetPlayerCanUseCover(GetPlayerPed(-1), false)
  end
end)

Still tried it with my localhost server with your code ChieF-TroN, I can still “Q” or take cover.

SetPlayerCanUseCover wants PlayerID not GetPlayerPed… just use SetPlayerCanUseCover(PlayerId(), false)
even the name sais player not ped

So does this mean this code only works in online server? Not on localhost?

ahahahah no… that means you must just pass the parameter i told you… localhost or different server is the same thing…

So if I use the code “SetPlayerCanUseCover(GetPlayerPed(-1), false)”, all active players won’t be able to use “Q” or lean?

no!! you must use SetPlayerCanUseCover(PlayerId(), false)
try it

Thank you so much guys! It worked. <3

is there a way to disable left control ?

DisableControlAction

is no working

where can i find the leaning script?

–disable lean –

Citizen.CreateThread(function()
while true do
Citizen.Wait(5)

  SetPlayerCanUseCover(PlayerId(), false)
end

end)

– put in any client.lua

1 Like

thank you

need help reenabling wall cover in my server, its not working for some reason