Okay
Well to create a ULX command you need to create a function and then some other stuff below it that actually adds it to ULX (I don't know what to call it so lets call it some other stuff haha)
Here's how you would do that (This does not open the URL)
function ulx.NameOfFunctionHere( calling_ply, target_ply )
WhatTheFunctionDoes
end
local WhatYouCalledYourFunction = ulx.command ( "NameOfCategoryHere", "ulx WhatYouWantTheConsoleCommandToBe", ulx.WhatYouCalledYourFunction, "!WhatYouWantYourChatCommandToBe", true )
WhatYouCalledYourFunction:defaultAccess( ULib.ACCESS_ALL )
WhatYouCalledYourFunction:help( "This describes your ULX command" )
Now to explain that:
Line 1: function ulx.NameOfFunctionHere( calling_ply, target_ply )
function tells the server to create a new function
ulx.NameOfFunctionHere is the exact of the name of the function, you'll need to use this name later
( calling_ply, target_ply ) is what the function "returns". This basically means that the function can use these two players in its code. "calling_ply" is the player that ran the command, and "target_ply" is the player that the command is being run on
Line 2: WhatTheFunctionDoes
This is all of the code that is inside of the function. It's the code that's ran when the function is called. I'll get into this later when I'm talking about the URL thing
Line 3: end
This ends the function
Line 4: local WhatYouCalledYourFunction = ulx.command ( "NameOfCategoryHere", "ulx WhatYouWantTheConsoleCommandToBe", ulx.WhatYouCalledYourFunction, "!WhatYouWantYourChatCommandToBe", true )
"local WhatYouCalledYourFunction" means put here what you put on line 1 after ulx. -- For example, if your line 1 read "function ulx.NameOfFunctionHere( calling_ply, target_ply )", then the beginning of line 4 would read "local NameOfFunctionHere"
" = ulx.command" means that you're telling the server that WhatYouCalledYourFunction is a ulx command
"( "NameOfCategoryHere"," means whatever you put inside of those quotes is the name of the category that this command will appear in when you open the xgui. If the category does not already exist, it'll create one for you.
""ulx WhatYouWantTheConsoleCommandToBe", " means that everything inside of those quotes will run this ULX command when typed into console
"ulx.WhatYouCalledYourFunction" means put here whatever you called your function. If your line 1 reads "function ulx.NameOfFunctionHere( calling_ply, target_ply )" then make this string say "ulx.NameOfFunctionHere" --DO NOT INCLUDE THE () OR ANYTHING INSIDE OF THEM
"!WhatYouWantYourChatCOmmandToBe" means that whatever is inside of these quotes will run the command when typed in player chat. For example, you could do "!ourwebsite"
"true" means that when a player types the command in chat, the message will not be shown in chat. In other words, you won't see anyone saying "!ourwebsite" (using the example from above). You could also set this to false if you're fine w/ seeing the command when you or other players type it
Line 5: WhatYouCalledYourFunction:defaultAccess( ULib.ACCESS_ALL )
"WhatYouCalledYourFunction" is exactly what you named your function on line 1 but minus the "ulx.", the (), and everything inside of the ()
":defaultAccess( ULib.ACCESS_ALL ) " means that by default, all players will have access to this command. You can remove the permission for this command for certain ranks or players ingame
Line 6: WhatYouCalledYourFunction:help( "This describes your ULX command" )
"WhatYouCalledYourFunction" is exactly what you named your function on line 1 but minus the "ulx.", the (), and everything inside of the ()
":help( "This describes your ULX command" )" means that when you type "ulx help" into the console and all of the commands are shown along with what they do, what it said inside of these quotes will be the description that is shown in console for this command
Forgot to mention this earlier: in this case, you wouldn't really need the target_ply in the function. I'm making it so when you type "!mywebsite" it has you open the link, so you don't have to do "!mywebsite MyNameHere"Now onto making the function do things:First, go ahead and remove "WhatTheFunctionDoes" if you copy and pasted the code into the file
Once you've done that, put your cursor at the end of the text at line 1 and hit enter so that your line two moves to line three and you're now in line 2
calling_ply is going to be what you use in place of ply
As I said before, calling_ply is the player that ran the command
so you'd start like this:
calling_ply:
Next we add a function to the end of that so the server knows what to do to the payer
Now edit your line two so after calling_ply: it will say SendLua("gui.OpenURL('
http://MyWebsiteHere.com')")
After giving the function a proper name and removing target_ply, your first three lines should read something like this
function ulx.ourwebsite( calling_ply )
calling_ply:SendLua("gui.OpenURL('[url]http://MyWebsiteHere.com[/url]')")
end
After doing that and filling in your last three lines, your final code should read something like this
function ulx.ourwebsite( calling_ply )
calling_ply:SendLua("gui.OpenURL('[url]http://MyWebsiteHere.com[/url]')")
end
local ourwebsite = ulx.command( "Links", "ulx ourwebsite", ulx.ourwebsite, "!ourwebsite" )
ourwebsite:defaultAccess( ULib.ACCESS_ALL )
ourwebsite:help( "Opens our website" )
That's untested code, by the way
Unless I put a typo somewhere and didn't notice, it should work, besides the fact that MyWebsiteHere.com probably isn't a real website
