• Hooks not working at all in PropHunt.
    8 replies, posted
I cannot for the life of me get the PlayerDeath and PlayerDisconnected events to fire. Any insight would be great. [CODE]if CLIENT then return end AddCSLuaFile() Bounty = {} Bounty.bounties = {} -- Pointshop = 1 -- Pointshop2 = 2 -- Custom = 3 Bounty.pstype = 2 local G = GAMEMODE or GM function G:PlayerDeath( victim, inflictor, attacker ) Bounty.PlayerDeath( victim, inflictor, attacker ) end function G:PlayerDisconnected( ply ) Bounty.PlayerDisconnected( ply ) end function Bounty.PlayerDeath( victim, inflictor, attacker ) print("Prop Killed") if ( victim == attacker ) then return end if ( Bounty.bounties[victim] ~= nil ) then print("Victim was not nil.") local amount = Bounty.bounties[victim]["amount"]; local poster = Bounty.bounties[victim]["poster"] if (Bounty.pstype == 1) then -- PointShop attacker:PS_GivePoints(amount) elseif (Bounty.pstype == 2) then -- PointShop2 attacker:PS2_AddStandardPoints(amount) else -- Custom Point handling. -- add custom code here. end Bounty.bounties[victim] = nil local message = "" .. attacker:Nick() .. " collect the " .. amount .. "/pts bounty on " .. victim:Nick() .. ", posted by " .. poster:Nick() .. "." PrintMessage(4, message) end end hook.Add( "PlayerDeath", "PropKilled_Bounties", Bounty.PlayerDeath ) print("hook registered! ^^^^") function Bounty.PlayerDisconnected( ply ) if ( Bounty.bounties[ply] ~= nil ) then Bounty.bounties[ply] = nil PrintMessage(4, "The bounty on " .. ply:Nick() .. " has been dropped.") end end hook.Add( "PlayerDisconnected", "BountyPlayerDisconnect", Bounty.PlayerDisconnected )[/CODE]
Any errors? Does "hook registered! ^^^^" get printed? Why do you have AddCSLuaFile if you're not using this file clientside?
Yes hook register prints. Might add client side stuff later.
Anyone have any ideas? -bump-
I might be wrong, but I'm pretty sure you should get rid of these: [code] function G:PlayerDeath( victim, inflictor, attacker ) Bounty.PlayerDeath( victim, inflictor, attacker ) end function G:PlayerDisconnected( ply ) Bounty.PlayerDisconnected( ply ) end [/code] Comment them out and see what happens for the PlayerDeath hook.
Eitherway it would at least fire once. i've tried it both ways and print("Prop Killed") never fires.
Is it possible that an earlier hook returns a value (which it shouldn't do), thus preventing your hooks from being fired? I say, try hooking into Think and see if that at least works.
Couldn't find ANY references to it in the fretta base or in PropHunt gamemode.
Instead of checking through every file manually you can list all hooks with [CODE]PrintTable(hook.GetTable())[/CODE] then you'll know where to look assuming developers have chosen reasonable identifiers for their hooks.
Sorry, you need to Log In to post a reply to this thread.