Ulysses
General => Developers Corner => Topic started by: eriikok on October 22, 2015, 04:01:08 AM
-
Hello.
So I have this problem, there seems to be a problem with the hooks on the current Github version of ULib. I have these spawn hooks to prevent players from spawning stuff, it gets called and I return false, but the entity still spawns.
This is a normal PlayerSpawnSENT:
hook.Add( "PlayerSpawnSENT", "asdasdawefdasdgrgdsfsretASGRS", function(ply,sent)
ply:ChatPrint("MEEP MEEP")
return false
end, -2 )
Obviously, the player should not be able to spawn a Bouncy ball. But:
(http://i.imgur.com/np7acWT.png)
*Notice bottom left corner.
Has anyone else experienced this? Is it a known problem. Is it something I somehow missed? (Been looking at this for days man)
-
hook.Add() (http://wiki.garrysmod.com/page/hook/Add) only takes 3 arguments. You gave 4.
-
hook.Add() (http://wiki.garrysmod.com/page/hook/Add) only takes 3 arguments. You gave 4.
ULib adds a 4th argument. https://github.com/Nayruden/Ulysses/blob/master/ulib/lua/ulib/shared/hook.lua
-
Oh, I see. Sorry about that. I didn't know ULib added hook priorities.
This behaviour is caused by the following if-statement: https://github.com/Nayruden/Ulysses/blob/master/ulib/lua/ulib/shared/hook.lua#L111-L113
Hook priorities:
HOOK_MONITOR_HIGH = -2
HOOK_HIGH = -1
HOOK_NORMAL = 0
HOOK_LOW = 1
HOOK_MONITOR_LOW = 2
The 4th argument, the priority, can't be a monitor priority if you want to return something. It has to be either -1, 0 or 1 — or the return value won't be registered.
Edit: Fix grammar
-
Aw man, that was the issue. Thank you so much man, been scratching my head with this on several occasions, often several hours. :p