ULX

Author Topic: Hooking PlayerDeath is preventing the base PlayerDeath events from firing.  (Read 2549 times)

0 Members and 1 Guest are viewing this topic.

Offline ambro

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
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.

Code: [Select]
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 )

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
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.
Experiencing God's grace one day at a time.

Offline ambro

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
I am as well,

Question, I found the following ULX hooks for PlayerDeath,

Code: [Select]
./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.

Offline ambro

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
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?

Offline ambro

  • Newbie
  • *
  • Posts: 21
  • Karma: 2
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!

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Glad you found it.
(by asking the duck)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
"Rubber Ducking"  - my favorite form of code debugging!