print("[ElunaGate]: GM Addon loaded!")
local GMAddon = {
Prefix = "GMAddon"
};
-- [[OnChat Trigger]]
function GMAddon.OnChat(Event, Player, Message, Type, Language, Misc)
if (string.lower(Message) == "gmaddon") then
if (Player:IsGM()) then
GMAddon.RenderMainMenu(Player)
else
Player:SendBroadcastMessage("You do not have the correct permissions to access this addon!")
end
end
end
RegisterPlayerEvent(18, GMAddon.OnChat)
-- [[ MAIN MENU ]]
function GMAddon.RenderMainMenu(Player)
GMAddon.MainButtons = {
"Ports",
"Tickets",
"Items",
"Skills",
"Spells",
"GameObjects",
"NPCs",
"Players",
"Pets",
"Communication",
"Ban",
"Server",
"Overrides",
"Modify",
};
local YOffset = 320
local Frame = CreateFrame(GMAddon.Prefix.."MainFrame")
Frame:SetText("ElunaGate GM")
Frame:SetCantMove(false)
Frame:SetHeight(YOffset)
Frame:SetWidth(150)
for k, v in pairs(GMAddon.MainButtons) do
local Button = Frame:CreateButton(GMAddon.Prefix..v)
Button:SetText(v)
Button:SetHeight(15)
Button:SetWidth(130)
Button:SetYOffset(YOffset-200)
Button:SetXOffset(2)
Button:SetEvent("OnClick", function(self, event, Player)
GMAddon.RenderSubMenu(Player, v)
Frame:Hide(Player)
end
)
YOffset = YOffset - 20
end
Frame:Send(Player)
end
function GMAddon.RenderSubMenu(Player, Type)
-- [[ PORTS MENU ]]
GMAddon.Ports = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"PortButton", "Port To", 15, 120, 100, 0},
{"SummonButton", "Summon", 15, 120, 60, 0},
{"AppearButton", "Appear", 15, 120, 40, 0},
{"WPPlayerButton", "Port Player", 15, 120, -60, 0},
{"WPSelfButton", "Port Self", 15, 120, -80, 0},
{"GetCoordButton", "Get Coords", 15, 120, -100, 0},
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
{"PortName", "Input port name here.", 15, 100, 120, 3},
{"PlayerName", "Input Player name here.", 15, 100, 80, 3},
{"MapId", "Input Map ID here.", 15, 100, 20, 3},
{"XCoord", "Input X Coordinate here.", 15, 100, 0, 3},
{"YCoord", "Input Y Coordinate here.", 15, 100, -20, 3},
{"ZCoord", "Input Z Coordinate here.", 15, 100, -40, 3},
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
{"PortName", "PortButton"},
{"PlayerName", "SummonButton"},
{"PlayerName", "AppearButton"},
{"PlayerName", "WPPlayerButton"},
{"MapId", "WPPlayerButton"},
{"XCoord", "WPPlayerButton"},
{"YCoord", "WPPlayerButton"},
{"ZCoord", "WPPlayerButton"},
{"MapId", "WPSelfButton"},
{"XCoord", "WPSelfButton"},
{"YCoord", "WPSelfButton"},
{"ZCoord", "WPSelfButton"},
};
}
-- [[ TICKETS MENU ]]
GMAddon.Tickets = {
Height = 360,
Width = 360,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -160, 0},
{"NextPageButton", ">", 25, 25, -130, 75},
{"PreviousPageButton", "<", 25, 25, -130, -75},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
{"NumberTab", "#", 15, 100, 130, -130, 12},
{"NameTab", "Name", 15, 100, 130, -90, 12},
{"LocationTab", "Location", 15, 100, 130, 50, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Items = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Skills = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Spells = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.GameObjects = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.NPCs = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Players = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Pets = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Communication = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Ban = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Server = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Overrides = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
GMAddon.Modify = {
Height = 320,
Width = 150,
Buttons = {
-- {"ButtonName", "ButtonText", Height, Width, YOffset, XOffset}
{"BackButton", "Back", 15, 100, -135, 0},
},
EditBoxes = {
-- {"EditBoxName", "HoverText", Height, Width, YOffset, XOffset}
},
TextBoxes = {
-- {"TextBoxName", "Text", Height, Width, YOffset, XOffset, TextHeight}
{"WIP", "WORK IN PROGRESS!", 15, 200, 0, 0, 12},
},
StatusLinks = {
-- {"EditBoxName", "ButtonName"}
};
}
if GMAddon[Type] == nil then
Player:SendBroadcastMessage("The "..Type.." button has not yet been coded!")
return
else
-- [[ RENDER WINDOW ]]
local Frame = CreateFrame(GMAddon.Prefix..Type.."SelectFrame")
Frame:SetText(Type)
Frame:SetCantMove(false)
Frame:SetHeight(GMAddon[Type]["Height"])
Frame:SetWidth(GMAddon[Type]["Width"])
-- [[ RENDER BUTTONS ]]
for k, v in pairs(GMAddon[Type]["Buttons"]) do
if Button then
print("True")
end
local Button = Frame:CreateButton(GMAddon.Prefix..Type..v[1])
Button:SetText(v[2])
Button:SetHeight(v[3])
Button:SetWidth(v[4])
Button:SetYOffset(v[5])
Button:SetXOffset(v[6])
-- [[ HANDLE ONCLICK EVENT ]]
Button:SetEvent("OnClick", function(self, event, Player, Cache)
GMAddon.HandleOnClick(Player, Type, Frame, v[1], Cache, Button)
end)
end
-- [[ RENDER TEXT BOXES ]]
for k, v in pairs(GMAddon[Type]["TextBoxes"]) do
local TextBox = Frame:CreateTextBox(GMAddon.Prefix..Type..v[1])
TextBox:SetText(v[2])
TextBox:SetHeight(v[3])
TextBox:SetWidth(v[4])
TextBox:SetYOffset(v[5])
TextBox:SetXOffset(v[6])
TextBox:SetTextHeight(v[7])
end
-- [[ RENDER EDIT BOXES ]]
for k, v in pairs(GMAddon[Type]["EditBoxes"]) do
local EditBox = Frame:CreateEditBox(GMAddon.Prefix..Type..v[1])
EditBox:SetTooltip(v[2])
EditBox:SetHeight(v[3])
EditBox:SetWidth(v[4])
EditBox:SetYOffset(v[5])
EditBox:SetXOffset(v[6])
-- [[ CREATE STATUSLINK ]]
for key, link in pairs(GMAddon[Type]["StatusLinks"]) do
if(v[1] == link[1]) then
EditBox:SetStatusLink(GMAddon.Prefix..Type..link[2])
end
end
end
Frame:Send(Player)
end
end
function GMAddon.HandleOnClick(Player, Type, Frame, Button, Cache)
if(Type == "Ports") then
if(Button == "PortButton") then
-- TODO: Implement tele to name
Player:SendBroadcastMessage("This feature is currently not coded.")
elseif(Button == "SummonButton" or Button == "AppearButton") then
local PlayerNameBox = Cache[3]
if(PlayerNameBox == nil) then
Player:SendBroadcastMessage("Please enter a player name to use this feature.")
return;
end
local SelectedPlayer = GetPlayerByName(PlayerNameBox)
if not SelectedPlayer then
Player:SendBroadcastMessage(PlayerNameBox.." is currently not in game.")
return;
end
if(Button == "SummonButton") then
-- [[ HANDLE SUMMON CODE ]]
SelectedPlayer:Teleport(Player:GetMapId(), Player:GetX(), Player:GetY(), Player:GetZ(), Player:GetO())
Player:SendBroadcastMessage("Summoning "..PlayerNameBox..".")
else
-- [[ HANDLE APPEAR CODE ]]
Player:Teleport(SelectedPlayer:GetMapId(), SelectedPlayer:GetX(), SelectedPlayer:GetY(), SelectedPlayer:GetZ(), SelectedPlayer:GetO())
Player:SendBroadcastMessage("Appearing to "..PlayerNameBox..".")
end
elseif(Button == "WPPlayerButton") then
GMAddon.Temp = {};
-- Handle stupid dynamic cache table...
for k, v in pairs(Cache) do
if v == "GMAddonPortsMapId" then
GMAddon.Temp["MapId"] = tonumber(Cache[k+1])
elseif v == "GMAddonPortsXCoord" then
GMAddon.Temp["X"] = tonumber(Cache[k+1])
elseif v == "GMAddonPortsYCoord" then
GMAddon.Temp["Y"] = tonumber(Cache[k+1])
elseif v == "GMAddonPortsZCoord" then
GMAddon.Temp["Z"] = tonumber(Cache[k+1])
elseif v == "GMAddonPortsPlayerName" then
GMAddon.Temp["PlayerName"] = Cache[k+1]
end
end
local Map, X, Y, Z = GMAddon.Temp["MapId"], GMAddon.Temp["X"], GMAddon.Temp["Y"], GMAddon.Temp["Z"]
if(#Cache < 11) then
Player:SendBroadcastMessage("All fields (Player name and coordinates) must be filled out to teleport a player!")
else
local SelectedPlayer = GetPlayerByName(GMAddon.Temp["PlayerName"])
if not SelectedPlayer or SelectedPlayer == nil then
Player:SendBroadcastMessage(GMAddon.Temp["PlayerName"].." is currently not in game.")
elseif Map == nil or X == nil or Y == nil or Z == nil then
Player:SendBroadcastMessage("Your coordinates are incorrect values.")
else
SelectedPlayer:Teleport(Map, X, Y, Z, 0)
Player:SendBroadcastMessage("Teleporting "..GMAddon.Temp["PlayerName"].." to coordinates: "..Map.." "..X.." "..Y.." "..Z..".")
end
end
GMAddon.Temp = nil;
elseif(Button == "WPSelfButton") then
GMAddon.Temp = {};
-- Handle stupid dynamic cache table...
for k, v in pairs(Cache) do
if v == "GMAddonPortsMapId" then
GMAddon.Temp["MapId"] = tonumber(Cache[k+1])
elseif v == "GMAddonPortsXCoord" then
GMAddon.Temp["X"] = tonumber(Cache[k+1])
elseif v == "GMAddonPortsYCoord" then
GMAddon.Temp["Y"] = tonumber(Cache[k+1])
elseif v == "GMAddonPortsZCoord" then
GMAddon.Temp["Z"] = tonumber(Cache[k+1])
end
end
local Map, X, Y, Z = GMAddon.Temp["MapId"], GMAddon.Temp["X"], GMAddon.Temp["Y"], GMAddon.Temp["Z"]
if(#Cache < 9) then
Player:SendBroadcastMessage("All coordinate fields must be filled out to teleport!")
else
if Map == nil or X == nil or Y == nil or Z == nil then
Player:SendBroadcastMessage("Your coordinates are incorrect values.")
else
Player:Teleport(Map, X, Y, Z, 0)
Player:SendBroadcastMessage("Teleporting to coordinates: "..Map.." "..X.." "..Y.." "..Z..".")
end
end
GMAddon.Temp = nil;
elseif(Button == "GetCoordButton") then
Player:SendBroadcastMessage("Map: "..Player:GetMapId().." X Coord: "..Player:GetX().." Y Coord: "..Player:GetY().." Z Coord: "..Player:GetZ().." Orientation: "..Player:GetO())
end
end
if(Button == "BackButton") then
GMAddon.RenderMainMenu(Player)
Frame:Hide(Player)
end
end