arciCZ Posted October 7, 2018 Share Posted October 7, 2018 Hi is there a way how to get from Event Handler "onPlayerCommand" a params from command? Or for get command and params is other event handler? Link to comment
Fist Posted October 7, 2018 Share Posted October 7, 2018 I don't understand what you mean. Can you describe better? If you mean how to get parameters from command when typing /command 1 2 3 4 and so on, you need to use event handler "addCommandHandler" and therefore you'll be able to get parameters for that specified command you want. Link to comment
arciCZ Posted October 7, 2018 Author Share Posted October 7, 2018 I want to log players command with his parametrs then when i use /command hello then i want log into variable for next use: Player etc.. used command "/command" with params "hello" Link to comment
Moderators IIYAMA Posted October 7, 2018 Moderators Share Posted October 7, 2018 addCommandHandler("test", function (player, command, ...) iprint("The responsible player/console:", player) iprint("The command:", command) iprint("The arguments:", ...) local arguments = {...} iprint("The first and second argument:", arguments[1], ",", arguments[2]) end) Serverside @arciCZ This is the sky. Link to comment
arciCZ Posted October 7, 2018 Author Share Posted October 7, 2018 @IIYAMA Yes, but I do not need a specific one, but I need it in general for all, no need for a command after a command. Link to comment
Moderators IIYAMA Posted October 7, 2018 Moderators Share Posted October 7, 2018 1 minute ago, arciCZ said: @IIYAMA Yes, but I do not need a specific one, but I need it in general for all, no need for a command after a command. Hmm good question. I think they didn't add this feature in case of passwords and other security/privacy sensitive commands. Link to comment
arciCZ Posted October 7, 2018 Author Share Posted October 7, 2018 @IIYAMA oh okay, i need this because i want to log last 10 commands with params for reports. Link to comment
LyricalMM Posted October 7, 2018 Share Posted October 7, 2018 you can simply just add a log script or admin warn script with an exported function that you can add at each command function to outputChat or outputLog Link to comment
iMr.WiFi..! Posted October 8, 2018 Share Posted October 8, 2018 function onPreFunction( _, _, _, _, _, ... ) local args = {...} removeCommandHandler( args[1] ); addCommandHandler(args[1], function ( player, command, ... ) iprint("The responsible player/console:", player) iprint("The command:", command) iprint("The arguments:", ...) args[2]() end ) end addDebugHook( "preFunction", onPreFunction, {"addCommandHandler"} ) Link to comment
Addlibs Posted October 8, 2018 Share Posted October 8, 2018 (edited) There's OnClientConsole/OnConsole that gives the full command string along with parameters for any command, except /login where the parameters are censored into triple asterisks. I don't believe it gets triggered if you cancelEvent on onPlayerCommand for the same command though. Edited October 8, 2018 by MrTasty Link to comment
arciCZ Posted October 8, 2018 Author Share Posted October 8, 2018 I do that with addCommandHandler and getCommandHandlers thanks for help all. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now