-- Summon Cooldown in seconds
local GSCD = 30
local GuildSummonCD = {}
function GuildTool_OnGossip(item, event, plr)
if(plr:IsInGuild() == true) then
if(plr:GetGuildLeader() == plr:GetName()) then
item:GossipCreateMenu(100, plr, 0)
item:GossipMenuAddItem(1, "Summon ALL Guild Members", 1, 0, "Are you sure you want to summon ALL guild members?")
item:GossipMenuAddItem(1, "Invite Player to Guild", 2, 1, "Insert Players name into the code box.")
item:GossipMenuAddItem(1, "Kick Player from Guild", 3, 1, "Insert Players name into the code box.")
item:GossipMenuAddItem(1, "Guild Notifications", 4, 0)
item:GossipMenuAddItem(1, "Disband Guild", 7, 1, "To disband your guild, type DISBAND into the code box.")
item:GossipSendMenu(plr)
else
plr:SendBroadcastMessage("You are not this guild's leader!")
end
else
plr:SendBroadcastMessage("You are not in a guild!")
end
end
function GuildTool_OnSubGossip(item, event, plr, id, intid, code)
if(GSCD >= 60) then
GSCD_Timer = GSCD/60
GSCD_Type = "Minutes"
elseif(GSCD < 60) then
GSCD_Timer = GSCD
GSCD_Type = "Seconds"
end
if(intid == 1) then
if GuildSummonCD[plr:GetName()] ~= nil and ((os.clock()-GuildSummonCD[plr:GetName()])) <= GSCD then
plr:SendAreaTriggerMessage("|cFFFF0000You must wait "..GSCD_Timer.." "..GSCD_Type.." before using this function!")
plr:GossipComplete()
else
GuildSummonCD[plr:GetName()] = os.clock()
for k, v in pairs(GetPlayersInWorld()) do
if (v:GetGuildId() == plr:GetGuildId()) then
if(v:GetName() ~= v:GetGuildLeader()) then
v:Teleport(plr:GetMapId(), plr:GetX(), plr:GetY(), plr:GetZ(), plr:GetO())
v:SendBroadcastMessage("You have been summoned by your Guild Master!")
else
plr:SendBroadcastMessage("All guild members have been summoned.")
end
end
end
plr:GossipComplete()
end
end
if(intid == 2) or (intid == 3) then
for k, v in pairs(GetPlayersInWorld()) do
local pCode = code
if(v:GetName() == pCode) then
if(intid == 2) then
if(v:IsInGuild() == true) and (v:GetGuildId() ~= plr:GetGuildId()) then
plr:SendBroadcastMessage(""..pCode.." is already in a guild!")
elseif(v:IsInGuild() == true) and (v:GetGuildId() == plr:GetGuildId()) then
plr:SendBroadcastMessage(""..pCode.." is already in your guild!")
elseif(v:IsInGuild() == false) and (v:GetName() == pCode) then
plr:SendGuildInvite(v)
end
elseif(intid == 3) then
if(v:GetGuildId() == plr:GetGuildId()) then
plr:RemoveGuildMember(v)
elseif(v:GetGuildId() ~= plr:GetGuildId()) then
plr:SendBroadcastMessage(""..pCode.." is not in your guild, or is not online.")
end
end
end
end
plr:GossipComplete()
end
if(intid == 4) then
item:GossipCreateMenu(100, plr, 0)
item:GossipMenuAddItem(1, "Guild Chat Notification", 5, 1, "Insert Guild Chat Notification into the code box.")
item:GossipMenuAddItem(1, "Guild Warning Notifications", 6, 1, "Insert Guild Warning Notification into the code box.")
item:GossipSendMenu(plr)
end
if(intid == 5) or (intid == 6) then
for k, v in pairs(GetPlayersInWorld()) do
local pCode = code
if (v:GetGuildId() == plr:GetGuildId()) then
if(intid == 5) then
v:SendBroadcastMessage("|cFF33FF33[Guild Notification]: |cFFFFFFFF"..pCode.."")
elseif(intid == 6) then
v:SendAreaTriggerMessage("|cFF33FF33[Guild Warning]: |cFFFFFFFF"..pCode.."")
end
end
end
plr:GossipComplete()
end
if(intid == 7) then
local pCode = "DISBAND"
if(code == pCode) then
plr:DisbandGuild()
elseif(code ~= pCode) then
plr:SendBroadcastMessage("You did not type DISBAND into the code box.")
end
plr:GossipComplete()
end
end
RegisterItemGossipEvent(90003, 1, "GuildTool_OnGossip")
RegisterItemGossipEvent(90003, 2, "GuildTool_OnSubGossip")