Skip to content

Conversation

MohabCodeX
Copy link
Contributor

Usage

Testing Script
-- Client-side
addEventHandler("onClientCommand", root, function(command, ...)
    if command == "restricted" then
        cancelEvent() 
        outputChatBox("This command is disabled!", 255, 100, 100)
    end
end)


addEventHandler("onClientCommand", root, function(command, ...)
    local args = {...}
    local executedByFunction = args[#args]
    table.remove(args, #args) 
    
    local blockedCommands = {"run", "exec", "execute", "lua", "script"}
    for _, blocked in ipairs(blockedCommands) do
        if command == blocked then
            cancelEvent()
            triggerServerEvent("onPlayerUsedExecutor", localPlayer, command)
            return
        end
    end
    
    if not executedByFunction then
        local currentTime = getTickCount()
        if currentTime - (lastCommandTime or 0) < 100 then
            triggerServerEvent("onPlayerUsedExecutor", localPlayer, "rapid_execution")
        end
        lastCommandTime = currentTime
    end
end)

-- Server-side

addEvent("onPlayerUsedExecutor", true)
addEventHandler("onPlayerUsedExecutor", root, function(reason)
    banPlayer(client, true, false, false, 0, "Lua executor detected: " .. reason)
end)

Fixes #3160

@FileEX FileEX added the enhancement New feature or request label Sep 7, 2025
@MohabCodeX MohabCodeX requested a review from FileEX September 8, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'onPlayerCommand' event for client-side
3 participants