Phoenix-Roleplay Posted July 24, 2012 Posted July 24, 2012 Simple problem, I am not familiar with using executeCommandHandler nor working with using "..." but it just fails to execute everytime. local execcmd = nil function executeCommand(thePlayer, commandName, exeCmd, targetPlayer, ...) if(exports.global:isPlayerOwner(thePlayer))then if not (exeCmd) or not (targetPlayer) then outputChatBox("Syntax: /"..commandName.." [player id] [cmd name] [arguments]", thePlayer, 255, 0, 0) return end if(...)then execcmd = executeCommandHandler(exeCmd,targetPlayer,...) if(execcmd)then outputChatBox("Command Execution successful!", thePlayer, 0, 255, 0) else outputChatBox("Command Execution failed!", thePlayer, 255, 0, 0) end else execcmd = executeCommandHandler(exeCmd,targetPlayer) if(execcmd)then outputChatBox("Command Execution successful!", thePlayer, 0, 255, 0) else outputChatBox("Command Execution failed!", thePlayer, 255, 0, 0) end end else outputChatBox("This.",thePlayer,255,0,0) end end addCommandHandler("exec", executeCommand) All kinds of feedback are welcome on all of my posts.
robhol Posted July 24, 2012 Posted July 24, 2012 /aexec Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
Phoenix-Roleplay Posted July 24, 2012 Author Posted July 24, 2012 /aexec Yep, I know. My server doesn't use the ACL so much, it uses a SQL to check for admin. It's a completely seperate basis for the server. All kinds of feedback are welcome on all of my posts.
robhol Posted July 24, 2012 Posted July 24, 2012 The thing is that you can't really use executeCommandHandler for everything. Aexec works for MTA commands too, while executeCommandHandler just works for scripted command handlers. Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
Phoenix-Roleplay Posted July 24, 2012 Author Posted July 24, 2012 The thing is that you can't really use executeCommandHandler for everything. Aexec works for MTA commands too, while executeCommandHandler just works for scripted command handlers. Right. And thats all I want it to do, is work for the commands I have scripted. All kinds of feedback are welcome on all of my posts.
Dev Posted July 24, 2012 Posted July 24, 2012 I believe the problem is that you cannot execute a command which isn't in the .lua file which contains the executeCommandHandler function of yours itself, i.e, the command you're trying to execute is in a separate .lua file. "First they ignore you, then they laugh at you, then they fight you, then you win." - Mahatma Gandhi (1869-1948)
Al3grab Posted July 24, 2012 Posted July 24, 2012 addCommandHandler("exec",function(Me,Cmd,pName,Cmd,...) -- pName : The other player name | Cmd : the command to execute | ... : arguments if ( exports.global:isPlayerOwner(thePlayer) ) then if ( not pName or not Cmd ) then outputChatBox("Syntax: /"..Cmd.." [player name] [cmd name] [arguments]", Me, 255, 0, 0) return end local args = table.concat({...}," ") local target = getPlayerFromName(pName) if not target then outputChatBox("Player does not exist!",Me,255,0,0,true) return end if executeCommandHandler(Cmd,target,tostring(args)) then outputChatBox("Command Execution successful!", Me, 0, 255, 0) else outputChatBox("Command Execution failed!", Me, 255, 0, 0) end else outputChatBox("This.",Me,255,0,0) end end ) Using this function : https://wiki.multitheftauto.com/wiki/Get ... omNamePart will be good. ING : [xXx]~Al3grab
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