• !join Command with LUA
    7 replies, posted
Hello, right now I'm trying to create a command that will open my steam group's profile for a user when they type !join in chat, this is the code I have so far: [CODE]function myCommand ( ply, text, public ) if( string.sub( text, 1, 6) == "!join" ) then gui.OpenURL("http://steamcommunity.com/groups/basedgamings") end end hook.Add( "PlayerSay" , "myCommand" , myCommand )[/CODE] It wasn't working before, there was no response to the !join command. The questions I have are, will this code work, and where does the .lua file with the code need to be? I'm running a TTT server.
I didn't know that "!join" are 6 chars :v:
[QUOTE=Wizard of Ass;39207683]I didn't know that "!join" are 6 chars :v:[/QUOTE] Oh thank you, now, where would i put this lua to have the command work?
Noticed that a second later, you are using the wrong hook too, atleast for complexity reasons it should look like this: [lua] hook.Add("OnPlayerChat", "blarg", function(ply, txt) if(ply == LocalPlayer() and txt:sub(1, 5) == "!join") then gui.OpenURL("http://steamcommunity.com/groups/basedgamings") end end) [/lua] NOTE: Admin systems like Evolve will most likely fuck this over.
[QUOTE=Wizard of Ass;39207745]Noticed that a second later, you are using the wrong hook too, atleast for complexity reasons it should look like this: [lua] hook.Add("OnPlayerChat", "blarg", function(ply, txt) if(ply == LocalPlayer() and txt:sub(1, 5) == "!join") then gui.OpenURL("http://steamcommunity.com/groups/basedgamings") end end) [/lua] NOTE: Admin systems like Evolve will most likely fuck this over.[/QUOTE] Oh, I have ULX currently, do I just need to give people permission and stuff? And where should I put this LUA code?
-snip
Afaik this will not really conflict with ULX, but I am not sure. File file would need to be placed in /autorun/ Also correction: [lua] AddCSLuaFile() if(CLIENT) then hook.Add("OnPlayerChat", "blarg", function(ply, txt) if(ply == LocalPlayer() and txt:sub(1, 5) == "!join") then gui.OpenURL("http://steamcommunity.com/groups/basedgamings") end end) end [/lua]
[QUOTE=Wizard of Ass;39207835]Afaik this will not really conflict with ULX, but I am not sure. File file would need to be placed in /autorun/ Also correction: [lua] AddCSLuaFile() if(CLIENT) then hook.Add("OnPlayerChat", "blarg", function(ply, txt) if(ply == LocalPlayer() and txt:sub(1, 5) == "!join") then gui.OpenURL("http://steamcommunity.com/groups/basedgamings") end end) end [/lua][/QUOTE] Thanks a ton man!
Sorry, you need to Log In to post a reply to this thread.