Parse a command out
Hello all,
Sorry for my poor english but I'm french. I want parse a command out, My command is like : Quote:
Maybe a hook is a good solution, i writed this : [code] ---------------------------------------------------------------- -- Variables ---------------------------------------------------------------- local filtre = "false"; ---------------------------------------------------------------- -- Evenement chargement ---------------------------------------------------------------- function GmTool_OnLoad() -- Crée la slash command SlashCmdList["GMTOOL"] = GmTool_perso_Slash; SLASH_GMTOOL1 = "/gt"; end ---------------------------------------------------------------- -- Evenement d'appel de /gt ---------------------------------------------------------------- function GmTool_perso_Slash(cmd) DEFAULT_CHAT_FRAME:AddMessage("Command: " .. cmd); if cmd == "dtoff" then -- Met en place le Hook GmTool_HookAllChatFrames(); -- Met en place l'indicateur de filtre filtre = "true"; end end ---------------------------------------------------------------- -- Hook ---------------------------------------------------------------- function GmTool_HookAllChatFrames() for i=1,NUM_CHAT_WINDOWS do local cf = getglobal("ChatFrame"..i); cf.GmTool_Orig_AddMessage = cf.AddMessage; cf.AddMessage = GmTool_ChatFrame_AddMessage; end end function GmTool_ChatFrame_AddMessage(self, msg) if msg == "Command: test" then DEFAULT_CHAT_FRAME:AddMessage(msg); DEFAULT_CHAT_FRAME:AddMessage(self); end end [/quote] But it's not good :( Thank's for your help. |
This will handle two variables entered for a command.
Code:
function GmTool_OnLoad() |
No, I want the reponse of a command
|
You want a slash command to do something, is that it? In your code you use "/gt dtoff" to do GmTool_HookAllChatFrames();
Your slash code is just a bit off then. You need parenthesis in your IF statement. Like this: ---------------------------------------------------------------- -- Evenement d'appel de /gt ---------------------------------------------------------------- function GmTool_perso_Slash(cmd) DEFAULT_CHAT_FRAME:AddMessage("Command: " .. cmd); if (cmd == "dtoff") then -- Met en place le Hook GmTool_HookAllChatFrames(); -- Met en place l'indicateur de filtre filtre = "true"; end end I thought you were trying to parse a command with options like in your first example: aaaaa 18 eeeee With aaaaa being the slash command and 18 eeeee being the options for that command. I also noticed a problem with your GmTool_HookAllChatFrames() function. This line - cf.AddMessage = GmTool_ChatFrame_AddMessage Try changing it to this GmTool_ChatFrame_AddMessage(cf.AddMessage); This will call your AddMessage function with your message as a variable. You will need to remove the Self from function GmTool_ChatFrame_AddMessage(self, msg) because there is nothing defining it in your code (whats Self supposed to be anyway?). |
Thank's, I will try
|
In game, I have a command, this command return a string and i want find this string to parse and extract an int value.
What is the best solution please ? Hook ? For example when I write in chat room : Quote:
Quote:
|
up please :'(
|
what's wrong with slash commands (/command) ?
Why do you want to imitate private server gm commands (.command) ? |
Thank's for your reponse.
For more information : I want create an addon for gm private server. |
well, private servers are not supported, condoned, or endorsed here.
|
Quote:
|
All times are GMT -6. The time now is 07:22 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI