Author Topic: Custom Ulx Command  (Read 10355 times)

0 Members and 1 Guest are viewing this topic.

Offline rocky123xo

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
Custom Ulx Command
« on: January 22, 2013, 06:53:06 PM »
I am running a DarkRP server with the lastest version of ULX and Ulib, and I would like to add a command.
I want the command to be !donate, as typed in game chat, and I want it to open a webpage when people type it in. Problem is, I have no clue how to do that.
If someone could help me out, that would be awesome.
Thanks again.

Offline krooks

  • Sr. Member
  • ****
  • Posts: 382
  • Karma: 32
  • I don't like video games.
    • Diamond Krooks
Re: Custom Ulx Command
« Reply #1 on: January 22, 2013, 07:11:02 PM »
My TTT server. Join the fun!

Offline Q4-Bi.

  • Newbie
  • *
  • Posts: 3
  • Karma: 2
Re: Custom Ulx Command
« Reply #2 on: February 06, 2013, 11:32:08 AM »
The link posted in the previous one shows how to do it with the command only. If you wish to also show it in the !menu of ULX you could also use this.

Code: [Select]
CATEGORY_NAME = "Community Links"
// Donate
function ulx.donate(ply)
ply:SendLua([[gui.OpenURL("http://ban-hammer.net/forum/index.php?/donate/")]])
end
local donate = ulx.command( CATEGORY_NAME, "ulx donate", ulx.donate, "!donate" )
donate:defaultAccess( ULib.ACCESS_ALL )
donate:help( "Donate $10 or more to become a lifetime donator status on TTT." )

Make a new lua file called "links.lua"
Place the file in "ULX/lua/ulx/modules/sh/"

If you wish to use other links you can just remember to change the information around a little :)

Heres what my file looks like

Code: [Select]
CATEGORY_NAME = "Community Links"

// Bans List
function ulx.banslist(ply)
ply:SendLua([[gui.OpenURL("http://ban-hammer.net/ban/")]])
end
local banslist = ulx.command( CATEGORY_NAME, "ulx banslist", ulx.banslist, "!banslist" )
banslist:defaultAccess( ULib.ACCESS_ALL )
banslist:help( "Displays the current ULX Global Bans page." )

// Forums
function ulx.website(ply)
ply:SendLua([[gui.OpenURL("http://ban-hammer.net/forum/")]])
end
local website = ulx.command( CATEGORY_NAME, "ulx website", ulx.website, "!website" )
website:defaultAccess( ULib.ACCESS_ALL )
website:help( "Displays our wonderful forums." )

// Community Page
function ulx.join(ply)
ply:SendLua([[gui.OpenURL("http://steamcommunity.com/groups/Ban-Hammers/")]])
end
local join = ulx.command( CATEGORY_NAME, "ulx join", ulx.join, "!join" )
join:defaultAccess( ULib.ACCESS_ALL )
join:help( "Displays out Steam Community page." )

// Facebook
function ulx.facebook(ply)
ply:SendLua([[gui.OpenURL("http://facebook.com/banhammers/")]])
end
local facebook = ulx.command( CATEGORY_NAME, "ulx facebook", ulx.facebook, "!facebook" )
facebook:defaultAccess( ULib.ACCESS_ALL )
facebook:help( "Like us on Facebook." )

// Twitter
function ulx.twitter(ply)
ply:SendLua([[gui.OpenURL("http://twitter.com/BanHammerCom/")]])
end
local twitter = ulx.command( CATEGORY_NAME, "ulx twitter", ulx.twitter, "!twitter" )
twitter:defaultAccess( ULib.ACCESS_ALL )
twitter:help( "Follow us on Twitter." )

// Donate
function ulx.donate(ply)
ply:SendLua([[gui.OpenURL("http://ban-hammer.net/forum/index.php?/donate/")]])
end
local donate = ulx.command( CATEGORY_NAME, "ulx donate", ulx.donate, "!donate" )
donate:defaultAccess( ULib.ACCESS_ALL )
donate:help( "Donate $10 or more to become a lifetime donator status on TTT." )