Ulysses
General => Developers Corner => Topic started by: CrazyCallum113 on September 30, 2013, 04:17:59 PM
-
Hey I'm just here to ask about create your own command for ULX. I want to know how to create a chat command to point to a workshop page. For example this would be like typing "!content" and it'd take you to a workshop page to download content - or any desired webpage for that matter. Thanks in advance :)
-
Best place to start looking/review how would be to look at the code for ULX's motd.
The code is shared between client and server, since server has to send a html text, or a url to have displayed by the client.
-
I've tried looking into this and haven't found much luck.
I stumbled across a custom !stopsound command for the chat and I've had a look at the code. I can't figure how to alter it or create a new one that would point to the workshop or a webpage
function ulx.stopsounds( calling_ply )
for _, pl in ipairs( player.GetAll() ) do pl:ConCommand("stopsound") end
end
local stopsound = ulx.command( CATEGORY_NAME, "ulx stopsound", ulx.stopsounds, "!stopsound", true )
stopsound:defaultAccess( ULib.ACCESS_ADMIN )
stopsound:help( "Stops all sounds." )
-
Look within ULX files themselves.
The client side MOTD section you'd need to study/review from is addons/ulx/lua/ulx/modules/cl/motdmenu.lua (https://github.com/Nayruden/Ulysses/blob/master/ulx/lua/ulx/modules/cl/motdmenu.lua)
It uses a custom usermessage to receive info from the server to display, either a URL or html text file sent from the server at connect.
The server(shared actually) side code to send the html or url to the client is addons/ulx/lua/ulx/modules/sh/menus.lua (https://github.com/Nayruden/Ulysses/blob/master/ulx/lua/ulx/modules/sh/menus.lua)
It will all seem a bit complex at first, but it can be pruned down considerably for just a URL and your own command.