Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CreateQue()
- local que = {que = {}}
- function que:Add(index)
- if (self:Has(index)) then
- return false
- end
- self.que[index] = true
- return true
- end
- function que:Remove(index)
- if (not self:Has(index)) then
- return false
- end
- self.que[index] = nil
- return true
- end
- function que:Has(index)
- return self.que[index] ~= nil
- end
- function que:Get()
- return self.que
- end
- local pairs = pairs
- function que:Count()
- local count = 0
- for k,v in pairs(self.que) do
- count = count + 1
- end
- return count
- end
- return que
- end
- function BattleGroundTSOnChat(event, player, msg, _, lang) -- Only for Debug Change this to Creature Gossip
- if (msg == "#test1") then
- OnBattleGroundTSHello(event, player)
- end
- end
- function OnBattleGroundTSHello(event, player)
- local que = CreateQue()
- local plrguid = player:GetGUID()
- local IsInQueue = que:Has(plrguid)
- if IsInQueue then
- player:GossipMenuAddItem(0, "Leave the Battle", 0, 2) -- Leave the queue
- else
- player:GossipMenuAddItem(0, "Join the Battle", 0, 3) -- Join the queue
- end
- player:GossipMenuAddItem(0, "Nevermind..", 0, 1)
- player:GossipSetText("Hello "..player:GetName().."")
- player:GossipSendMenu(0x7FFFFFFF, player, 100)
- end
- function OnBattleGroundTSSelect(event, player, _, sender, intid, code)
- local que = CreateQue()
- local plrguid = player:GetGUID()
- local added = que:Add(plrguid)
- local removed = que:Remove(plrguid)
- if (intid == 1) then -- Close the Gossip
- player:GossipComplete()
- elseif (intid == 2) then -- Leave the queue
- player:removed()
- player:GossipComplete()
- player:SendBroadcastMessage("you leave the queue")
- elseif (intid == 3) then -- Join the queue
- if (result) then
- player:SendBroadcastMessage("you already in the queue") -- player already in the queue
- player:GossipComplete()
- else
- player:added()
- player:SendBroadcastMessage("you join the queue")
- player:RegisterEvent(BattleGroundTSCheck, 10000, 0) -- Check all 10 secounds the queue player count
- player:GossipComplete()
- end
- end
- end
- function BattleGroundTSCheck(event, delay, pCall, player)
- local count = que:Count()
- if (count < 3) then
- player:SendBroadcastMessage("1") -- queue not much player
- else
- player:SendBroadcastMessage("2") -- queue start here the window for invite and teleport
- end
- end
- RegisterPlayerEvent(18, BattleGroundTSOnChat) -- Register Evenet on Chat Command use
- RegisterPlayerGossipEvent(100, 2, OnBattleGroundTSSelect) -- Register Event for Gossip Select
- -- 2014-11-23 15:26:00 lua_scripts/bg.lua:78: attempt to call method 'added' (a nil value)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement