Jump to content

getCommandHandlers


xXMADEXx

Recommended Posts

Hello.

First of all I don't know if there's another method to this, because I haven't really looked into it very much, but I think MTA should make getCommandHandlers.

I think that MTA should make the function getCommandHandlers that returns a table of commands so that players could try to detect if a script has a backdoor or not. Maybe there should be an argument of the resource you want to get, but if it's not set then it will just return all commands. This way people could just run a basic script such as:

for i, v in pairs ( getCommandHandlers ( resourceRoot  ) ) do 
    outputChatBox ( "Command: ".. tostring ( i ).." | Callback: "..tostring ( v ) ) 
end 

and they would know if the script has an obvious backdoor, even if it's compiled.

The returned table should be something like the following:

{ 
    ['CommandName'] = { 
        resource = "The resource element where the command is located", 
        callback = "The function the command executes", 
        restricted = "restricted from addCommandHandler", 
        caseSensitive = "is the command case sensitive" 
    }, 
  
    -- example: 
    ['newcar'] = { 
        resource = getResourceFromName ( "core_commands" ), 
        callback = function ( ) end, 
        restricted = false, 
        caseSensitive = true 
    } 
} 

Link to comment
local addCommandHandler_real = addCommandHandler 
  
function addCommandHandler(...) 
    local added = addCommandHandler_real(...) 
    if added then 
        local commandName = ... 
        outputChatBox("Added command: "..commandName) 
    end 
    return added 
end 

Link to comment
local addCommandHandler_real = addCommandHandler 
  
function addCommandHandler(...) 
    local added = addCommandHandler_real(...) 
    if added then 
        local commandName = ... 
        outputChatBox("Added command: "..commandName) 
    end 
    return added 
end 

I'm a freaking idiot :oops: idk why i didn't think of just re-writing the function :C

Link to comment
  • 3 weeks later...
  • 2 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...