ULX

Author Topic: Add user to group via lua  (Read 7118 times)

0 Members and 1 Guest are viewing this topic.

Offline BigBrainAFK

  • Newbie
  • *
  • Posts: 15
  • Karma: 0
Add user to group via lua
« on: April 09, 2015, 01:23:44 PM »
Hello,

I'm working on a TTT server and I have the problem that i don't know how to add a user in ulx to a usergroup via lua script say for example like in an achievement system or something like that.

As far as I know it doesn't work via ply:SetUserGroup so how should i do it then?


P.S.: It would be cool if it says "(Someone) added *INSERT NAME HERE* to *INSERT GROUP HERE*" like if a real admin adds the player

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Add user to group via lua
« Reply #1 on: April 09, 2015, 01:33:42 PM »
Why don't you just run the already existing command (ulx adduser) using RunConsoleCommand()?

Offline BigBrainAFK

  • Newbie
  • *
  • Posts: 15
  • Karma: 0
Re: Add user to group via lua
« Reply #2 on: April 09, 2015, 01:45:26 PM »
I kind of remember that I saw a thread already talking about RunConsoleCommand and how it don't work with ULX but i think i give it a try.

Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Add user to group via lua
« Reply #3 on: April 09, 2015, 02:29:41 PM »
RunConsoleCommand("ulx", "adduser", target_ply, group)
Once you get to know me, you'll find you'll have never met me at all.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Add user to group via lua
« Reply #4 on: April 09, 2015, 03:21:07 PM »
RunConsoleCommand("ulx", "adduser", target_ply, group)
target_ply:Nick() *
bw81@ulysses-forums ~ % whoami
Homepage

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Add user to group via lua
« Reply #5 on: April 09, 2015, 05:52:07 PM »
of, if you want to just bypass that entirely, you can go straight to UCL.

ULib.ucl.addUser( target_ply:SteamID(), nil, nil, group )

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Add user to group via lua
« Reply #6 on: April 09, 2015, 08:09:25 PM »
Yes indeed.
In theory, you wouldn't even need ULX installed. Only ULib.
See our ULib docs page, linked from the sticky post(s) at front of the Dev corner forum area.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline BigBrainAFK

  • Newbie
  • *
  • Posts: 15
  • Karma: 0
Re: Add user to group via lua
« Reply #7 on: April 10, 2015, 11:40:23 AM »
Got it working now and i wanted to thank you guys for the quick help :D

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Add user to group via lua
« Reply #8 on: April 11, 2015, 09:02:35 AM »
In theory, you wouldn't even need ULX installed. Only ULib.

How is this??? If ULX is not installed how would the person be in a group???

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Add user to group via lua
« Reply #9 on: April 11, 2015, 09:43:01 AM »
How is this??? If ULX is not installed how would the person be in a group???
Because ULX uses ULib's group system, and you can add users to ULib using Lua and not just ULX.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.