Ulysses
Ulysses Stuff => General Chat & Help and Support => Topic started 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.
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?
-
Is the code throwing an error, or is the pointshop hook also named "AG_AddMember"?
-
...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!
-
The hook library follows the same functionality as Garry's default hook implementation. Garry no longer uses pcall so we don't either.
-
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.
-
There's nothing magical in his implementation. It will fail the same way.
-
I apologize for doubting you. I tested it myself and it is as you say.
-
See you on the 4th of July! :P
(But, really, feel free to stop by and say hi sooner than that)