Limits to Hooks

I know on the Wiki it says you can have unlimited hooks on something but clearly I can’t. Any Ideas? I’m completely stumped.

This works.

local function xpFirstSpawn( ply )
    print("firing xpspawn")
hook.Add( "PlayerInitialSpawn", "xpInitialSpawn", xpFirstSpawn )

This does not.

local function karmaFirstSpawn( ply )
	print("firing karmaSpawn")
hook.Add( "PlayerInitialSpawn", "karmaInitialSpawn", karmaFirstSpawn )

I’m 100% positive it’s being loaded by the server. It just refuses to run.

-snip- dead babies.

That’s just to print to the console serverside.
Like I said, the first one works, the second does not. I can tell no difference between the first and last.

It already occured to me once, although I don’t know exactly why. Try using an extremely short name, and see if it works. For some reason, hooks would screw up when I use really long names. Although “karmaInitialSpawn” isn’t long at all, so that’s weird.

I guess those two pieces of code are in the same file, right?

different files and they are both local functions. I’ll give that a whirl.


Yes, that was the problem! Thank you so much!

Wow, that’s extremely weird. As I said, “karmaInitialSpawn” is an average length string, nothing too long. I remember using much longer unique hook names.

Maybe you have an addon which has a hook called “karmaInitialSpawn” which ended up overriding yours? You can always check that, since you changed the name of your own hook, try running this in the console:

lua_run print(hook.GetTable().PlayerInitialSpawn.karmaInitialSpawn)

If it prints something else than nil, there goes your problem.

I think 16 characters is the upper limit.

] lua_run hook.Add("PlayerSay","AnExtreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeemelylongname", function(p)p:Kill()end)
> hook.Add("PlayerSay","AnExtreeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeemelylongname", function(p)p:Kill()end)...
STNO | Crazy Quebecer suicided!
*DEAD* STNO | Crazy Quebecer: b

I’m stumped then, the ONLY thing I changed was the length and it worked fine.

Do it. I’m pretty much sure that’s because you already have an addon which uses a hook called “karmaInitialSpawn”. Otherwise, I really don’t see why your hook wouldn’t register.