• Chat Command Hook
    3 replies, posted
Hello, I am scripting a simple gamemode, and I would like to know how i could add a Lua hook so when the player types a certain thing in chat, things happen. For example: Player Types /buymenu Chat Command Is Hidden Buymenu Opens End How would I be able to do this?
PlayerSay
Wow man! Thanks! [editline]9th September 2011[/editline] Could I Ask One More Thing. How Would I Make Colored Chat Appear In The Chatbox? Could You Show Me An Example Script?
If the messages are predefined you could do something like.. [lua] if SERVER then hook.Add("PlayerSay","removeCmd",function(ply,text) if(string.sub(text,1,1)=="/")then umsg.Start(ply,"sendCM"); umsg.Float(2); umsg.End(); return ""; end end) else local CMs = { {Color(220,50,50), "we are red, ", Color(50,50,220), "now we are blue"}, {Color(220,50,50), "we are blue, ", Color(50,225,50), "now we are green"} }; function printChat(um) chat.AddText(unpack(CMs[um:ReadFloat()])); end usermessage.Hook("sendCM",printChat); end [/lua] Else you would have to umsg the stuff to print.
Sorry, you need to Log In to post a reply to this thread.