Open LUA anunncer Gurubashi chest

Flauce

:)
Flauce Rep
0
0
0
Rep
0
Flauce Vouches
0
0
0
Vouches
0
Posts
2
Likes
0
Bits
2 YEARS
2 YEARS OF SERVICE
LEVEL 4 185 XP
Hello everyone, I would like you to help me fix the following lua script that I want to be able to do the following but for some reason I don't know what I'm doing wrong:

- Announce when the Gurubashi chest is 45 min., 30 min., 15 min., 10 min., and 5 min., and then tell me when it is ready to be batch and also when a player is ready. has divided everything into a global message ANNOUNCE., what I need is to adapt lua_script for azerothcore.


-- ... (existing code)

local TIMER_INTERVAL_SECONDS = 60 -- Set the timer interval in seconds

-- ... (existing code)

function haS.OnLoot(event, player, item, count, loot, index)
-- Check if the looted item matches the Gurubashi chest item ID
if item:GetEntry() == YOUR_GURUBASHI_CHEST_ITEM_ID then
-- Implement your logic for the Gurubashi chest loot event here
-- For example, you can announce the loot or perform other actions
player:SendBroadcastMessage(player:GetName() .. " looted the Gurubashi chest!")

-- Reset the loot state after looting (optional)
local chestGameObject = GetGameObjectByGUID(item:GetOwner())
if chestGameObject then
chestGameObject:SetLootState(1) -- Set the loot state to "Not Ready" (replace 1 with the appropriate LootState value)
end
end
end

-- ... (existing code)

function haS.StartEvent(Id, player)
-- Existing code...

-- Add the following block to register the loot event
if haS.Conf.ItemReward[haS.ActiveId] ~= nil then
-- Set the loot state of the Gurubashi chest to "Ready" before starting the event (replace 2 with the appropriate LootState value)
local chestGameObject = GetGameObjectByGUID(haS.ObjectGuid)
if chestGameObject then
chestGameObject:SetLootState(2) -- Set the loot state to "Ready" (replace 2 with the appropriate LootState value)
end

player:RegisterEvent(haS.OnLoot, TIMER_INTERVAL_SECONDS * 1000, 0) -- Register the loot event with a timer
end

-- Existing code...

-- Add timers to notify players before the event starts
local notifyIntervals = {45, 30, 15, 10, 5} -- Notification intervals in minutes
for _, interval in ipairs(notifyIntervals) do
local notifyDelay = (TIMER_INTERVAL_SECONDS * (interval * 60)) - 10 -- Notify a little earlier to account for the countdown
player:RegisterEvent(haS.NotifyEvent, notifyDelay, 1, interval)
end

-- Add a timer for the countdown when there are 10 seconds left
local countdownDelay = (TIMER_INTERVAL_SECONDS * 10) - 10 -- Notify 10 seconds earlier for the countdown
player:RegisterEvent(haS.CountdownEvent, countdownDelay, 1)
end

-- Add a function to notify players at specific intervals
function haS.NotifyEvent(event, player, _, minutesBeforeEvent)
player:SendBroadcastMessage("The Gurubashi chest event will start in " .. minutesBeforeEvent .. " minutes! Get ready!")
end

-- Add a function for the countdown when there are 10 seconds left
function haS.CountdownEvent(event, player, _, _)
for i = 10, 1, -1 do
player:SendBroadcastMessage("Event starting in " .. i .. " seconds!")
Sleep(1000) -- Sleep for 1 second
end

player:SendBroadcastMessage("The Gurubashi chest event is starting now!")
end

-- ... (existing code)

thanks for your help
 
Last edited:

3,390

1,271

9,555

428

Top