• chat command help
    5 replies, posted
Ok, I feel a bit stupid but I've been away from lua for a bit. Basically, I want to make it so if a player says stopmusic in the chatbox it stops playing music. Basically all I need help with is how to detect the word in chat and which player did it. So.. [lua] if player.defaultmusic = 1 then local music = 1 else if player.defaultmusic = 2 then local music = 0[/lua] Just showing how I'm going to be doing this, so if the player types stopmusic in the chatbox player.defaultmusic gets set to 2. Any idea?. I put this in the newbie area because I feel like a noob right now :P.
[url]http://wiki.garrysmod.com/?title=Gamemode.PlayerSay[/url]
[LUA] function MyFuncName( pl, cmd, args ) //you code goes here // // pl is the person who said the naughty word! // cmd is the naughty word in question! // args is the insults that follow ( in a table cause there are so many! ) // // And the 3 piggys lived happy ever after, The ... end // :3 hook.Add("PlayerSay", "Meisno's Fantastic Solution!", function( ply, text) if ply:IsValid() then // you don't want people aboosing rcon :P local sep = string.Explode( text, " ") if sep[1] == "!StopMusic" then local pl = ply local cmd = sep[1] table.remove( sep, 1) local args = sep MyFuncName( pl, cmd, args) end end end) [/LUA] [editline]01:40PM[/editline] :O ninja'd 6 hours ago?!?!?! i took that long to answer ?!?!
PlayerSay doesn't recognize Console, does it?
[QUOTE=samwilki;22255949]PlayerSay doesn't recognize Console, does it?[/QUOTE] ..No?.
Just to pitch a question here, is there a hook that returns everything that happens in chat or does PlayerSay do that? What I mean is like when using chat.AddText, players join/leave, messages from admin mods when slaying or kicking, etc. EDIT: [url]http://wiki.garrysmod.com/?title=Gamemode.ChatText[/url] Could that be everything BUT player messages in chat?
Sorry, you need to Log In to post a reply to this thread.