Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-01-24, 09:59 AM   #1
Kajuvra
A Murloc Raider
Join Date: Feb 2024
Posts: 4
Printing when a player has died in raid chat.

So in my race addon its important to know when someone dies and have that announced to raid chat by the raid leader and i think im going about this all wrong.

In the OnPlayerDead function:
It checks if a race is in progress (GnomeRunner.raceInProgress).
If a race is in progress, it announces the player's death using GnomeRunner.AnnouncePlayerDeath(playerName) in the raid chat.
It also sends an addon message (PLAYER_DEAD: playerName) to the raid leader using C_ChatInfo.SendAddonMessage.
This way, when a player dies, the addon both announces it in the raid chat and sends an addon message to the raid leader. The raid leader's addon can then listen for these messages and handle them accordingly.

Code:
-- New function to announce player deaths in raid chat
function GnomeRunner.AnnouncePlayerDeath(playerName)
    SendChatMessage(playerName .. " has died!", "RAID")
end
Code:
-- Modify the existing OnPlayerDead function
function GnomeRunner.OnPlayerDead()
    GnomeRunner.CheckPlayer()

    if GnomeRunner.raceInProgress then
        local playerName = UnitName("player")

        if UnitIsGroupLeader("player") then
            GnomeRunner.AnnouncePlayerDeath(playerName) -- Announce player death in raid chat
        else
            C_ChatInfo.SendAddonMessage (GnomeRunner.addonPrefix, "PLAYER_DEAD:" .. playerName, "WHISPER", GnomeRunner.raidLeader)
        end

        GnomeRunner.totalDeaths = GnomeRunner.totalDeaths + 1
    end
end
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Printing when a player has died in raid chat.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off