I want to disable weapon usage when switching between routing buckets?

I want to disable the use of weapons when switching between buckets. For example, when the bucket is at 0, the weapon can be used.But the player will not be able to use weapons while in bucket 1. How can I do that?

Hi, I would have use Server-Client communication with Net Events. In this practice I’ve used server side verification for actual routing. I hope you understand this, feel free to ask.

Client:

local disabled = false
RegisterNetEvent("switchRoutingBucket")
AddEventHandler("switchRoutingBucket", function(state)
    disabled = state    -- Client gets the routing information from the server.
end)


CreateThread(function()
    while true do
        if (disabled) then
            DisableControlAction(0, 25, true)    --Disable right click
            DisableControlAction(0, 24, true)    --Disable left click
        end
       Wait(disabled and 0 or 1000)    --Optimize if disabled is false, the loop should not run at every tick.
   end
end)

I don’t know when you want to switch routing, so I made it in RegisterCommand way.
Server:

RegisterCommand("switchRoute", function(source, args)
     -- if player gives argument, then routing it's bucket to the entered one, default is 0.
     local route = args[1] and args[1] or 0
     SetPlayerRoutingBucket(source, route)
    
     
     --Tell its client that routing bucket has been changed. Send to it which route the player uses.
     -- It recevies a boolean, which is true when its not zero.
     TriggerClientEvent("switchRoutingBucket", source, route ~= 0)
end)
1 Like

Thanks for your help. The codes worked.