Ulysses
General => Developers Corner => Topic started by: nicwillu on May 20, 2014, 07:55:46 AM
-
Greetings.
I have this piece of lua code working perfectly, basically it opens a recruitment window when typing !joinsgx:
function joinsgxCommand( pl, text, teamonly )
if (text == "!joinsgx") then
pl:SendLua([[gui.OpenURL("http://sg-x.info/recruitment")]]) -- Change ADDRESS to your chosen page.
end
end
hook.Add( "PlayerSay", "Chat", joinsgxCommand )
Now, I want to add another chat command for getting a list of addons the server is using when typing !addons
function getaddonsCommand( pl, text, teamonly )
if (text == "!addons") then
pl:SendLua([[gui.OpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=139301267")]]) -- Change ADDRESS to your chosen page.
end
end
hook.Add( "PlayerSay", "Chat", getaddonsCommand )
But when I type in !addons nothing happens, why? How come !joinsgx works but not !addons? I changed the function variable (or whatever it is called) so they are not the same.
Excuse my noob-skill in lua coding, I got this code from somewhere else and I edited it to fit my needs. any help appreciated!
-
This isn't a ULX command...but alright.
I don't see anything wrong, so those two are probably just conflicting.
Put both urls in one function instead of two.
-
This isn't a ULX command...but alright.
I don't see anything wrong, so those two are probably just conflicting.
Put both urls in one function instead of two.
How exactly would I do that?
EDIT: Made it work somehow :)
function donateCommand( pl, text, teamonly )
if (text == "!joinsgx") then
pl:SendLua([[gui.OpenURL("http://sg-x.info/recruitment")]]) -- Change ADDRESS to your chosen page.
end
if (text == "!addons") then
pl:SendLua([[gui.OpenURL("http://sg-x.infololol/recruitment")]])
end
end
hook.Add( "PlayerSay", "Chat", donateCommand )
Thanks for the help.
-
function GetURLCommand( pl, text, teamonly )
if text == "!addons" then
pl:SendLua([[gui.OpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=139301267")]])
elseif text == "!joinsgx" then
pl:SendLua([[gui.OpenURL("http://sg-x.info/recruitment")]])
end
end
hook.Add( "PlayerSay", "Chat", GetURLCommand )
In my honest opinion, you need to learn lua to run a server.
-
function GetURLCommand( pl, text, teamonly )
if text == "!addons" then
pl:SendLua([[gui.OpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=139301267")]])
elseif text == "!joinsgx" then
pl:SendLua([[gui.OpenURL("http://sg-x.info/recruitment")]])
end
end
hook.Add( "PlayerSay", "Chat", GetURLCommand )
In my honest opinion, you need to learn lua to run a server.
Why is that? I've hosted servers for years without having to get involved in lua that much. Sure it's good to know, but to say that you need to know lua to run a server... well in my honest opinion I disagree.
Anyway thanks :)
-
Hold on, I just helped you and gave an opinion, and you complain against me?
That's uncalled for.
-
Hold on, I just helped you and gave an opinion, and you complain against me?
That's uncalled for.
Am I not allowed to give my own opinion to what you said?
I thanked twice! :)
Now, case closed
-
Your original problem was that you were giving 2 hooks the same unique name.
hook.Add( "PlayerSay", "Unique Name", function)
If you name 2 hooks the same unique name as you did, one will override the other.
-
What MrPres says!
Additionally Neku, he IS learning lua by asking questions, and, though he did ask in a ULX specific section, simply ask he post in Developers corner next time.
I didn't even fully understand that the original topic had been moved until I saw the MOVED notice after this topic.
Oh, and nicwillu, fyi, the help and support section is intended for ULX related questions.
Feel free to ask lua/other development questions here in the Developers corner section of the forums.