• Print

Author Topic: command help  (Read 5020 times)

0 Members and 1 Guest are viewing this topic.

Offline howzy

  • Newbie
  • *
  • Posts: 6
  • Karma: -1
command help
« on: January 20, 2016, 07:34:38 pm »
So I have seen a lot of servers with !forum command, I dont know what the proper code is, ive tried many. Also there is a !autoslay command, I was wondering if I could get that for my deathrun server? Anyone know a code or addon? Also I need a !gagtimer command thingy, it is where you can gag someone for a certain amount of time then after the time is done, it auto ungags them.

Offline nobbyblue

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: command help
« Reply #1 on: January 21, 2016, 02:35:10 am »
I believe something like this would do what you're asking:

Code: Lua
  1. hook.Add( "PlayerSay", "forumfunc", function( ply, text, public )
  2.         text = string.lower( text ) -- Make the chat message entirely lowercase
  3.         if ( text == "!forum" ) then
  4.                 gui.OpenURL( "http://yourforumurl" )
  5.                 return ""
  6.         end
  7. end )

I just grabbed this from the GMOD wiki though so not a clue if this is correct, worth a try though.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: command help
« Reply #2 on: January 21, 2016, 08:21:22 am »
I believe something like this would do what you're asking:

Code: Lua
  1. hook.Add( "PlayerSay", "forumfunc", function( ply, text, public )
  2.         text = string.lower( text ) -- Make the chat message entirely lowercase
  3.         if ( text == "!forum" ) then
  4.                 gui.OpenURL( "http://yourforumurl" )
  5.                 return ""
  6.         end
  7. end )

I just grabbed this from the GMOD wiki though so not a clue if this is correct, worth a try though.

gui.OpenURL is a clientside function. It won't work and might throw an error if it's run serverside.

Code: Lua
  1. local CATEGORY_NAME = "URLs"
  2.  
  3. ------------------------------ Forums ------------------------------
  4. function ulx.forums( calling_ply )
  5.   calling_ply:SendLua([[gui.OpenURL("http://forums.website")]])
  6. end
  7. local forums = ulx.command( CATEGORY_NAME, "ulx forums", ulx.forums, "!forums" )
  8. forums:defaultAccess( ULib.ACCESS_ALL )
  9. forums:help( "Opens the forums." )

Pretty self explanatory. Like nobbyblue pointed out, gui.OpenURL opens the specified URL in the Steam Overlay. SendLua just runs it on calling_ply's client. The double braces are another way to specify strings in Lua, and it allows you to have double quotes in the function.
« Last Edit: January 21, 2016, 08:25:01 am by roastchicken »
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline Im Howzy

  • Newbie
  • *
  • Posts: 3
  • Karma: 1
Re: command help
« Reply #3 on: January 21, 2016, 07:57:55 pm »
I got the !forums command working, but still don't know how to do gag duration and slay amount thingy to auto slay for a certain amount of round? Help?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: command help
« Reply #4 on: January 21, 2016, 08:30:39 pm »
Howzy, as many of the community members here know about me, I really dislike when people don't use "Search" functions that forums, or even google, provide.
Using our search is page context sensitive. If you go into a section, the search will only search that section.
I searched from our front page for "gag time", but likely could have started in Releases.
Guess what, the 3rd or 4th post after searching for "gag time", in our RELEASES section no less, has someone who made a time based Gag.
/index.php/topic,8604.0.html

As for !forum, though someone posted for you, someone too made a release that you could have easily edited to fit your needs.
/index.php/topic,8469.0.html
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print