Feche1320 Posted July 22, 2011 Share Posted July 22, 2011 Hello, is there any resource to convert the /command to !command aswell? I have more than 150 commands to convert.. Thanks. Link to comment
Feche1320 Posted July 22, 2011 Author Share Posted July 22, 2011 I mean, to use / and ! at the same time, now I have / commands, but some people like(like old race) the ! command prefix too, so I was asking is there is a resource that can make that for me, becouse I have more than 150 commands. Thanks. Link to comment
Aibo Posted July 22, 2011 Share Posted July 22, 2011 you can use onPlayerChat event to check for commands and execute those you already have added. somthing like this: function retroCommands(text) if text:find("!", 1, 1) then -- check if text starts with ! local command = gettok(text, 1, 32):sub(2) -- get command name without ! if #command > 0 then local arguments = text:sub(#command+3) -- separate command from arguments (if any) -- you can do it other way: = text:gsub("!"..command, "") executeCommandHandler(command, source, arguments) -- your resource needs access to executeCommandHandler end end end addEventHandler("onPlayerChat", getRootElement(), retroCommands) and you may want to cancelEvent() to hide the command input. just note that if you don't cancel, chat output will show after the command is executed. Link to comment
Feche1320 Posted July 22, 2011 Author Share Posted July 22, 2011 you can use onPlayerChat event to check for commands and execute those you already have added.somthing like this: function retroCommands(text) if text:find("!", 1, 1) then -- check if text starts with ! local command = gettok(text, 1, 32):sub(2) -- get command name without ! if #command > 0 then local arguments = text:sub(#command+3) -- separate command from arguments (if any) -- you can do it other way: = text:gsub("!"..command, "") executeCommandHandler(command, source, arguments) -- your resource needs access to executeCommandHandler end end end addEventHandler("onPlayerChat", getRootElement(), retroCommands) and you may want to cancelEvent() to hide the command input. just note that if you don't cancel, chat output will show after the command is executed. Thanks!! 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