General > Developers Corner
Chat command -> Open website not working correctly
nicwillu:
Greetings.
I have this piece of lua code working perfectly, basically it opens a recruitment window when typing !joinsgx:
--- Code: ---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 )
--- End code ---
Now, I want to add another chat command for getting a list of addons the server is using when typing !addons
--- Code: ---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 )
--- End code ---
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!
Neku:
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.
nicwillu:
--- Quote from: Neku on May 20, 2014, 08:03:39 AM ---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.
--- End quote ---
How exactly would I do that?
EDIT: Made it work somehow :)
--- Code: ---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 )
--- End code ---
Thanks for the help.
Neku:
--- Code: ---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 )
--- End code ---
In my honest opinion, you need to learn lua to run a server.
nicwillu:
--- Quote from: Neku on May 20, 2014, 08:44:16 AM ---
--- Code: ---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 )
--- End code ---
In my honest opinion, you need to learn lua to run a server.
--- End quote ---
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 :)
Navigation
[0] Message Index
[#] Next page
Go to full version