Ulysses

Ulysses Stuff => General Chat & Help and Support => Topic started by: TomatoSoup on January 01, 2016, 01:35:29 PM

Title: Problem with Pointshop hooks while using ULib, Part 2
Post by: TomatoSoup 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?
Title: Re: Problem with Pointshop hooks while using ULib, Part 2
Post by: Megiddo on January 01, 2016, 01:51:29 PM
Is the code throwing an error, or is the pointshop hook also named "AG_AddMember"?
Title: Re: Problem with Pointshop hooks while using ULib, Part 2
Post by: TomatoSoup 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!
Title: Re: Problem with Pointshop hooks while using ULib, Part 2
Post by: Megiddo 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.
Title: Re: Problem with Pointshop hooks while using ULib, Part 2
Post by: TomatoSoup 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.
Title: Re: Problem with Pointshop hooks while using ULib, Part 2
Post by: Megiddo on January 01, 2016, 03:19:10 PM
There's nothing magical in his implementation. It will fail the same way.
Title: Re: Problem with Pointshop hooks while using ULib, Part 2
Post by: TomatoSoup on January 01, 2016, 05:22:06 PM
I apologize for doubting you. I tested it myself and it is as you say.
Title: Re: Problem with Pointshop hooks while using ULib, Part 2
Post by: JamminR 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)