Some hooks suddenly not working

So I’ve got a rather weird issue. Some hooks are not being called at all when they should be. Some of them worked previously, and others are in the same lua file as ones that work fine. They mostly seem to be TTT hooks, but that might only be because I don’t use other ones nearly as often. Here’s an example:

function itemcheck( )
if SERVER then
	for _, v in pairs( player.GetAll() ) do
           --Simple code here that I know works. Can't show it because that would be leaking another author's code however.

hook.Add("TTTBeginRound", "checkHook", itemcheck)

This code was working fine at first. I tried to add another hook that called the same function on a TTTPrepareRound hook, and that’s when I noticed it was no longer working, but it may have stopped before that. I removed the additional hook and it still doesn’t work. This code is in its own lua file in lua/autorun.

Hooks that return a value will prevent other hooks of the same type from running. Check you have no conflicts.

Return a value? I didn’t know hooks could do that. How would that work?

Common example:

return true

I’m looking through all of the files I’ve edited lately and can’t find anything like that. I’m assuming that the return would come from within the function called by the hook correct?

It may not even be something you have edited yourself, most addons will make use of hooks, and some crappy ones will break them for other scripts. Check your TTT related addons.

I think it may be my achievement system. I just added a test achievement using the playerdeath hook which immediately broke everything. No one who died was moved to the “dead” team and could still talk in live chat. Upon deleting the test achievement it was immediately fixed.

The weird thing is though that there are already several other achievements that use the playerdeath hook in that same system and don’t cause me any problems that I’ve noticed. So to be sure it’s not something I screwed up, here’s the code. (I don’t think there’s anything in here that would be considered a leak of the script.)

local ACHIEVEMENT = {}

ACHIEVEMENT.Amount = 999
ACHIEVEMENT.Picture = "achievement_icons/k.png"
ACHIEVEMENT.Description = "This is a test. It will be removed soon."
ACHIEVEMENT.Reward = "Depends on how awesome you are."

ACHIEVEMENT.Function = function()
	if SERVER then
		function ACHIEVEMENT.Hook( victim, inf, attacker )
			attacker:PrintChat("You've killed someone!")
			attacker:ACHProgress( ACHIEVEMENT, 1 )
		hook.Add( "PlayerDeath", "ACH_TESTHook", ACHIEVEMENT.Hook )
		function ACHIEVEMENT.RewardFunction( ply )

RegisterAchievement( ACHIEVEMENT )

1: this is a completely different hook
2: I don’t see any returns anyway

I guess my thought was that some other part of the achievement script I’m using called returned a value through this hook since I used it here, since the hook seemed to break in other places (The part of the code that moves players to other teams) when I added this.

It isn’t relevant to this issue unless it uses the TTTBeginRound hook and it returns a value

There are other hooks that aren’t working properly as well, the TTTBeginRound one is just an example. But any rate I see your point. I’ll have to spend some time looking through my addons then. In the meantime, thanks for the help. :smile: