ULX

Author Topic: ULX Hook for adduser?  (Read 3369 times)

0 Members and 1 Guest are viewing this topic.

Offline lynx

  • Jr. Member
  • **
  • Posts: 59
  • Karma: 15
ULX Hook for adduser?
« on: January 10, 2014, 07:48:09 PM »
I'm trying to integrate two systems that use ULX as a base. One sets a players forum rank based on their usergroup ingame on join, and the other updates their ingame rank on join. I want to change the first one (setting forum rank) to only run when the users group is changed (as we have a donation system that does it) so that if their forum rank gets changed their ingame rank will change on join instead of the other way around.

I'm a decent coder (in my opinion) but I've not coded for ULX before. Is there any hook I could use so that when a users group is changed it will call a hook that could be used with hook.Add? Or will I have to integrate a hook.Call with ULX so that it can call the external plugin when it happens?

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: ULX Hook for adduser?
« Reply #1 on: January 10, 2014, 08:12:51 PM »
A hook you can use is UCLChanged. It doesn't pass any args but you can use it to check usergroups and such.
I made this script for PUDS, you can modify it for your project: http://puu.sh/6dixt.lua
« Last Edit: January 11, 2014, 02:38:45 PM by Cobalt77 »

Offline lynx

  • Jr. Member
  • **
  • Posts: 59
  • Karma: 15
Re: ULX Hook for adduser?
« Reply #2 on: January 10, 2014, 08:29:25 PM »
Thanks. I'll try that out in a bit. Looking through the ulib code and found the ULib.HOOK_UCLAUTH hook which passes 2 arguments (one being _ which is some data and the other being the player) so going to try that out a bit before having to loop through users every time something changes.

Edit:
It actually only parses 1 argument. The player.
« Last Edit: January 10, 2014, 08:45:33 PM by lynx »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULX Hook for adduser?
« Reply #3 on: January 11, 2014, 09:25:28 AM »
You can find the documentation for the hook here: http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#UCLAuthed
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Hook for adduser?
« Reply #4 on: January 11, 2014, 10:13:30 AM »
RE: Our ULib docs Megiddo linked -
And many other documented features of ULib. :)

Though people are welcome to build upon ULX, it wasn't originally intended to be and therefore not documented publicly. (Plenty of comments in the code itself)
ULX is built upon ULib, which has been documented extensively. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline lynx

  • Jr. Member
  • **
  • Posts: 59
  • Karma: 15
Re: ULX Hook for adduser?
« Reply #5 on: January 11, 2014, 02:00:12 PM »
Sweet, thanks guys. That's exactly what I needed. Now I just am looking into how to add users to ulx groups via lua (don't want to use the hacky RunConsoleCommand way if I can prevent it.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: ULX Hook for adduser?
« Reply #6 on: January 11, 2014, 02:13:17 PM »
Sweet, thanks guys. That's exactly what I needed. Now I just am looking into how to add users to ulx groups via lua (don't want to use the hacky RunConsoleCommand way if I can prevent it.
http://ulyssesmod.net/docs/files/lua/ulib/server/ucl-lua.html#ucl.addUser
:p
bw81@ulysses-forums ~ % whoami
Homepage