-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpcTeleporter.lua
More file actions
173 lines (149 loc) · 5.78 KB
/
Copy pathNpcTeleporter.lua
File metadata and controls
173 lines (149 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
local NpcSpellVendor = 100017
local TokenID = 21215
local function OnGossipHello(event, player, object, unit)
local pRace = player:GetRaceAsString(2)
local pName = player:GetName();
local class = player:GetClass();
player:GossipClearMenu();
if(player:IsAlliance())then
pFactionTP = "Alliance";
else
pFactionTP = "Horde";
end
local pLevel = player:GetLevel();
if(pLevel >= 80)then
Query = WorldDBQuery('SELECT * FROM npc_teleporter WHERE faction = "All" AND parentgroup = "0" AND active = 1;')
Query2 = WorldDBQuery('SELECT * FROM npc_teleporter WHERE faction = "VIP" AND parentgroup = "0" AND active = 1;')
Query3 = WorldDBQuery('SELECT * FROM npc_teleporter WHERE faction = "'..pFactionTP..'" AND parentgroup = "0" AND active = 1;')
if(Query3) then
repeat
local row3 = {
icon = Query3:GetString(0),
name = Query3:GetString(1),
faction = Query3:GetString(9),
id = Query3:GetUInt32(10)
}
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row3.icon .. ":40:40:-22:0|t " .. row3.name, 1, row3.id)
until not Query3:NextRow()
end
if(Query2) then
repeat
local row2 = {
icon = Query2:GetString(0),
name = Query2:GetString(1),
faction = Query2:GetString(9),
id = Query2:GetUInt32(10)
}
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row2.icon .. ":40:40:-22:0|t " .. row2.name, 1, row2.id)
until not Query2:NextRow()
end
if(Query) then
repeat
local row = {
icon = Query:GetString(0),
name = Query:GetString(1),
faction = Query:GetString(9),
id = Query:GetUInt32(10)
}
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.name, 1, row.id)
until not Query:NextRow()
end
player:GossipSetText("Bonjour " .. pName .. ", où souhaitez-vous aller ?" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
else
player:GossipSetText("Bonjour " .. pName .. ", vous devez être niveau 80 pour pouvoir vous téléporter ailleurs qu'en zone XP." )
player:GossipMenuAddItem(0, "Retourner à la zone xp.", 1, 995)
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
end
end
local function OnClickTeleport(event, player, object, sender, intid, code, menuid)
local pName = player:GetName();
if(intid == 995)then
player:Teleport(1, -6541.454102, 2853.834473, 2.278454, 1.501072);
elseif(intid == 3)then
Query4 = WorldDBQuery('SELECT * FROM npc_teleporter WHERE faction = "All" AND parentgroup = "1" AND active = 1;')
player:GossipClearMenu();
if(Query4) then
repeat
local row4 = {
icon = Query4:GetString(0),
name = Query4:GetString(1),
faction = Query4:GetString(9),
id = Query4:GetUInt32(10)
}
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row4.icon .. ":40:40:-22:0|t " .. row4.name, 1, row4.id)
until not Query4:NextRow()
end
player:GossipMenuAddItem(0, "Retour", 1, 999)
player:GossipSetText("Bonsoir " .. pName .. ", où souhaitez-vous aller ?" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 2)then
Query4 = WorldDBQuery('SELECT * FROM npc_teleporter WHERE faction = "All" AND parentgroup = "2" AND active = 1 ORDER BY name ASC;')
player:GossipClearMenu();
if(Query4) then
repeat
local row4 = {
icon = Query4:GetString(0),
name = Query4:GetString(1),
faction = Query4:GetString(9),
id = Query4:GetUInt32(10)
}
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row4.icon .. ":40:40:-22:0|t " .. row4.name, 1, row4.id)
until not Query4:NextRow()
end
player:GossipMenuAddItem(0, "Retour", 1, 999)
player:GossipSetText("Bonsoir " .. pName .. ", où souhaitez-vous aller ?" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 19)then
Query4 = WorldDBQuery('SELECT * FROM npc_teleporter WHERE faction = "All" AND parentgroup = "3" AND active = 1;')
player:GossipClearMenu();
if(Query4) then
repeat
local row4 = {
icon = Query4:GetString(0),
name = Query4:GetString(1),
faction = Query4:GetString(9),
id = Query4:GetUInt32(10)
}
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row4.icon .. ":40:40:-22:0|t " .. row4.name, 1, row4.id)
until not Query4:NextRow()
end
player:GossipMenuAddItem(0, "Retour", 1, 999)
player:GossipSetText("Bonsoir " .. pName .. ", où souhaitez-vous aller ?" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 24)then
Query4 = WorldDBQuery('SELECT * FROM npc_teleporter WHERE faction = "All" AND parentgroup = "4" AND active = 1;')
player:GossipClearMenu();
if(Query4) then
repeat
local row4 = {
icon = Query4:GetString(0),
name = Query4:GetString(1),
faction = Query4:GetString(9),
id = Query4:GetUInt32(10)
}
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row4.icon .. ":40:40:-22:0|t " .. row4.name, 1, row4.id)
until not Query4:NextRow()
end
player:GossipMenuAddItem(0, "Retour", 1, 999)
player:GossipSetText("Bonsoir " .. pName .. ", où souhaitez-vous aller ?" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 999)then
OnGossipHello(event, player, object, unit);
else
QueryTP = WorldDBQuery('SELECT map, x, y, z, o FROM npc_teleporter WHERE id = "'..intid..'";');
local rowtp = {
map = QueryTP:GetString(0),
x = QueryTP:GetString(1),
y = QueryTP:GetString(2),
z = QueryTP:GetString(3),
o = QueryTP:GetString(4)
}
player:Dismount();
player:Teleport(rowtp.map, rowtp.x, rowtp.y, rowtp.z, rowtp.o);
end
end
RegisterCreatureGossipEvent(NpcSpellVendor, 1, OnGossipHello)
RegisterCreatureGossipEvent(NpcSpellVendor, 2, OnClickTeleport)
local console = debug.getinfo (1, "S").short_src;
print("- "..console);