How can I determine the state of a specific player in the server?

WEEN

Member
Jul 24, 2025
2
0
130
Pronouns
he/him
I'm trying to make a death counter mod for my friends and I. I've gotten far enough to make one counter that both display's the first players name and properly updates on a death. The problem is that the first counter updates on any player dying. I can't for the life of me figure out how to determine which player is the one who is dying. There's probably some index I'm unaware of that I can take advantage of to do this, but I can't find one, hence this thread.
I'm hoping someone more knowledgeable can help me and give me some code example to solve this problem.
 
I'm trying to make a death counter mod for my friends and I. I've gotten far enough to make one counter that both display's the first players name and properly updates on a death. The problem is that the first counter updates on any player dying. I can't for the life of me figure out how to determine which player is the one who is dying. There's probably some index I'm unaware of that I can take advantage of to do this, but I can't find one, hence this thread.
I'm hoping someone more knowledgeable can help me and give me some code example to solve this problem.
What hook are you using? HOOK_ON_DEATH has MarioState passed to the function, and from here you can access its player index. i.e:

Code:
function on_death(m)
        log_to_console(tostring(m.playerIndex))
end

hook_event(HOOK_ON_DEATH, on_death)
 
Thank you both for your insight! While I couldn't find a way to make the m.playerIndex work, I did end up finding through research that I could use gNetworkPlayers[0].globalIndex to do what I was trying to do. I also didn't know about the HOOK_ON_DEATH. I had it working without, but this hook does help with optimization.
 

Users who are viewing this thread