Jump to content

onPlayerCommand gets params?


arciCZ

Recommended Posts

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
  • Moderators
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
  • Moderators
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
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

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.
×
×
  • Create New...