Author Topic: Problem with Pointshop hooks while using ULib, Part 2  (Read 1783 times)

0 Members and 1 Guest are viewing this topic.

Offline TomatoSoup

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
Problem with Pointshop hooks while using ULib, Part 2
« on: January 01, 2016, 01:35:29 PM »
About 7 months ago I had a problem with ULib's hook-priority system causing Pointshop to fail to call it's PlayerInitialSpawn hook. Some other piece of code was returning a value from PlayerInitialSpawn and ULib caused it to run in an unexpected order, stopping Pointshop's from running.

I'm having the problem again and I'm entirely stumped. Here is the offending code.

Code: [Select]
local function checkMember(ply)
    if members[ply:SteamID64()] then
        setRank(ply,"member")
    else
        if not ply:CheckGroup("vip") then
            ULib.ucl.removeUser( ply:SteamID() )
        end
    end
end
hook.Add("PlayerInitialSpawn", "AG_AddMember", checkMember)

With this code, Pointshop's PlayerInitialSpawn is never called. Comment out that last line, it starts getting called again.

What am I doing wrong now?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Problem with Pointshop hooks while using ULib, Part 2
« Reply #1 on: January 01, 2016, 01:51:29 PM »
Is the code throwing an error, or is the pointshop hook also named "AG_AddMember"?
Experiencing God's grace one day at a time.

Offline TomatoSoup

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
Re: Problem with Pointshop hooks while using ULib, Part 2
« Reply #2 on: January 01, 2016, 02:02:42 PM »
...Yes. With hindsight I should confirm that my code is not throwing an error before I post. Which then propagates through ULib's Lua-based hook handler and brutally murders it. In my defense, it was printing an error every think, so it was easy to miss. Could you do me a favor and get something with pcall or xpcall put in there so that I can stop jumping the gun on making threads?

See you guys again in seven months!
« Last Edit: January 01, 2016, 02:05:24 PM by TomatoSoup »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Problem with Pointshop hooks while using ULib, Part 2
« Reply #3 on: January 01, 2016, 02:37:56 PM »
The hook library follows the same functionality as Garry's default hook implementation. Garry no longer uses pcall so we don't either.
Experiencing God's grace one day at a time.

Offline TomatoSoup

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
Re: Problem with Pointshop hooks while using ULib, Part 2
« Reply #4 on: January 01, 2016, 02:42:26 PM »
I disagree with you there. While Garry does not use pcall, an error on one hook does not stop all the hooks that follow it, which is the current behavior of ULib's implementation. I agree it's not how Garry does it, but it would achieve the same results.

Or am I terribly mistaken? I'm not certain of this, but I feel that I would have noticed it if I were wrong, with how often my hooks break.
« Last Edit: January 01, 2016, 02:44:01 PM by TomatoSoup »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Problem with Pointshop hooks while using ULib, Part 2
« Reply #5 on: January 01, 2016, 03:19:10 PM »
There's nothing magical in his implementation. It will fail the same way.
Experiencing God's grace one day at a time.

Offline TomatoSoup

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
Re: Problem with Pointshop hooks while using ULib, Part 2
« Reply #6 on: January 01, 2016, 05:22:06 PM »
I apologize for doubting you. I tested it myself and it is as you say.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Problem with Pointshop hooks while using ULib, Part 2
« Reply #7 on: January 01, 2016, 09:41:23 PM »
See you on the 4th of July! :P

(But, really, feel free to stop by and say hi sooner than that)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming