Code:
-*****************************************
--*UniversalTeleNPC script by Oxin v1.2 *
--* AspireDev.org *
--*Made for SydneyWotlkBeta *
--*Everyone is free to distribute and modify to their *
--*needs but please leave the original credits *
--*****************************************
local npcid = 200000
local menunum = 33310
local menuicon = 4
local teleicon = 2
local menu =
{
{"Class Trainers",
{
{"Paladin", 37, 1160.088257, 371.752472, 355.525665},
{"Priest", 37, 1160.088257, 371.752472, 355.525665},
{"Shaman", 37, 1057.267456, 397.039124, 339.991333},
{"Warrior", 37, 1024.346680, 386.166229, 332.062164},
{"Rogue", 37, 1011.189636, 391.762573, 336.828796},
{"Warlock", 37, 1218.062134, 346.329102, 370.863312},
{"Mage", 37, 1218.062134, 346.329102, 370.863312},
{"Hunter", 37, 1165.920898, 308.611786, 354.212952},
{"Druid", 37, 1165.920898, 308.611786, 354.212952}
}
},
{"Profession Trainers",
{
{"Leatherworking", 37, 1026.105103, 385.793518, 336.799896},
{"Enchanting", 37, 1218.062134, 346.329102, 370.863312},
{"Blacksmithing", 37, 1240.293823, 243.216705, 355.536072},
{"Engineering", 37, 1240.293823, 243.216705, 355.536072},
{"Alchemy", 37, 1227.457886, 198.279648, 354.644836},
{"Tailoring", 37, 1180.818604, 194.865295, 357.214050},
{"Jewelcrafting", 37, 1178.090942, 206.977142, 372.440460},
{"Cooking", 37, 1159.221436, 331.393188, 354.312592}
}
},
{"Vendors",
{
{"Main Vendors", 37, 1175.451782, 270.882629, 357.752716},
{"Gems", 37, 1104.128174, 401.164734, 354.609253},
{"Containers", 37, 1104.128174, 401.164734, 354.609253},
{"Projectiles", 37, 1104.128174, 401.164734, 354.609253},
{"Season 3", 37, 1096.719971, 298.905939, 338.617249},
{"Dungeon Tiers", 37, 1096.719971, 298.905939, 338.617249},
{"Food", 37, 1159.419434, 214.685043, 357.204498}
}
},
{"Innkeeper", 37, 1180.024780, 211.609070, 357.207306},
{"Mounts", 37, 1140.919189, 277.717896, 353.954224},
{"Battlemasters", 37, 99.597717, 344.603516, 333.011078},
{"Weaponmaster", 37, 1143.361450, 213.367447, 356.382141}
}
function TeleNPC_MainMenu(Unit, Player)
local i = 0
Unit:GossipCreateMenu(menunum, Player, 0)
for k,v in pairs(menu) do
i = i + 1
if type(v[2]) == "table" then
Unit:GossipMenuAddItem(menuicon, v[1], i, 0)
i = i + #(v[2])
else
Unit:GossipMenuAddItem(teleicon, v[1], i, 0)
end
end
Unit:GossipSendMenu(Player)
end
function TeleNPC_SubMenu(Unit, Player, i, Submenu)
Unit:GossipCreateMenu(menunum-i, Player, 0)
Unit:GossipMenuAddItem(7, "<--Back", 0, 0)
for k,v in pairs(Submenu) do
i = i + 1
Unit:GossipMenuAddItem(teleicon, v[1], i, 0)
end
Unit:GossipSendMenu(Player)
end
function TeleNPC_OnGossipTalk(Unit, Event, Player)
TeleNPC_MainMenu(Unit, Player)
end
function TeleNPC_OnGossipSelect(Unit, Event, Player, MenuId, Id, Code)
local i = 0
if(Id == 0) then
TeleNPC_MainMenu(Unit,Player)
else
for k,v in pairs(menu) do
i = i + 1
if (Id == i) then
if type(v[2]) == "table" then
TeleNPC_SubMenu(Unit, Player, i, v[2])
else
if Player:IsInCombat() then
Unit:SendChatMessage(12, 0, "You can't teleport while in combat!")
else
Player:Teleport(v[2], v[3], v[4], v[5])
end
Unit:GossipComplete(Player)
end
return
elseif (type(v[2]) == "table") then
for j,w in pairs(v[2]) do
i = i + 1
if (Id == i) then
if Player:IsInCombat() then
Unit:SendChatMessage(12, 0, "You can't teleport while in combat!")
else
Player:Teleport(w[2], w[3], w[4], w[5])
end
Unit:GossipComplete(Player)
return
end
end
end
end
end
end
RegisterUnitGossipEvent(npcid, 1, "TeleNPC_OnGossipTalk")
RegisterUnitGossipEvent(npcid, 2, "TeleNPC_OnGossipSelect")