banmandan

[QUESTION] How to output every command entered into console

Recommended Posts

I was curious if it was possible to output every single command entered into console?

 

For example:

No matter which command a player enters, it’ll output on console. I know you can add this call to a regular function, but you’d need to tie it to every command manually, and when there’s over 300 commands it’s hard to get every one of them.

 

So to recap, even if it’s not a valid command I’d like it to be sent to console - can this be done?

Share this post


Link to post
addEventHandler("onClientConsole", localPlayer,
  function (text)
    local args = split(text, " ") -- split the text by spaces
    local command = table.remove(args, 1) -- remove the first word from the args table and put it into the "command" variable
    
    outputConsole(command)
  end
)

This should work, but I haven't tested it. This is clientside code by the way. You can use onConsole on the server but I believe that won't trigger for commands handled by a command handler.

Edited by MrTasty
  • Thanks 1

Share this post


Link to post

Server Side :

addEventHandler( 'onPlayerCommand' , root , 
function( command )  
    	outputConsole( table.concat( { command } , ' ' ) , source )
    end
)  

 

Edited by KillerX
  • Thanks 1

Share this post


Link to post
51 minutes ago, KillerX said:

Server Side :


addEventHandler( 'onPlayerCommand' , root , 
function( command )  
    	outputConsole( table.concat( { command } , ' ' ) , source )
    end
)  

 

Thank you, I will try this too!

 

Much appreciated

  • Like 1

Share this post


Link to post
1 hour ago, KillerX said:

Server Side :


addEventHandler( 'onPlayerCommand' , root , 
function( command )  
    	outputConsole( table.concat( { command } , ' ' ) , source )
    end
)  

 

It does not appear to be working

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.