How to stop cheaters from crashing your server

What i think should work is if you will disable kicking and using weapons on motorcycles.
Becouse cheaters crash players that they will set ped without arms and use Crowbar or some other melee weapon and start punching from the motorcycle. Very simple solution to this problem would be this:
anticrasher.lua (266 Bytes)

Very simple script im not the creator!!!
But when i saw it i had an a idea that it would stop the cheaters
Thanks.

Sorry for my english if there is any mistakes

This is good, however it’s bad practice to just have loops running every frame like that.

Here’s a better solution to increase optimizations:

CreateThread(function()
    while true do
        local playerPed = PlayerPedId()
        local isOnBike = IsPedOnAnyBike(playerPed)

        if isOnBike then
            DisableControlAction(0, 345, true)
            Wait(0)
        else
            Wait(500)
        end
    end
end)

This is good aswell, however, it’s bad practice to have an endless ‘while true do’ loop running with no way to end.

Here’s a better solution to allow the script to be quiet during downtime:

playerPed = PlayerPedId()

AddEventHandler("gameEventTriggered", function(event, args)
   if event == "CEventNetworkPlayerEnteredVehicle" then
      while IsPedOnAnyBike(playerPed) do
         Wait(0)
         DisableControlAction(0, 345, true)
      end
   Wait(200)
   DisableControlAction(0, 345, false) --re-enable control after loop stops
   end
end)

Nice solution, thanks for sharing.

One potential problem, PlayerPedId() is not static and can change provided something like SetPlayerModel() is called.

Perhaps move it inside the event above the while loop.

Oh good call! Also I was being a rascal by copying and pasting your comment verbatim.

1 Like

This was already fixed by this pr: fix(gta-streaming-five): skeleton bone index bounds check by tens0rfl0w · Pull Request #3105 · citizenfx/fivem · GitHub
Probably is in canary or beta, so try in those channels.

1 Like