• Print

Author Topic: Custom !donate command to open webpage  (Read 9167 times)

0 Members and 1 Guest are viewing this topic.

Offline Astro Gaming | Dylan

  • Newbie
  • *
  • Posts: 8
  • Karma: -3
Custom !donate command to open webpage
« on: December 13, 2014, 08:10:56 am »
Hello I am in need of help. I have seen other DarkRP servers who have special ULX commands such as !forum, !donate, !apply etc and I needed this for my server and I seen an old post on how to do it here but it is outdated so if anyone knows how to help me for example I want the user to type in !astroshop and it will open a steam overlay which takes the user to our website! Thankyou so much to everyone who helps me out

- Dylan :)


Offline Astro Gaming | Dylan

  • Newbie
  • *
  • Posts: 8
  • Karma: -3
Re: Custom !donate command to open webpage
« Reply #2 on: December 13, 2014, 12:43:19 pm »
That is completely different that is to do with add-ons etc can you help me please

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Custom !donate command to open webpage
« Reply #3 on: December 13, 2014, 12:50:46 pm »
That is completely different that is to do with add-ons etc can you help me please
...no, that's exactly what you're asking for.

Code: Lua
  1. function ulx.openurl( calling_ply )
  2.         calling_ply:SendLua("gui.OpenURL([[your fancy link goes here]])")
  3. end
  4. local openurl = ulx.command( "Custom", "ulx openurl", ulx.openurl, "!openurl" )
  5. openurl:defaultAccess( ULib.ACCESS_ALL )
  6. openurl:help( "Something helpful about this command goes here." )

Code is not static, it can be modified. As you can see, I've just adapted the reply from that post to fit a better need. You can change "openurl" to whatever you want, so long as you change it everywhere in that code. "your fancy link goes here" and "Something helpful about this command goes here." can also be changed.
« Last Edit: December 13, 2014, 12:54:51 pm by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline Astro Gaming | Dylan

  • Newbie
  • *
  • Posts: 8
  • Karma: -3
Re: Custom !donate command to open webpage
« Reply #4 on: December 13, 2014, 01:57:08 pm »
Where do I save this file? + local openurl = ulx.command( "Custom", "ulx openurl", ulx.openurl, "!openurl" ) what do I put in the Custom and the ulxopenurl?

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Custom !donate command to open webpage
« Reply #5 on: December 13, 2014, 02:57:51 pm »
Where do I save this file? + local openurl = ulx.command( "Custom", "ulx openurl", ulx.openurl, "!openurl" ) what do I put in the Custom and the ulxopenurl?
Custom is the name of the category in XGUI your command will appear. It can be anything.
Replace openurl anywhere in your script with something descriptive and unique. Keep in mind it must all be one word.

Example:
Code: Lua
  1. local doathing = ulx.command( "Utility", "ulx doathing", ulx.doathing, "!doathing" )

EDIT: You would also have to change this line:
Code: Lua
  1. function ulx.openurl( calling_ply )
to match your edits.

Going along with my previous example...
Code: Lua
  1. function ulx.doathing( calling_ply )

EDIT 2: Fixed code.
« Last Edit: December 13, 2014, 03:02:39 pm by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline Astro Gaming | Dylan

  • Newbie
  • *
  • Posts: 8
  • Karma: -3
Re: Custom !donate command to open webpage
« Reply #6 on: December 14, 2014, 09:27:55 am »
Where do I save it though

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Custom !donate command to open webpage
« Reply #7 on: December 14, 2014, 10:08:57 am »
Where do I save it though
/lua/ulx/modules/sh/<filename>.lua
bw81@ulysses-forums ~ % whoami
Homepage

Offline Astro Gaming | Dylan

  • Newbie
  • *
  • Posts: 8
  • Karma: -3
Re: Custom !donate command to open webpage
« Reply #8 on: December 15, 2014, 12:18:21 am »
Thank-you so much it works !

  • Print