• Derma Question
    3 replies, posted
How can I make it so, when somebody says something specific in chat (e.g. /somethingspecific hi etc etc etc...) to show up in a derma menu (without the "/somethingspecific" of course) So, basically a chat command that prints to a menu. For example: If I said "/request can I have a lollipop?" Then "can I have a lollipop?" would show up in the menu. [highlight](User was banned for this post ("Undescriptive thread title" - Gran PC))[/highlight]
[CODE]local command = { "!server", "!servers", "/server", "/servers", }[/CODE] just put this before the actually command
Didn't work. Let me just clear up what I wanted to do. If I said "/request can I have a lollipop?" Then "can I have a lollipop?" would show up in the menu.
Somthing along the lines of this would work. You may have to play around with it. This code hasn't been fully test for extracting the string. Getting the chat command to work should work fine. [lua] if SERVER then -- Add a hook to player chat hook.Add("PlayerSay", "UniqueChatHook", function(Player, Text, Public) -- Check if the text starts with a / if Text[1] == "/" then -- Make the text all lowercase Text = Text:lower() -- Check if the text is "/somethingspecific". If so, run the console command if Text == "/somethingspecific" then -- Do something. This may work but you might have to play around with the sub string yourVariable = string.sub(Text, string.len("/somethingspecific")+1) functionToCall(yourVariable) return "" end end end) end [/lua]
Sorry, you need to Log In to post a reply to this thread.