Jump to content

onPlayerCommand gets params?


arciCZ

Recommended Posts

Posted

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?

Posted

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.

Posted

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"

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

 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
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"} )

 

Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة

ليس عليك اسعاد الجميع ,
ولكن عليك بإن لا تؤذي أحداً 

=========
You do not have to make everyone happy,
But you should not hurt anyone

 

Want to contact with me?

 

Discord: JustCarry#2616 (Always there)
Skype: Live:JustCarry10 (Not always)

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...