Author Topic: How do I add !apply command?  (Read 3018 times)

0 Members and 1 Guest are viewing this topic.

Offline Risteh

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
How do I add !apply command?
« 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." )

Offline Mclovin

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
  • Hi there.
Re: How do I add !apply command?
« Reply #1 on: January 03, 2014, 04:16:04 AM »
addons/ulx/lua/modules/sh
Call me Fogell. :D

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How do I add !apply command?
« Reply #2 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
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Risteh

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: How do I add !apply command?
« Reply #3 on: January 04, 2014, 08:37:50 AM »
When I put apply_url in console it says unknown command?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: How do I add !apply command?
« Reply #4 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?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: How do I add !apply command?
« Reply #5 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.
bw81@ulysses-forums ~ % whoami
Homepage

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: How do I add !apply command?
« Reply #6 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.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: How do I add !apply command?
« Reply #7 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.
Out of the Garry's Mod business.

Offline Risteh

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
Re: How do I add !apply command?
« Reply #8 on: January 04, 2014, 10:50:06 PM »
Thanks, Ven. It works. And thank you Cobolt for the initial code!