Gnome Running Addon

just not working
 avatar
unknown
lua
2 years ago
2.6 kB
8
Indexable
local frame = CreateFrame("Frame")

-- List of Item IDs for Flare effects
local flareItemIDs = {
  23769, -- red-smoke-flare
  23768, -- white-smoke-flare
  25886, -- purple-smoke-flare
  23770, -- blue-smoke-flare
  23771, -- green-smoke-flare
}

-- Example countdown logic
local countdownInProgress = false
local countdownSeconds = 10

C_Timer.NewTicker(1, function()
  if countdownInProgress then
    countdownSeconds = countdownSeconds - 1
    if countdownSeconds > 0 then
      -- Announce countdown in raid warning
      SendChatMessage("Race starting in " .. countdownSeconds .. " seconds!", "RAID_WARNING")
    else
      -- Announce race start in raid warning
      SendChatMessage("GO GO GO! The race has started!", "RAID_WARNING")
      -- Announce race start in Say chat
      SendChatMessage("GO GO GO! The race has started!", "SAY")
      countdownInProgress = false
      countdownSeconds = 10 -- Reset countdown for next use
    end
  end
end)

-- Register events you want to listen for
frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") -- Event when a unit successfully casts a spell

-- Function to handle events
function frame:OnEvent(event, ...)
  if event == "UNIT_SPELLCAST_SUCCEEDED" then
    local unit, _, _, _, spellID = ...

    print("Event Triggered:", event)
    print("Unit:", unit)
    print("Spell ID:", spellID)

    if unit == "player" then
      local spellName = GetSpellInfo(spellID)

      print("Spell Name:", spellName)

      for _, flareItemID in ipairs(flareItemIDs) do
        local itemName = GetItemInfo(flareItemID)

        print("Checking against Flare Item ID:", flareItemID)
        print("Item Name:", itemName)

        if itemName and spellName and itemName == spellName then
          local playerName = UnitName("player")

          -- Announce in normal chat
          print(playerName .. " used a " .. itemName .. "!")

          -- Announce in raid chat
          SendChatMessage(playerName .. " used a " .. itemName .. "!", "RAID")

          -- Announce in raid warning
          SendChatMessage(playerName .. " used a " .. itemName .. "!", "RAID_WARNING")

          return
        end
      end
    end
  end
end

-- Set the script handler
frame:SetScript("OnEvent", frame.OnEvent)

-- Register slash command for /race
SLASH_START_RACE1 = "/race"
SlashCmdList["START_RACE"] = function(msg)
  if msg == "" then
    -- Handle the /race command
    print("Starting the race!")
    countdownInProgress = true
  else
    print("Invalid command. Usage: /race")
  end
end
Editor is loading...
Leave a Comment