Ulysses
General => Developers Corner => Topic started by: Jaden Zepeda on December 20, 2014, 02:55:48 PM
-
I have 2 lua files, group.lua and donate.lua, both in my autorun server. Lets say I lua_openscript group.lua and lua_openscript donate.lua right after, only !donate works because it was the last one I ran, is there a way to make it so both of them work at the same time?
Donate.lua
function donateCommand( pl, text, teamonly )
if (text == "!donate") then
pl:SendLua([[gui.OpenURL("http://sites.google.com/site/bigmacssw/donate")]]) -- Change ADDRESS to your chosen page.
end
end
hook.Add( "PlayerSay", "Chat", donateCommand )
Group.lua
function groupCommand( pl, text, teamonly )
if (text == "!group") then
pl:SendLua([[gui.OpenURL("http://steamcommunity.com/groups/sandboxwars")]]) -- Change ADDRESS to your chosen page.
end
end
hook.Add( "PlayerSay", "Chat", groupCommand )
-
Your hook add command uses the same "identifier" for both commands. "Chat"
That middle term has to be unique, or it overwrites previous.
From hook.Add (http://wiki.garrysmod.com/page/hook/Add)
hook.Add( string eventName, any identifier, function func )
any identifier
The unique identifier, usually a string. This can be used to replace or remove existing hooks. If the identifier is not a string and IsValid(identifier) returns false on the hook's call, the hook will be removed.
-
Your hook add command uses the same "identifier" for both commands. "Chat"
That middle term has to be unique, or it overwrites previous.
From hook.Add (http://wiki.garrysmod.com/page/hook/Add)
hook.Add( string eventName, any identifier, function func )
Wow, Im so stupid I can't believe I missed that! Thanks alot!
-
It's the small details that will get you everytime.
You're welcome.