Ulysses
General => Developers Corner => Topic started by: ambro on April 01, 2013, 10:36:35 PM
-
Hello all,
So I'm a bit stumped on this,
I've created my own lua file with a bunch of functionality I've been writing, this is the first hook I've added and it's proven to be a bit troublesome thus far, hopefully someone can provide me with insight on what the problem may be with this.
The server is running the latest version of ULX and is using the TTT gamemode, when I'm using the below functionality / hook, when a player dies, the message is being successfully sent via the hook however, it's preventing the PlayerDeath events from firing, IE, the player will die and will lose control of his character but, on the TAB menu, the player still appears to be alive and can speak in voice to other alive players.
Now, I've tried adding a 20 to the end of the hook "hook.Add( "PlayerDeath", "ULXSendPlayerDeathHook", SendPlayerDeath, 20)" and tried it in the reverse, -20 (I believe raises priority higher).
I did notice that ULX has a logger function in log.lua which also hooks PlayerDeath with a priority of -20, this functionality seems to work fine, doesn't block the base PlayerDeath events at all, so my question is, why is the below blocking the base functionality?
Any information on this will be greatly appreciated.
Thank you all.
local CATEGORY_NAME = "Utility"
------------------------------ Hook PlayerDeath ------------------------------
local function SendPlayerDeath( victim, weapon, killer )
victim:PrintMessage( HUD_PRINTTALK, string.format( "(%s)%s killed you", killer:GetRoleString(), killer:Nick() ) )
end
hook.Add( "PlayerDeath", "ULXSendPlayerDeathHook", SendPlayerDeath )
-
Nothing in there ought to be affecting other hooks. I'm as stumped as you are why this would be giving the results you observe.
-
I am as well,
Question, I found the following ULX hooks for PlayerDeath,
./lua/ulx/lib.lua:hook.Add( "PlayerDeath", "ULXCheckDeath", checkDeath, -10 ) -- Hook it first because we're blocking their death.
./lua/ulx/log.lua:local function playerDeath( victim, weapon, killer )
./lua/ulx/log.lua:hook.Add( "PlayerDeath", "ULXLogDeath", playerDeath, -20 )
./lua/ulx/modules/sh/fun.lua:hook.Add( "PlayerDeath", "ULXCheckFireDeath", checkFireDeath )
./lua/ulx/modules/sh/fun.lua:hook.Add( "PlayerDeath", "ULXCheckMaulDeath", checkMaulDeath, -15 ) -- Hook it first because we're changing speed. Want others to override us.
Should I be assigning my hook at a priority of -19? would that have any effect? or should I not be specifying a priority?
Wondering if perhaps I'm hooking this wrong.
Also worth noting, I have this file installed in the ""/ulx/lua/ulx/modules/sh" folder, could this be causing an issue?
Thanks for your help.
-
So, with the below code, when I die from falling damage for example, I'm in this state of "limbo" I appear to be in spec but, according to the score board, I'm still alive and the round won't end unless I'm slayed.
This is driving me up a wall! I don't suppose someone can try to replicate this on your end?
-
I found the issue, I wasn't handling non player deaths, suicides, falling death, prop kill death in my code, so it was getting hung up there.
After adding in logic to handle that, all is now working!
-
Glad you found it.
(by asking the duck)
-
"Rubber Ducking" - my favorite form of code debugging!