-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpellVendor.lua
More file actions
346 lines (340 loc) · 14.4 KB
/
Copy pathSpellVendor.lua
File metadata and controls
346 lines (340 loc) · 14.4 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
local NpcSpellVendor = 100012
local TokenID = 3000002
local function OnGossipHello(event, player, object, unit)
local pRace = player:GetRaceAsString(2)
local pName = player:GetName();
local class = player:GetClass();
player:GossipClearMenu();
if(class ~= 1) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Ability_Warrior_Warbringer:40:40:-22:0|t Guerrier", 1, 101) end
if(class ~= 2) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Ability_Paladin_SheathofLight:40:40:-22:0|t Paladin", 1, 102) end
if(class ~= 3) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Ability_Hunter_ZenArchery:40:40:-22:0|t Chasseur", 1, 103) end
if(class ~= 4) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Ability_Rogue_Waylay:40:40:-22:0|t Voleur", 1, 104) end
if(class ~= 5) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Spell_Shadow_ShadowPower:40:40:-22:0|t Prêtre", 1, 105) end
if(class ~= 6) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Spell_DeathKnight_FrozenRuneWeapon:40:40:-22:0|t Chevalier de la mort", 1, 106) end
if(class ~= 7) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Spell_Shaman_StaticShock:40:40:-22:0|t Chaman", 1, 107) end
if(class ~= 8) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Ability_Mage_ShatterShield:40:40:-22:0|t Mage", 1, 108) end
if(class ~= 9) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Ability_Warlock_FireandBrimstone:40:40:-22:0|t Démoniste", 1, 109) end
if(class ~= 11) then player:GossipMenuAddItem(0, "|TInterface\\icons\\Ability_Druid_TigersRoar:40:40:-22:0|t Druide", 1, 111) end
player:GossipMenuAddItem(0, "|TInterface\\icons\\Achievement_Dungeon_ClassicRaider:40:40:-22:0|t Hors classe", 1, 110)
player:GossipSetText("De quelle classe souhaitez-vous acheter un sort ?" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
end
local function OnClassSelect(event, player, object, sender, intid, code, menuid)
if(intid == 101) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 1 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Guerrier disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 102) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 2 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Paladin disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 103) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 3 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Chasseur disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 104) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 4 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Voleur disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 105) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 5 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Prêtre disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 106) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 6 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Chevalier de la mort disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 107) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 7 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Chaman disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 108) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 8 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Mage disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 109) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 9 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Démoniste disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 111) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 11 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts du Druide disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 110) then
player:GossipMenuAddItem(0, "Retour", 1, 1)
Query = WorldDBQuery("SELECT * FROM spellvendor WHERE classid = 10 ORDER BY prix DESC;")
if(Query) then
repeat
local row = {
spellid = Query:GetUInt32(0),
prix = Query:GetUInt32(1),
refund = Query:GetUInt32(2),
spellname = Query:GetString(3),
icon = Query:GetString(4),
desc = Query:GetString(5),
}
if(player:HasItem(TokenID, row.prix)) then
row.prix = "|cff337935[" .. row.prix .. " jetons]|r";
else
row.prix = "|cffb12f2f[" .. row.prix .. " jetons]|r";
end
if(player:HasSpell(row.spellid) == false) then
player:GossipMenuAddItem(0, "|TInterface\\icons\\" .. row.icon .. ":40:40:-22:0|t " .. row.spellname .. " " .. row.prix, 1, row.spellid, false, row.desc)
end
until not Query:NextRow()
end
player:GossipSetText("Voici les sorts hors classe disponible" )
player:GossipSendMenu(0x7FFFFFFF, object, MenuId)
elseif(intid == 1) then
OnGossipHello(event, player, object)
else
Query = WorldDBQuery("SELECT prix, spellname FROM spellvendor WHERE spellid = " .. intid .. ";");
if(Query) then
if(player:HasSpell(intid)) then
player:SendBroadcastMessage("Vous possédez déjà ce sort...");
player:GossipComplete();
return false;
end
if(player:HasItem(TokenID, Query:GetUInt32(0))) then
local pGuid = player:GetGUIDLow();
Query2 = WorldDBQuery("SELECT spells, maxspells FROM userspells WHERE guid = " .. pGuid .. ";");
if(Query2) then
player:GossipComplete();
local spells = Query2:GetUInt32(0);
local maxspells = GetPlayerMaxSpell(pGuid);
if(spells >= maxspells)then
player:SendBroadcastMessage("|cffb12f2fVous avez atteint vos "..maxspells.." spells sur ce personnage, vous pouvez augmenter ce nombres par divers moyens.|r");
return false;
end
QueryU = WorldDBExecute("UPDATE userspells SET spells = spells + 1 WHERE guid = " .. pGuid ..";");
player:SendBroadcastMessage("|cff337935Vous venez d'acheter le sort " .. Query:GetString(1));
player:LearnSpell(intid);
player:RemoveItem(TokenID, Query:GetUInt32(0));
else
QueryI = WorldDBExecute("INSERT INTO userspells(guid, spells, maxspells) VALUES(" .. pGuid ..", 1, 8);");
player:SendBroadcastMessage("|cff337935Vous venez d'acheter le sort " .. Query:GetString(1));
player:LearnSpell(intid);
player:RemoveItem(TokenID, Query:GetUInt32(0));
player:GossipComplete();
end
else
player:SendBroadcastMessage("|cffb12f2fVous n'avez pas assez de jetons pour acheter " .. Query:GetString(1));
player:GossipComplete();
end
end
end
end
RegisterCreatureGossipEvent(NpcSpellVendor, 1, OnGossipHello)
RegisterCreatureGossipEvent(NpcSpellVendor, 2, OnClassSelect)
local console = debug.getinfo (1, "S").short_src;
print("- "..console);