• Print

Author Topic: Ulx Custom Command for user groups  (Read 6030 times)

0 Members and 1 Guest are viewing this topic.

Offline proxzei

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Ulx Custom Command for user groups
« on: April 12, 2016, 02:32:06 pm »
Does anyone know hot to make a ulx command where by typing !vip a user would be added to that group. Just !vip though.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Ulx Custom Command for user groups
« Reply #1 on: April 12, 2016, 03:50:54 pm »
Yes.
Many here know how.
What particular challenge are you having with it?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline proxzei

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Ulx Custom Command for user groups
« Reply #2 on: April 13, 2016, 07:49:45 am »
Uh, I don't know how to do it at all and would like the code if thats possible.

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Ulx Custom Command for user groups
« Reply #3 on: April 13, 2016, 10:59:46 am »
it's basically a shortened version of ulx adduser.

so you basically want to write the command that gets called on !vip which runs the function to add the calling player to "vip".

RunConsoleCommand("ulx","adduser",calling_ply,"vip")
Once you get to know me, you'll find you'll have never met me at all.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Ulx Custom Command for user groups
« Reply #4 on: April 14, 2016, 04:30:51 am »
It doesn't seem like this person knows how to code at all, so that won't be very helpful. I'm usually against just giving people code because it's much better if you learn how to code yourself, but I'll make an exception because this is so simple.

This command is used like "!vip <player>".

Code: Lua
  1. local CATEGORY_NAME = "Utility" --the category the command will be located under in the XGUI menu (!menu)
  2.  
  3. function ulx.givevip( calling_ply, target_ply )
  4.   RunConsoleCommand( "ulx", "adduser", target_ply, "vip" ) --runs the command "ulx adduser <player> vip" in console
  5. end
  6. local givevip = ulx.command( CATEGORY_NAME, "ulx vip", ulx.givevip, "!vip" ) --tells ULX to create this command and gives it the corresponding console and chat commands, in addition to the category it should be in
  7. givevip:addParam{ type=ULib.cmds.PlayerArg } --adds a player argument to the command
  8. givevip:defaultAccess( ULib.ACCESS_SUPERADMIN ) --the default group that can access the command
  9. givevip:help( "Sets the targeted player's group to vip." )

Edit:

Whoops, forgot to tell you where to put this. I suggest you create a new addon (just a new folder in 'garrysmod/addons/') and put this file in '<addonname>/lua/ulx/modules/sh'
« Last Edit: April 14, 2016, 04:35:42 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 Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Ulx Custom Command for user groups
« Reply #5 on: April 14, 2016, 09:45:53 am »
It doesn't seem like this person knows how to code at all, so that won't be very helpful. I'm usually against just giving people code because it's much better if you learn how to code yourself, but I'll make an exception because this is so simple.

The reason it's so simple is why i didn't just dump code.
Once you get to know me, you'll find you'll have never met me at all.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Ulx Custom Command for user groups
« Reply #6 on: April 14, 2016, 05:39:57 pm »
The reason it's so simple is why i didn't just dump code.

Eh, I just did it because it didn't take me much effort. If I were 100% true to my philosophy I wouldn't give anyone code without them attempting it first, but every once in a while you have to break.

Reading my post again it seems I may have sounded a bit rude... I didn't mean to insult you for trying to help, I just wanted to point out that it likely wouldn't be very useful to someone who doesn't know how to code.
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 Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Ulx Custom Command for user groups
« Reply #7 on: April 14, 2016, 07:49:33 pm »

No insult taken, you'd have to try a lot harder ;)
Once you get to know me, you'll find you'll have never met me at all.

  • Print