Ulysses

General => Developers Corner => Topic started by: Risteh on January 03, 2014, 12:38:17 AM

Title: How do I add !apply command?
Post by: Risteh on January 03, 2014, 12:38:17 AM
I want to make a command where you can type !apply and it opens a webpage in the Steam browser. I think I've got the code but I don't know where to put it.

Code: [Select]
function ulx.apply( calling_ply )

calling_ply:SendLua([[gui.OpenURL( "]] .. GetConVarString("apply_url") .. [[" )]])

end

local apply = ulx.command( "Custom", "ulx apply", ulx.apply, "!apply" )
apply:defaultAccess( ULib.ACCESS_ALL )
apply:help( "Apply to staff team." )
Title: Re: How do I add !apply command?
Post by: Mclovin on January 03, 2014, 04:16:04 AM
addons/ulx/lua/modules/sh
Title: Re: How do I add !apply command?
Post by: JamminR on January 03, 2014, 08:00:05 AM
better yet,  make your own addon.
Create folder in addons like
/addons/MyAddons/lua/ulx/modules/sh
Make an addon.txt file (use google or get syntax from another addon)
Make your apply.lua file in /addons/MyAddons/lua/ulx/modules/sh
Title: Re: How do I add !apply command?
Post by: Risteh on January 04, 2014, 08:37:50 AM
When I put apply_url in console it says unknown command?
Title: Re: How do I add !apply command?
Post by: JamminR on January 04, 2014, 08:45:35 AM
If you're using the same code you have listed in your original post, you'd have to use "ulx apply".
I'm thinking there might be other bugs too, but, lets start one at a time.
So, you've created two files, right?
/addons/MyAddons/addon.txt
/addons/MyAddons/lua/ulx/modules/sh/my_apply.lua
and in my_apply.lua, you've pasted your code from original post?
Title: Re: How do I add !apply command?
Post by: Bytewave on January 04, 2014, 09:33:39 AM
I found one problem with his code:
He calls for the value of apply_url, but he never created the convar in the first place, nor did he set a default value.
Title: Re: How do I add !apply command?
Post by: Cobalt on January 04, 2014, 02:04:59 PM
You're using my code, and in my code i created a convar which is in a separate file. You need to remove the convar and concatenation part and just enter the url you want to use.
Title: Re: How do I add !apply command?
Post by: Neku on January 04, 2014, 03:25:13 PM
Code: [Select]
function ulx.apply( calling_ply )

calling_ply:SendLua([[gui.OpenURL( "http://www.google.com/" )]])

end

local apply = ulx.command( "Custom", "ulx apply", ulx.apply, "!apply" )
apply:defaultAccess( ULib.ACCESS_ALL )
apply:help( "Apply to staff team." )

That should work.

If not, sorry, I don't know Lua.
Title: Re: How do I add !apply command?
Post by: Risteh on January 04, 2014, 10:50:06 PM
Thanks, Ven. It works. And thank you Cobolt for the initial code!