· 5 years ago · Feb 03, 2020, 11:46 AM
1From 624d0fabf899405f6a247e5285ad6ad430afa8b6 Mon Sep 17 00:00:00 2001
2From: Undead <undead02@yandex.ru>
3Date: Sat, 9 Jan 2016 18:48:58 +0300
4Subject: [PATCH 1/4]
5 ============================GuildHouse============================
6
7---
8 sql/GuildHouse/AuthRbacAddGHcommands.sql | 4 +
9 sql/GuildHouse/WorldAddGuildLevelINPinfo.sql | 1 +
10 sql/GuildHouse/WorldSqlAddGHcommands.sql | 4 +
11 sql/GuildHouse/guildLevelSQL_characters.sql | 349 ++
12 sql/GuildHouse/world_guildlevel.sql | 5 +
13 src/server/game/Entities/Player/Player.cpp | 93 +-
14 src/server/game/Entities/Player/Player.h | 3 +-
15 src/server/game/Guilds/Guild.cpp | 124 +-
16 src/server/game/Handlers/MiscHandler.cpp | 12 +-
17 src/server/scripts/Commands/cs_account.cpp | 6012 ++++++++++++++++++++++----
18 src/server/scripts/Commands/cs_misc.cpp | 5 +
19 11 files changed, 5662 insertions(+), 950 deletions(-)
20 create mode 100644 sql/GuildHouse/AuthRbacAddGHcommands.sql
21 create mode 100644 sql/GuildHouse/WorldAddGuildLevelINPinfo.sql
22 create mode 100644 sql/GuildHouse/WorldSqlAddGHcommands.sql
23 create mode 100644 sql/GuildHouse/guildLevelSQL_characters.sql
24 create mode 100644 sql/GuildHouse/world_guildlevel.sql
25
26diff --git a/sql/GuildHouse/AuthRbacAddGHcommands.sql b/sql/GuildHouse/AuthRbacAddGHcommands.sql
27new file mode 100644
28index 0000000..df1b229
29--- /dev/null
30+++ b/sql/GuildHouse/AuthRbacAddGHcommands.sql
31@@ -0,0 +1,4 @@
32+INSERT INTO `rbac_permissions` (`id`, `name`) VALUES (1200, 'Command: guildhouse add');
33+INSERT INTO `rbac_permissions` (`id`, `name`) VALUES (1201, 'Command: guildhouse delete');
34+INSERT INTO `rbac_permissions` (`id`, `name`) VALUES (1202, 'Command: guildhouse tele');
35+INSERT INTO `rbac_permissions` (`id`, `name`) VALUES (1203, 'Command: guildhouse');
36\ No newline at end of file
37diff --git a/sql/GuildHouse/WorldAddGuildLevelINPinfo.sql b/sql/GuildHouse/WorldAddGuildLevelINPinfo.sql
38new file mode 100644
39index 0000000..13688f6
40--- /dev/null
41+++ b/sql/GuildHouse/WorldAddGuildLevelINPinfo.sql
42@@ -0,0 +1 @@
43+INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc1`, `content_loc2`, `content_loc3`, `content_loc4`, `content_loc5`, `content_loc6`, `content_loc7`, `content_loc8`) VALUES (10000, 'Guildlevel: %u', '', '', '', '', '', '', '', 'Уровень гильдии: %u');
44\ No newline at end of file
45diff --git a/sql/GuildHouse/WorldSqlAddGHcommands.sql b/sql/GuildHouse/WorldSqlAddGHcommands.sql
46new file mode 100644
47index 0000000..f3b1e6f
48--- /dev/null
49+++ b/sql/GuildHouse/WorldSqlAddGHcommands.sql
50@@ -0,0 +1,4 @@
51+INSERT INTO `command` (`name`, `permission`, `help`) VALUES ('guildhouse add', '1200', 'Syntax: .guildhouse add "$GuildHouseName" $Cost. Add Guildhouse into Vendor list');
52+INSERT INTO `command` (`name`, `permission`, `help`) VALUES ('guildhouse delete', '1201', 'Syntax: .guildhouse delete "$GuildHouseName" . Delete Guildhouse from Vendor list.');
53+INSERT INTO `command` (`name`, `permission`, `help`) VALUES ('guildhouse tele', '1202', 'Syntax: .guildhouse tele "$GuildName" Teleport yourself in Guildhouse selected Guild.');
54+INSERT INTO `command` (`name`, `permission`, `help`) VALUES ('guildhouse', '1203', 'Syntax: .guldhouse .. Control any Guildhouse. Add Delete or Tele to selected Guildhouse');
55diff --git a/sql/GuildHouse/guildLevelSQL_characters.sql b/sql/GuildHouse/guildLevelSQL_characters.sql
56new file mode 100644
57index 0000000..74154d7
58--- /dev/null
59+++ b/sql/GuildHouse/guildLevelSQL_characters.sql
60@@ -0,0 +1,349 @@
61+/*
62+Navicat MySQL Data Transfer
63+
64+Source Server : alisten
65+Source Server Version : 50543
66+Source Host : localhost:3306
67+Source Database : characters_aw
68+
69+Target Server Type : MYSQL
70+Target Server Version : 50543
71+File Encoding : 65001
72+
73+Date: 2015-05-25 22:51:05
74+*/
75+
76+SET FOREIGN_KEY_CHECKS=0;
77+
78+-- ----------------------------
79+-- Table structure for `guild_learn_spell`
80+-- ----------------------------
81+DROP TABLE IF EXISTS `guild_learn_spell`;
82+CREATE TABLE `guild_learn_spell` (
83+ `guild` bigint(40) unsigned NOT NULL DEFAULT '0',
84+ `spellortitle` bigint(40) unsigned NOT NULL DEFAULT '0',
85+ `isSpell` bigint(40) unsigned NOT NULL DEFAULT '0',
86+ PRIMARY KEY (`guild`,`spellortitle`,`isSpell`)
87+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Guild spell and title';
88+
89+-- ----------------------------
90+-- Records of guild_learn_spell
91+-- ----------------------------
92+
93+-- ----------------------------
94+-- Table structure for `guild_level`
95+-- ----------------------------
96+DROP TABLE IF EXISTS `guild_level`;
97+CREATE TABLE `guild_level` (
98+ `level` int(40) NOT NULL DEFAULT '0',
99+ `xp` int(40) NOT NULL DEFAULT '0',
100+ `guild` int(40) NOT NULL DEFAULT '0',
101+ `color` text,
102+ PRIMARY KEY (`guild`)
103+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
104+
105+-- ----------------------------
106+-- Records of guild_level
107+-- ----------------------------
108+
109+-- ----------------------------
110+-- Table structure for `guild_level_invested`
111+-- ----------------------------
112+DROP TABLE IF EXISTS `guild_level_invested`;
113+CREATE TABLE `guild_level_invested` (
114+ `guild` bigint(40) NOT NULL DEFAULT '0',
115+ `name` varchar(12) NOT NULL DEFAULT '0',
116+ `honor` bigint(40) NOT NULL DEFAULT '0',
117+ `number` bigint(40) NOT NULL DEFAULT '0',
118+ `arena` bigint(40) NOT NULL DEFAULT '0',
119+ `gold` bigint(40) NOT NULL DEFAULT '0',
120+ `svitok` bigint(40) NOT NULL DEFAULT '0',
121+ `token` bigint(40) NOT NULL DEFAULT '0',
122+ PRIMARY KEY (`guild`,`number`,`name`)
123+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
124+
125+-- ----------------------------
126+-- Records of guild_level_invested
127+-- ----------------------------
128+
129+-- ----------------------------
130+-- Table structure for `guild_level_spell`
131+-- ----------------------------
132+DROP TABLE IF EXISTS `guild_level_spell`;
133+CREATE TABLE `guild_level_spell` (
134+ `spellortitle` bigint(40) unsigned NOT NULL DEFAULT '0',
135+ `cost` bigint(40) unsigned NOT NULL DEFAULT '0',
136+ `number` bigint(40) unsigned NOT NULL DEFAULT '0',
137+ `isSpell` bigint(40) unsigned NOT NULL DEFAULT '0',
138+ PRIMARY KEY (`number`)
139+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Guild spell and title';
140+
141+-- ----------------------------
142+-- Records of guild_level_spell
143+-- ----------------------------
144+
145+-- ----------------------------
146+-- Table structure for `guild_xp_table`
147+-- ----------------------------
148+DROP TABLE IF EXISTS `guild_xp_table`;
149+CREATE TABLE `guild_xp_table` (
150+ `level` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT 'guild level',
151+ `xp` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'guild xp',
152+ PRIMARY KEY (`level`)
153+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
154+
155+-- ----------------------------
156+-- Records of guild_xp_table
157+-- ----------------------------
158+INSERT INTO `guild_xp_table` VALUES ('1', '100');
159+INSERT INTO `guild_xp_table` VALUES ('2', '300');
160+INSERT INTO `guild_xp_table` VALUES ('3', '600');
161+INSERT INTO `guild_xp_table` VALUES ('4', '1000');
162+INSERT INTO `guild_xp_table` VALUES ('5', '1500');
163+INSERT INTO `guild_xp_table` VALUES ('6', '2100');
164+INSERT INTO `guild_xp_table` VALUES ('7', '2800');
165+INSERT INTO `guild_xp_table` VALUES ('8', '3600');
166+INSERT INTO `guild_xp_table` VALUES ('9', '4500');
167+INSERT INTO `guild_xp_table` VALUES ('10', '5500');
168+INSERT INTO `guild_xp_table` VALUES ('11', '6600');
169+INSERT INTO `guild_xp_table` VALUES ('12', '7800');
170+INSERT INTO `guild_xp_table` VALUES ('13', '9100');
171+INSERT INTO `guild_xp_table` VALUES ('14', '10500');
172+INSERT INTO `guild_xp_table` VALUES ('15', '12000');
173+INSERT INTO `guild_xp_table` VALUES ('16', '13600');
174+INSERT INTO `guild_xp_table` VALUES ('17', '15300');
175+INSERT INTO `guild_xp_table` VALUES ('18', '17100');
176+INSERT INTO `guild_xp_table` VALUES ('19', '19000');
177+INSERT INTO `guild_xp_table` VALUES ('20', '21000');
178+INSERT INTO `guild_xp_table` VALUES ('21', '23100');
179+INSERT INTO `guild_xp_table` VALUES ('22', '25300');
180+INSERT INTO `guild_xp_table` VALUES ('23', '27600');
181+INSERT INTO `guild_xp_table` VALUES ('24', '30000');
182+INSERT INTO `guild_xp_table` VALUES ('25', '32500');
183+INSERT INTO `guild_xp_table` VALUES ('26', '35100');
184+INSERT INTO `guild_xp_table` VALUES ('27', '37800');
185+INSERT INTO `guild_xp_table` VALUES ('28', '40600');
186+INSERT INTO `guild_xp_table` VALUES ('29', '43500');
187+INSERT INTO `guild_xp_table` VALUES ('30', '46500');
188+
189+-- ----------------------------
190+-- Table structure for `guildhouse_go`
191+-- ----------------------------
192+DROP TABLE IF EXISTS `guildhouse_go`;
193+CREATE TABLE `guildhouse_go` (
194+ `name` text,
195+ `id` bigint(40) NOT NULL DEFAULT '0',
196+ `cost` bigint(40) NOT NULL DEFAULT '0',
197+ `number` bigint(40) NOT NULL DEFAULT '0',
198+ PRIMARY KEY (`id`,`number`)
199+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='gh';
200+
201+-- ----------------------------
202+-- Records of guildhouse_go
203+-- ----------------------------
204+INSERT INTO `guildhouse_go` VALUES ('Палатка урков', '193215', '5', '1000');
205+INSERT INTO `guildhouse_go` VALUES ('Ящик какой-то', '204020', '2', '1001');
206+INSERT INTO `guildhouse_go` VALUES ('Палатка норм', '191742', '4', '1002');
207+INSERT INTO `guildhouse_go` VALUES ('Банк Даларана', '193088', '50', '1003');
208+INSERT INTO `guildhouse_go` VALUES ('Косяк ледоспинки', '192059', '60', '1004');
209+INSERT INTO `guildhouse_go` VALUES ('Косяк ледникового лосося', '192050', '60', '1005');
210+INSERT INTO `guildhouse_go` VALUES ('Косяк ракушечного подкаменщика', '192046', '60', '1006');
211+INSERT INTO `guildhouse_go` VALUES ('Стайка медуз', '192057', '60', '1007');
212+INSERT INTO `guildhouse_go` VALUES ('Статуя Кадгара', '25333', '100', '1008');
213+INSERT INTO `guildhouse_go` VALUES ('Памятник Грому Адскому Крику', '21004', '30', '1009');
214+INSERT INTO `guildhouse_go` VALUES ('Портал в Луносвет', '191010', '30', '1010');
215+INSERT INTO `guildhouse_go` VALUES ('Портал в Громовой Утес', '191011', '30', '1011');
216+INSERT INTO `guildhouse_go` VALUES ('Портал в Подгород', '191012', '30', '1012');
217+INSERT INTO `guildhouse_go` VALUES ('Портал в Оргриммар', '191009', '30', '1013');
218+INSERT INTO `guildhouse_go` VALUES ('Портал в Шаттрат', '191014', '60', '1014');
219+INSERT INTO `guildhouse_go` VALUES ('Портал в Даларан', '201797', '100', '1015');
220+INSERT INTO `guildhouse_go` VALUES ('Косяк дракоперой рыбы-ангела', '192048', '60', '1017');
221+INSERT INTO `guildhouse_go` VALUES ('Почта', '191949', '30', '1016');
222+INSERT INTO `guildhouse_go` VALUES ('Портал в Пещеры времени', '193604', '20', '1019');
223+INSERT INTO `guildhouse_go` VALUES ('Наковальня', '192697', '50', '1020');
224+INSERT INTO `guildhouse_go` VALUES ('Горн', '173064', '30', '1021');
225+INSERT INTO `guildhouse_go` VALUES ('столики красивый', '186422', '50', '1022');
226+INSERT INTO `guildhouse_go` VALUES ('стул в комплект к столику красивому ', '24593', '50', '1023');
227+INSERT INTO `guildhouse_go` VALUES ('стул для барной стойки ', '171617', '50', '1024');
228+INSERT INTO `guildhouse_go` VALUES ('бокал вина на барную стойку ', '192824', '50', '1025');
229+INSERT INTO `guildhouse_go` VALUES ('миска под закуску ', '181592', '50', '1026');
230+INSERT INTO `guildhouse_go` VALUES ('бутылка вина ', '2333', '50', '1027');
231+INSERT INTO `guildhouse_go` VALUES ('мешок с деньжатами', '186736', '50', '1028');
232+INSERT INTO `guildhouse_go` VALUES ('свечка настольная ', '180338', '50', '1029');
233+INSERT INTO `guildhouse_go` VALUES ('нож столовый ', '190353', '50', '1030');
234+INSERT INTO `guildhouse_go` VALUES ('алкоголь ', '2560', '50', '1031');
235+INSERT INTO `guildhouse_go` VALUES ('мужская кружка ', '181307', '50', '1032');
236+INSERT INTO `guildhouse_go` VALUES ('наполненный пивом стакан', '180048', '50', '1033');
237+INSERT INTO `guildhouse_go` VALUES ('бутыль джек дениалса ', '178911', '50', '1034');
238+INSERT INTO `guildhouse_go` VALUES ('бочка для готовки ( под барбекю ) ', '181628', '50', '1035');
239+INSERT INTO `guildhouse_go` VALUES ('барбекю ', '185900', '50', '1036');
240+INSERT INTO `guildhouse_go` VALUES ('каменный валун , удобный для построения ', '191815', '50', '1037');
241+INSERT INTO `guildhouse_go` VALUES ('чаша золотая с вином ', '180754', '50', '1038');
242+INSERT INTO `guildhouse_go` VALUES ('вода и рыбки', '180658', '50', '1039');
243+INSERT INTO `guildhouse_go` VALUES ('напутствие ресторана ', '191942', '50', '1040');
244+INSERT INTO `guildhouse_go` VALUES ('классный фанарь бумажный на столбе', '180766', '50', '1041');
245+INSERT INTO `guildhouse_go` VALUES ('имп в шаре ', '185898', '50', '1042');
246+INSERT INTO `guildhouse_go` VALUES ('кустик ', '185175', '50', '1043');
247+INSERT INTO `guildhouse_go` VALUES ('меч', '190584', '50', '1044');
248+INSERT INTO `guildhouse_go` VALUES ('куст и грибы , красиво ', '190399', '50', '1045');
249+INSERT INTO `guildhouse_go` VALUES ('мини карта азерота ( вражеские действия ) с пометками ', '180852', '50', '1046');
250+INSERT INTO `guildhouse_go` VALUES ('туалет ( деревянный ) ', '186864', '50', '1047');
251+INSERT INTO `guildhouse_go` VALUES ('очень красивая парящая свечка', '179673', '50', '1048');
252+INSERT INTO `guildhouse_go` VALUES ('плита железная ', '185301', '50', '1049');
253+INSERT INTO `guildhouse_go` VALUES ('часы анимированные ', '19415', '50', '1050');
254+INSERT INTO `guildhouse_go` VALUES ('куб из трансформеров', '183877', '50', '1051');
255+INSERT INTO `guildhouse_go` VALUES ('вертикальная деревяшка', '193678', '50', '1052');
256+INSERT INTO `guildhouse_go` VALUES ('плоский ящичек с знаком топора', '194874', '50', '1053');
257+INSERT INTO `guildhouse_go` VALUES ('подушка', '179828', '50', '1054');
258+INSERT INTO `guildhouse_go` VALUES ('синяя подушка', '179832', '50', '1055');
259+INSERT INTO `guildhouse_go` VALUES ('шкура медведя разложена на полу ( ковер )', '19405', '50', '1056');
260+INSERT INTO `guildhouse_go` VALUES ('кошка ( мини объект белого тигра)', '13359', '50', '1057');
261+INSERT INTO `guildhouse_go` VALUES ('тотем ( Лунного Совуха )', '193768', '50', '1058');
262+INSERT INTO `guildhouse_go` VALUES ('краб в клетке на ужин', '188359', '50', '1059');
263+INSERT INTO `guildhouse_go` VALUES ('красивое цветение', '152095', '50', '1060');
264+INSERT INTO `guildhouse_go` VALUES ('большое, красивое, осеннее дерево ', '203037', '50', '1061');
265+INSERT INTO `guildhouse_go` VALUES ('деревцо ( Изумрудный лес )', '185491', '50', '1062');
266+INSERT INTO `guildhouse_go` VALUES ('дерево еще 1 с госипом', '149420', '50', '1063');
267+INSERT INTO `guildhouse_go` VALUES ('фанарь-прожектор ', '193630', '50', '1064');
268+INSERT INTO `guildhouse_go` VALUES ('Портал в Штормград', '190960', '50', '1065');
269+INSERT INTO `guildhouse_go` VALUES ('Портал в Дарнас', '191006', '50', '1066');
270+INSERT INTO `guildhouse_go` VALUES ('Портал в Стальгорн', '191008', '50', '1067');
271+INSERT INTO `guildhouse_go` VALUES ('Портал в Экзодар', '191007', '50', '1068');
272+
273+-- ----------------------------
274+-- Table structure for `guildhouse_npc`
275+-- ----------------------------
276+DROP TABLE IF EXISTS `guildhouse_npc`;
277+CREATE TABLE `guildhouse_npc` (
278+ `name` text,
279+ `id` bigint(40) NOT NULL DEFAULT '0',
280+ `cost` bigint(40) NOT NULL DEFAULT '0',
281+ `number` bigint(40) NOT NULL DEFAULT '0',
282+ PRIMARY KEY (`id`,`number`)
283+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='gh';
284+
285+-- ----------------------------
286+-- Records of guildhouse_npc
287+-- ----------------------------
288+INSERT INTO `guildhouse_npc` VALUES ('Манекен', '31146', '50', '10002');
289+INSERT INTO `guildhouse_npc` VALUES ('Банкир', '28677', '10', '10003');
290+INSERT INTO `guildhouse_npc` VALUES ('ОЛО регистратор Орда', '32170', '20', '10004');
291+INSERT INTO `guildhouse_npc` VALUES ('Распорядитель арены', '29568', '20', '10005');
292+INSERT INTO `guildhouse_npc` VALUES ('Регистратор команд арены', '29534', '20', '10006');
293+INSERT INTO `guildhouse_npc` VALUES ('Аукционер', '8661', '20', '10009');
294+INSERT INTO `guildhouse_npc` VALUES ('Хозяин таверны (Орда)', '6929', '50', '10010');
295+INSERT INTO `guildhouse_npc` VALUES ('Хозяин таверны (нейтрал)', '27187', '50', '10011');
296+INSERT INTO `guildhouse_npc` VALUES ('Учитель Начертания', '28702', '50', '10012');
297+INSERT INTO `guildhouse_npc` VALUES ('Учитель Наложения Чар', '28693', '50', '10013');
298+INSERT INTO `guildhouse_npc` VALUES ('Травник', '28704', '50', '10014');
299+INSERT INTO `guildhouse_npc` VALUES ('Алхимик', '28703', '50', '10015');
300+INSERT INTO `guildhouse_npc` VALUES ('Инженер', '28697', '50', '10016');
301+INSERT INTO `guildhouse_npc` VALUES ('Гном инженер', '29514', '50', '10017');
302+INSERT INTO `guildhouse_npc` VALUES ('Гоблин инженер', '29513', '50', '10018');
303+INSERT INTO `guildhouse_npc` VALUES ('Кожевник', '28700', '50', '10019');
304+INSERT INTO `guildhouse_npc` VALUES ('Учитель Снятия шкур', '28699', '50', '10020');
305+INSERT INTO `guildhouse_npc` VALUES ('Учитель Шитья', '28699', '50', '10021');
306+INSERT INTO `guildhouse_npc` VALUES ('Учитель Первой помощи', '28706', '50', '10022');
307+INSERT INTO `guildhouse_npc` VALUES ('Ювелир', '28701', '50', '10023');
308+INSERT INTO `guildhouse_npc` VALUES ('Учитель кузнечного дела', '29506', '50', '10024');
309+INSERT INTO `guildhouse_npc` VALUES ('Оружейник', '29505', '50', '10025');
310+INSERT INTO `guildhouse_npc` VALUES ('Горняк', '28698', '50', '10026');
311+INSERT INTO `guildhouse_npc` VALUES ('Рыболов', '28742', '50', '10027');
312+INSERT INTO `guildhouse_npc` VALUES ('Наставник Дк (орда)', '28472', '50', '10028');
313+INSERT INTO `guildhouse_npc` VALUES ('Наставник Воинов (орда)', '3354', '50', '10029');
314+INSERT INTO `guildhouse_npc` VALUES ('Наставник Разбойников (орда)', '3401', '50', '10030');
315+INSERT INTO `guildhouse_npc` VALUES ('Наставник Охотников (орда)', '3352', '50', '10031');
316+INSERT INTO `guildhouse_npc` VALUES ('Наставник Шаманов (орда)', '13417', '50', '10032');
317+INSERT INTO `guildhouse_npc` VALUES ('Наставник Жрецов (орда)', '6018', '50', '10033');
318+INSERT INTO `guildhouse_npc` VALUES ('Наставник Магов (орда)', '5882', '50', '10034');
319+INSERT INTO `guildhouse_npc` VALUES ('Наставник Чернокнижников (орда)', '3324', '50', '10035');
320+INSERT INTO `guildhouse_npc` VALUES ('Наставник Паладинов (орда)', '23128', '50', '10036');
321+INSERT INTO `guildhouse_npc` VALUES ('Наставник Друидов (орда)', '3064', '50', '10037');
322+INSERT INTO `guildhouse_npc` VALUES ('Наставник Дк (альянс)', '28472', '50', '10038');
323+INSERT INTO `guildhouse_npc` VALUES ('Наставник Воинов (альянс)', '5479', '50', '10039');
324+INSERT INTO `guildhouse_npc` VALUES ('Наставник Паладинов (альянс)', '928', '50', '10040');
325+INSERT INTO `guildhouse_npc` VALUES ('Наставник Разбойников (альянс)', '918', '50', '10041');
326+INSERT INTO `guildhouse_npc` VALUES ('Наставник Шаманов (альянс)', '20407', '50', '10042');
327+INSERT INTO `guildhouse_npc` VALUES ('Наставник Жрецов (альянс)', '5489', '50', '10043');
328+INSERT INTO `guildhouse_npc` VALUES ('Наставник Магов (альянс)', '331', '50', '10044');
329+INSERT INTO `guildhouse_npc` VALUES ('Наставник Друидов (альянс)', '5504', '50', '10045');
330+INSERT INTO `guildhouse_npc` VALUES ('Наставник Чернокнижников (альянс)', '461', '50', '10046');
331+INSERT INTO `guildhouse_npc` VALUES ('Наставник Охотников (альянс)', '5515', '50', '10047');
332+INSERT INTO `guildhouse_npc` VALUES ('НПС (Уровни Гильдий)', '999999', '50', '10048');
333+INSERT INTO `guildhouse_npc` VALUES ('НПС (Гильдейские заклинания)', '999997', '50', '10049');
334+INSERT INTO `guildhouse_npc` VALUES ('НПС (Дома Гильдий)', '999998', '50', '10050');
335+
336+-- ----------------------------
337+-- Table structure for `guildhouse_npc_spawned`
338+-- ----------------------------
339+DROP TABLE IF EXISTS `guildhouse_npc_spawned`;
340+CREATE TABLE `guildhouse_npc_spawned` (
341+ `guid` bigint(40) NOT NULL DEFAULT '0',
342+ `guildhouse` bigint(40) NOT NULL DEFAULT '0',
343+ PRIMARY KEY (`guid`)
344+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='gh';
345+
346+-- ----------------------------
347+-- Records of guildhouse_npc_spawned
348+-- ----------------------------
349+
350+-- ----------------------------
351+-- Table structure for `guildhouse_spawned`
352+-- ----------------------------
353+DROP TABLE IF EXISTS `guildhouse_spawned`;
354+CREATE TABLE `guildhouse_spawned` (
355+ `guid` bigint(40) NOT NULL DEFAULT '0',
356+ `guildhouse` bigint(40) NOT NULL DEFAULT '0',
357+ PRIMARY KEY (`guid`)
358+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='gh';
359+
360+-- ----------------------------
361+-- Records of guildhouse_spawned
362+-- ----------------------------
363+
364+-- ----------------------------
365+-- Table structure for `guildhouses`
366+-- ----------------------------
367+DROP TABLE IF EXISTS `guildhouses`;
368+CREATE TABLE `guildhouses` (
369+ `guild` bigint(20) unsigned NOT NULL DEFAULT '0',
370+ `name` varchar(255) NOT NULL DEFAULT '',
371+ `x` double NOT NULL,
372+ `y` double NOT NULL,
373+ `z` double NOT NULL,
374+ `radius` double NOT NULL,
375+ `cost` bigint(20) NOT NULL DEFAULT '0',
376+ `number` bigint(20) NOT NULL DEFAULT '0',
377+ `number2` bigint(20) NOT NULL DEFAULT '0',
378+ `map` int(11) NOT NULL,
379+ `sellerGuild` bigint(20) NOT NULL DEFAULT '0',
380+ PRIMARY KEY (`guild`,`name`)
381+) ENGINE=MyISAM AUTO_INCREMENT=43 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
382+
383+-- ----------------------------
384+-- Records of guildhouses
385+-- ----------------------------
386+INSERT INTO `guildhouses` VALUES ('0', 'Tauren village at Veiled Sea (Silithus)', '-10711', '2483', '8', '40', '1000', '1000', '10000', '1', '0');
387+INSERT INTO `guildhouses` VALUES ('3', 'Troll Village in mountains (Darkshore)', '7368', '-1560', '163', '70', '1000', '1001', '10001', '1', '0');
388+INSERT INTO `guildhouses` VALUES ('0', 'Dwarven village (Arathi Highlands, Forbidding Sea)', '-1840', '-4233', '2.14', '40', '1000', '1002', '10002', '0', '0');
389+INSERT INTO `guildhouses` VALUES ('0', 'Tauren camp (Mulgore, Red Rock)', '-723', '-1076', '179', '40', '1000', '1003', '10003', '1', '0');
390+INSERT INTO `guildhouses` VALUES ('0', 'Shadowfang Keep an outside instance (Silverpine Forest)', '-206', '1666', '80', '40', '1000', '1004', '10004', '0', '0');
391+INSERT INTO `guildhouses` VALUES ('4', 'Azshara Crater instance (Alliance entrance)', '1146', '-165', '313', '40', '1000', '1005', '10005', '37', '0');
392+INSERT INTO `guildhouses` VALUES ('0', 'Azshara Crater instance (Horde entrance)', '-123', '858', '298', '40', '1000', '1006', '10006', '37', '0');
393+INSERT INTO `guildhouses` VALUES ('0', 'Quel\'Thalas Tower', '4303', '-2760', '16.8', '60', '2000', '1007', '10007', '0', '1');
394+INSERT INTO `guildhouses` VALUES ('0', 'Zul\'Gurub an outside instance (Stranglethorn Vale)', '-11790', '-1640', '54.7', '40', '1000', '1008', '10008', '0', '0');
395+INSERT INTO `guildhouses` VALUES ('0', 'Goblin village (Tanaris, South Seas)', '-11805', '-4754', '6', '40', '1000', '1009', '10009', '1', '0');
396+INSERT INTO `guildhouses` VALUES ('0', 'Villains camp outside an Stormwind (Elwynn Forest)', '-9296', '670', '132', '40', '1000', '1010', '10010', '0', '0');
397+INSERT INTO `guildhouses` VALUES ('0', 'Stratholm an outside instance', '3414', '-3380', '142.2', '40', '1000', '1011', '10011', '0', '0');
398+INSERT INTO `guildhouses` VALUES ('0', 'The Ring of Valor (Aka. Orgrimmar Arena)', '2176', '-4766', '55', '40', '1000', '1012', '10012', '1', '2');
399+INSERT INTO `guildhouses` VALUES ('0', 'Stonetalon Logging Camp', '1951.512085', '1530.475586', '247.288147', '40', '1000', '1013', '10013', '1', '0');
400+INSERT INTO `guildhouses` VALUES ('0', 'Stonetalon Ruins', '2813.660645', '2248.552979', '215.524643', '40', '1000', '1014', '10014', '1', '0');
401+INSERT INTO `guildhouses` VALUES ('0', 'Teldrassil Furbold camp', '9725.27', '-21.43', '20.03', '40', '1000', '1015', '10015', '1', '0');
402+INSERT INTO `guildhouses` VALUES ('0', 'Wetlands mountain camp', '-3855', '-3479', '579', '40', '1000', '1016', '10016', '0', '0');
403+INSERT INTO `guildhouses` VALUES ('0', 'Ortell\'s Hideout', '-5362', '-2540', '485', '40', '1000', '1017', '10017', '0', '0');
404+INSERT INTO `guildhouses` VALUES ('0', 'Stranglethorn Secret Cave', '-12865', '-1396', '115', '40', '1018', '1000', '10018', '0', '0');
405+INSERT INTO `guildhouses` VALUES ('0', 'Karazhan Smiley', '-11073', '-1956', '39', '40', '1000', '1019', '10019', '0', '0');
406+INSERT INTO `guildhouses` VALUES ('0', 'Well of the Forgotten (Aka. Karazhan Crypt or Lower Karazhan)', '-11084', '-1801', '53', '40', '1000', '1020', '10020', '0', '0');
407+INSERT INTO `guildhouses` VALUES ('0', 'Undercity Top Tier', '1683.235474', '286.458801', '-45.451775', '40', '1000', '1021', '10021', '0', '0');
408+INSERT INTO `guildhouses` VALUES ('2', 'Stormwind Cut-Throat Alley', '-8521.3', '599.5', '101.399338', '40', '1000', '1022', '10022', '0', '0');
409+INSERT INTO `guildhouses` VALUES ('0', 'Temple', '-8660.319336', '1960.115356', '109.184181', '40', '1000', '1023', '10023', '1', '0');
410diff --git a/sql/GuildHouse/world_guildlevel.sql b/sql/GuildHouse/world_guildlevel.sql
411new file mode 100644
412index 0000000..78f161c
413--- /dev/null
414+++ b/sql/GuildHouse/world_guildlevel.sql
415@@ -0,0 +1,5 @@
416+DELETE FROM creature_template WHERE entry IN (999999, 999997, 999998);
417+INSERT INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `ScriptName`) VALUES (999999, 0, 0, 0, 0, 0, 28149, 0, 28149, 0, 'Майк', 'Уровни Гильдий', '', 0, 83, 83, 0, 35, 1, 'npc_guild_level');
418+INSERT INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `ScriptName`) VALUES (999998, 0, 0, 0, 0, 0, 28149, 0, 28149, 0, 'Джордж', 'Дома Гильдии', '', 0, 83, 83, 0, 35, 1, 'npc_guildhouse');
419+INSERT INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction`, `npcflag`, `ScriptName`) VALUES (999997, 0, 0, 0, 0, 0, 28149, 0, 28149, 0, 'Брен', 'Гильдейские заклинания', '', 0, 83, 83, 0, 35, 1, 'npc_guildspell');
420+UPDATE creature_template SET ScriptName='npc_guildhouse_builder', npcflag=1 WHERE entry = 36911;
421diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
422index f4228e3..d5aa37d 100644
423--- a/src/server/game/Entities/Player/Player.cpp
424+++ b/src/server/game/Entities/Player/Player.cpp
425@@ -3025,6 +3025,43 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
426 {
427 if (xp < 1)
428 return;
429+ uint32 guild = GetGuildIdFromDB(this->GetGUID());
430+ QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
431+ if (result && xp > 0) {
432+ Field *fields = result->Fetch();
433+ uint16 level = fields[0].GetUInt16();
434+ uint32 xps = fields[1].GetUInt32();
435+ if (xps >= 100 && xps < 300) xp += xp * 5 / 100;
436+ if (xps >= 300 && xps < 600) xp += xp * 10 / 100;
437+ if (xps >= 600 && xps < 1000) xp += xp * 15 / 100;
438+ if (xps >= 1000 && xps < 1500) xp += xp * 20 / 100;
439+ if (xps >= 1500 && xps < 2100) xp += xp * 25 / 100;
440+ if (xps >= 2100 && xps < 2800) xp += xp * 30 / 100;
441+ if (xps >= 2800 && xps < 3600) xp += xp * 35 / 100;
442+ if (xps >= 3600 && xps < 4500) xp += xp * 40 / 100;
443+ if (xps >= 4500 && xps < 5500) xp += xp * 45 / 100;
444+ if (xps >= 5500 && xps < 6600) xp += xp * 50 / 100;
445+ if (xps >= 6600 && xps < 7800) xp += xp * 55 / 100;
446+ if (xps >= 7800 && xps < 9100) xp += xp * 60 / 100;
447+ if (xps >= 9100 && xps < 10500) xp += xp * 65 / 100;
448+ if (xps >= 10500 && xps < 12000)xp += xp * 70 / 100;
449+ if (xps >= 12000 && xps < 13600) xp += xp * 75 / 100;
450+ if (xps >= 13600 && xps < 15300) xp += xp * 80 / 100;
451+ if (xps >= 15300 && xps < 17100) xp += xp * 85 / 100;
452+ if (xps >= 17100 && xps < 19000) xp += xp * 90 / 100;
453+ if (xps >= 19000 && xps < 21000) xp += xp * 95 / 100;
454+ if (xps >= 21000 && xps < 23100) xp += xp * 100 / 100;
455+ if (xps >= 23100 && xps < 25300) xp += xp * 105 / 100;
456+ if (xps >= 25300 && xps < 27600) xp += xp * 110 / 100;
457+ if (xps >= 27600 && xps < 30000) xp += xp * 115 / 100;
458+ if (xps >= 30000 && xps < 32500) xp += xp * 120 / 100;
459+ if (xps >= 32500 && xps < 35100) xp += xp * 125 / 100;
460+ if (xps >= 35100 && xps < 37800) xp += xp * 130 / 100;
461+ if (xps >= 37800 && xps < 40600) xp += xp * 135 / 100;
462+ if (xps >= 40600 && xps < 43500) xp += xp * 140 / 100;
463+ if (xps >= 43500 && xps < 46500) xp += xp * 145 / 100;
464+
465+ }
466
467 if (!IsAlive() && !GetBattlegroundId())
468 return;
469@@ -7035,6 +7072,50 @@ void Player::CheckAreaExploreAndOutdoor()
470 }
471 }
472 }
473+uint32 Player::GetGuildRate(uint32 amount) const
474+ {
475+ if (uint32 guild = GetGuildId()) {
476+ QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
477+ if (result) {
478+ Field *fields = result->Fetch();
479+ uint16 level = fields[0].GetUInt16();
480+ uint32 xp = fields[1].GetUInt32();
481+ if (xp >= 100 && xp < 300) amount += amount * 5 / 100;
482+ if (xp >= 300 && xp < 600) amount += amount * 10 / 100;
483+ if (xp >= 600 && xp < 1000) amount += amount * 15 / 100;
484+ if (xp >= 1000 && xp < 1500) amount += amount * 20 / 100;
485+ if (xp >= 1500 && xp < 2100) amount += amount * 25 / 100;
486+ if (xp >= 2100 && xp < 2800) amount += amount * 30 / 100;
487+ if (xp >= 2800 && xp < 3600) amount += amount * 35 / 100;
488+ if (xp >= 3600 && xp < 4500) amount += amount * 40 / 100;
489+ if (xp >= 4500 && xp < 5500) amount += amount * 45 / 100;
490+ if (xp >= 5500 && xp < 6600) amount += amount * 50 / 100;
491+ if (xp >= 6600 && xp < 7800) amount += amount * 55 / 100;
492+ if (xp >= 7800 && xp < 9100) amount += amount * 60 / 100;
493+ if (xp >= 9100 && xp < 10500) amount += amount * 65 / 100;
494+ if (xp >= 10500 && xp < 12000)amount += amount * 70 / 100;
495+ if (xp >= 12000 && xp < 13600) amount += amount * 75 / 100;
496+ if (xp >= 13600 && xp < 15300) amount += amount * 80 / 100;
497+ if (xp >= 15300 && xp < 17100) amount += amount * 85 / 100;
498+ if (xp >= 17100 && xp < 19000) amount += amount * 90 / 100;
499+ if (xp >= 19000 && xp < 21000) amount += amount * 95 / 100;
500+ if (xp >= 21000 && xp < 23100) amount += amount * 100 / 100;
501+ if (xp >= 23100 && xp < 25300) amount += amount * 105 / 100;
502+ if (xp >= 25300 && xp < 27600) amount += amount * 110 / 100;
503+ if (xp >= 27600 && xp < 30000) amount += amount * 115 / 100;
504+ if (xp >= 30000 && xp < 32500) amount += amount * 120 / 100;
505+ if (xp >= 32500 && xp < 35100) amount += amount * 125 / 100;
506+ if (xp >= 35100 && xp < 37800) amount += amount * 130 / 100;
507+ if (xp >= 37800 && xp < 40600) amount += amount * 135 / 100;
508+ if (xp >= 40600 && xp < 43500) amount += amount * 140 / 100;
509+ if (xp >= 43500 && xp < 46500) amount += amount * 145 / 100;
510+ }
511+
512+ }
513+
514+ return amount;
515+
516+ }
517
518 uint32 Player::TeamForRace(uint8 race)
519 {
520@@ -7449,7 +7530,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto
521 AddPct(honor_f, GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN_PCT));
522 }
523
524- honor_f *= sWorld->getRate(RATE_HONOR);
525+ honor_f *= GetGuildRate(sWorld->getRate(RATE_HONOR));
526
527 if (GetSession()->isVIP())
528 {
529@@ -9159,7 +9240,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
530 loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this, true);
531 break;
532 default:
533- loot->generateMoneyLoot(item->GetTemplate()->MinMoneyLoot, item->GetTemplate()->MaxMoneyLoot);
534+ loot->generateMoneyLoot(GetGuildRate(item->GetTemplate()->MinMoneyLoot), GetGuildRate(item->GetTemplate()->MaxMoneyLoot));
535 loot->FillLoot(item->GetEntry(), LootTemplates_Item, this, true, loot->gold != 0);
536
537 // Force save the loot and money items that were just rolled
538@@ -9193,7 +9274,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
539 loot->FillLoot(1, LootTemplates_Creature, this, true);
540 // It may need a better formula
541 // Now it works like this: lvl10: ~6copper, lvl70: ~9silver
542- bones->loot.gold = uint32(urand(50, 150) * 0.016f * pow(float(pLevel)/5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY));
543+ bones->loot.gold = GetGuildRate(uint32(urand(50, 150) * 0.016f * pow(float(pLevel) / 5.76f, 2.5f) * sWorld->getRate(RATE_DROP_MONEY)));
544 }
545
546 if (bones->lootRecipient != this)
547@@ -9235,7 +9316,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
548 // Generate extra money for pick pocket loot
549 const uint32 a = urand(0, creature->getLevel() / 2);
550 const uint32 b = urand(0, getLevel() / 2);
551- loot->gold = uint32(10 * (a + b) * sWorld->getRate(RATE_DROP_MONEY));
552+ loot->gold = GetGuildRate(uint32(10 * (a + b) * sWorld->getRate(RATE_DROP_MONEY)));
553 permission = OWNER_PERMISSION;
554 }
555 else
556@@ -15698,7 +15779,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
557 if (getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
558 GiveXP(XP, NULL);
559 else
560- moneyRew = int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY));
561+ moneyRew = GetGuildRate(int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY)));
562
563 // Give player extra money if GetRewOrReqMoney > 0 and get ReqMoney if negative
564 if (quest->GetRewOrReqMoney())
565@@ -17219,7 +17300,7 @@ void Player::SendQuestReward(Quest const* quest, uint32 XP)
566 else
567 {
568 data << uint32(0);
569- data << uint32(quest->GetRewOrReqMoney() + int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY)));
570+ data << GetGuildRate(uint32(quest->GetRewOrReqMoney() + int32(quest->GetRewMoneyMaxLevel() * sWorld->getRate(RATE_DROP_MONEY))));
571 }
572
573 data << uint32(10 * quest->CalculateHonorGain(GetQuestLevel(quest)));
574diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
575index cb4a5b4..9d2f341 100644
576--- a/src/server/game/Entities/Player/Player.h
577+++ b/src/server/game/Entities/Player/Player.h
578@@ -1057,7 +1057,7 @@ class TradeData
579
580 Item* GetSpellCastItem() const;
581 bool HasSpellCastItem() const { return m_spellCastItem != 0; }
582-
583+
584 uint32 GetMoney() const { return m_money; }
585 void SetMoney(uint32 money);
586
587@@ -1658,6 +1658,7 @@ class Player : public Unit, public GridObject<Player>
588 void VehicleSpellInitialize();
589 void SendRemoveControlBar();
590 bool HasSpell(uint32 spell) const;
591+ uint32 GetGuildRate(uint32 amount) const;
592 bool HasActiveSpell(uint32 spell) const; // show in spellbook
593 TrainerSpellState GetTrainerSpellState(TrainerSpell const* trainer_spell) const;
594 bool IsSpellFitByClassAndRace(uint32 spell_id) const;
595diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp
596index a795cca..e8690b6 100644
597--- a/src/server/game/Guilds/Guild.cpp
598+++ b/src/server/game/Guilds/Guild.cpp
599@@ -1183,6 +1183,8 @@ bool Guild::Create(Player* pLeader, std::string const& name)
600 stmt->setUInt32(0, m_id);
601 trans->Append(stmt);
602
603+ CharacterDatabase.PQuery("INSERT INTO guild_level (guild, level, xp) VALUES (%u, 1, 0)", m_id);
604+
605 uint8 index = 0;
606 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD);
607 stmt->setUInt32( index, m_id);
608@@ -1258,6 +1260,10 @@ void Guild::Disband()
609
610 CharacterDatabase.CommitTransaction(trans);
611 sGuildMgr->RemoveGuild(m_id);
612+
613+ uint32 guild = GetId();
614+ CharacterDatabase.PQuery("DELETE FROM guild_level WHERE guild = %u", guild);
615+ CharacterDatabase.PQuery("DELETE FROM guild_level_invested WHERE guild = %u", guild);
616 }
617
618 void Guild::UpdateMemberData(Player* player, uint8 dataid, uint32 value)
619@@ -1570,6 +1576,38 @@ void Guild::HandleAcceptMember(WorldSession* session)
620 return;
621
622 AddMember(player->GetGUID());
623+
624+ uint32 guild = GetId();
625+ std::string name = player->GetName();
626+ QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
627+ if (result) {
628+ do {
629+ Field* fields = result->Fetch();
630+ uint32 spellortitle = fields[0].GetUInt32();
631+ uint32 isSpell = fields[1].GetUInt32();
632+
633+ if (isSpell == 1) player->learnSpell(spellortitle, false);
634+ else player->SetTitle(sCharTitlesStore.LookupEntry(spellortitle));
635+
636+ }
637+ while (result->NextRow());
638+
639+ }
640+
641+ uint32 number;
642+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
643+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number) VALUES (%u, '%s', 0, 0, 10000)", guild, name.c_str());
644+
645+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
646+ if (result3) return;
647+
648+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
649+ if (result2) {
650+ Field* fields = result2->Fetch();
651+ number = fields[0].GetUInt32();
652+
653+ }
654+ CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number) VALUES (%u, '%s', 0, 0, %u)", guild, name.c_str(), number + 1);
655 }
656
657 void Guild::HandleLeaveMember(WorldSession* session)
658@@ -1588,6 +1626,28 @@ void Guild::HandleLeaveMember(WorldSession* session)
659 // Guild is disbanded if leader leaves.
660 Disband();
661 disband = true;
662+
663+ uint32 guild = GetId();
664+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
665+ if (result2) {
666+ do {
667+ Field* fields = result2->Fetch();
668+ uint32 spellortitle = fields[0].GetUInt32();
669+ uint32 isSpell = fields[1].GetUInt32();
670+
671+ if (isSpell == 1) player->removeSpell(spellortitle);
672+ else
673+ {
674+ player->SetTitle(sCharTitlesStore.LookupEntry(spellortitle), true);
675+ if (!player->HasTitle(player->GetInt32Value(PLAYER_CHOSEN_TITLE))) player->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
676+ }
677+
678+ }
679+ while (result2->NextRow());
680+
681+ }
682+
683+ CharacterDatabase.PQuery("DELETE FROM guild_learn_spell WHERE guild = %u", guild);
684 }
685 }
686 else
687@@ -1598,6 +1658,26 @@ void Guild::HandleLeaveMember(WorldSession* session)
688 _BroadcastEvent(GE_LEFT, player->GetGUID(), player->GetName().c_str());
689
690 SendCommandResult(session, GUILD_COMMAND_QUIT, ERR_GUILD_COMMAND_SUCCESS, m_name);
691+
692+ uint32 guild = GetId();
693+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
694+ if (result2) {
695+ do {
696+ Field* fields = result2->Fetch();
697+ uint32 spellortitle = fields[0].GetUInt32();
698+ uint32 isSpell = fields[1].GetUInt32();
699+
700+ if (isSpell == 1) player->removeSpell(spellortitle);
701+ else
702+ {
703+ player->SetTitle(sCharTitlesStore.LookupEntry(spellortitle), true);
704+ if (!player->HasTitle(player->GetInt32Value(PLAYER_CHOSEN_TITLE))) player->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
705+ }
706+
707+ }
708+ while (result2->NextRow());
709+
710+ }
711 }
712
713 sCalendarMgr->RemovePlayerGuildEventsAndSignups(player->GetGUID(), GetId());
714@@ -1630,6 +1710,32 @@ void Guild::HandleRemoveMember(WorldSession* session, std::string const& name)
715 DeleteMember(guid, false, true);
716 _LogEvent(GUILD_EVENT_LOG_UNINVITE_PLAYER, player->GetGUIDLow(), GUID_LOPART(guid));
717 _BroadcastEvent(GE_REMOVED, 0, name.c_str(), player->GetName().c_str());
718+
719+ uint32 guild = GetId();
720+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle, isSpell FROM guild_learn_spell WHERE guild = %u", guild);
721+ if (result2) {
722+ do {
723+ Field* fields = result2->Fetch();
724+ uint32 spellortitle = fields[0].GetUInt32();
725+ uint32 isSpell = fields[1].GetUInt32();
726+
727+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid))
728+ {
729+ if (onlinePlayer->IsInWorld()) {
730+ if (isSpell == 1) onlinePlayer->removeSpell(spellortitle);
731+ else
732+ {
733+ onlinePlayer->SetTitle(sCharTitlesStore.LookupEntry(spellortitle), true);
734+ if (!onlinePlayer->HasTitle(onlinePlayer->GetInt32Value(PLAYER_CHOSEN_TITLE))) onlinePlayer->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
735+ }
736+
737+ }
738+ }
739+
740+ }
741+ while (result2->NextRow());
742+
743+ }
744 }
745 }
746 }
747@@ -1940,7 +2046,23 @@ void Guild::SendLoginInfo(WorldSession* session)
748 bool Guild::LoadFromDB(Field* fields)
749 {
750 m_id = fields[0].GetUInt32();
751- m_name = fields[1].GetString();
752+ QueryResult resul = CharacterDatabase.PQuery("SELECT level, color FROM guild_level WHERE guild = %u", m_id);
753+ if (resul)
754+ {
755+ std::ostringstream m_nam;
756+ Field *field = resul->Fetch();
757+ uint16 leve = field[0].GetUInt16();
758+ std::string color = field[1].GetString();
759+ if (color != "") m_nam << color;
760+ else m_nam << "";
761+ m_nam << fields[1].GetString();
762+ if (color != "") m_nam << "|r (";
763+ else m_nam << " (";
764+ m_nam << leve;
765+ m_nam << " level.)";
766+ m_name = m_nam.str().c_str();
767+ }
768+ else m_name = fields[1].GetString();
769 m_leaderGuid = MAKE_NEW_GUID(fields[2].GetUInt32(), 0, HIGHGUID_PLAYER);
770 m_emblemInfo.LoadFromDB(fields);
771 m_info = fields[8].GetString();
772diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
773index 962d0ca..7ba5483 100644
774--- a/src/server/game/Handlers/MiscHandler.cpp
775+++ b/src/server/game/Handlers/MiscHandler.cpp
776@@ -200,18 +200,18 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
777
778 Guild* _guild = sGuildMgr->GetGuildByName(guild_name);
779 if (_guild)
780- {
781- QueryResult resul = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", _guild->GetId());
782- if (resul)
783 {
784+ QueryResult resul = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", _guild->GetId());
785+ if (resul)
786+ {
787 Field *field = resul->Fetch();
788 uint16 leve = field[0].GetUInt16();
789-
790- guild_name += ": ";
791+
792+ guild_name += ": ";
793 guild_name += leve;
794 guild_name += " level";
795+ }
796 }
797- }
798
799 recvData >> racemask; // race mask
800 recvData >> classmask; // class mask
801diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
802index 1121e4d..c241f9a 100644
803--- a/src/server/scripts/Commands/cs_account.cpp
804+++ b/src/server/scripts/Commands/cs_account.cpp
805@@ -1,19 +1,19 @@
806 /*
807- * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
808- *
809- * This program is free software; you can redistribute it and/or modify it
810- * under the terms of the GNU General Public License as published by the
811- * Free Software Foundation; either version 2 of the License, or (at your
812- * option) any later version.
813- *
814- * This program is distributed in the hope that it will be useful, but WITHOUT
815- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
816- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
817- * more details.
818- *
819- * You should have received a copy of the GNU General Public License along
820- * with this program. If not, see <http://www.gnu.org/licenses/>.
821- */
822+* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
823+*
824+* This program is free software; you can redistribute it and/or modify it
825+* under the terms of the GNU General Public License as published by the
826+* Free Software Foundation; either version 2 of the License, or (at your
827+* option) any later version.
828+*
829+* This program is distributed in the hope that it will be useful, but WITHOUT
830+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
831+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
832+* more details.
833+*
834+* You should have received a copy of the GNU General Public License along
835+* with this program. If not, see <http://www.gnu.org/licenses/>.
836+*/
837
838 /* ScriptData
839 Name: account_commandscript
840@@ -27,933 +27,5073 @@ EndScriptData */
841 #include "Language.h"
842 #include "Player.h"
843 #include "ScriptMgr.h"
844+#include "GuildMgr.h"
845+#include "Guild.h"
846+#include "ObjectMgr.h"
847+#include "SocialMgr.h"
848+#include "World.h"
849+#include "DatabaseEnv.h"
850+#include "ScriptPCH.h"
851+
852+#define sGuildMgr ACE_Singleton<GuildMgr, ACE_Null_Mutex>::instance()
853+void UpdateLevel(Player* player) {
854+ uint32 guild = player->GetGuildId();
855+ QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
856+ if (result) {
857+ Field *fields = result->Fetch();
858+ uint16 level = fields[0].GetUInt16();
859+ uint32 xp = fields[1].GetUInt32();
860+
861+ QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", xp);
862+ if (knowLevel)
863+ {
864+ Field *fs = knowLevel->Fetch();
865+ uint16 gLevel = fs[0].GetUInt16();
866+ CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u", gLevel, guild);
867+ }
868+
869+ }
870+
871+ sGuildMgr->LoadGuilds();
872+
873+}
874+
875
876 class account_commandscript : public CommandScript
877 {
878 public:
879- account_commandscript() : CommandScript("account_commandscript") { }
880-
881- ChatCommand* GetCommands() const override
882- {
883- static ChatCommand accountSetSecTable[] =
884- {
885- { "regmail", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_REGMAIL, true, &HandleAccountSetRegEmailCommand, "", NULL },
886- { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_EMAIL, true, &HandleAccountSetEmailCommand, "", NULL },
887- { NULL, 0, false, NULL, "", NULL }
888- };
889- static ChatCommand accountSetCommandTable[] =
890- {
891- { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "", NULL },
892- { "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, NULL, "", accountSetSecTable },
893- { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleAccountSetGmLevelCommand, "", NULL },
894- { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_PASSWORD, true, &HandleAccountSetPasswordCommand, "", NULL },
895- { NULL, 0, false, NULL, "", NULL }
896- };
897- static ChatCommand accountLockCommandTable[] =
898- {
899- { "country", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_COUNTRY, true, &HandleAccountLockCountryCommand, "", NULL },
900- { "ip", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_IP, true, &HandleAccountLockIpCommand, "", NULL },
901- { NULL, 0, false, NULL, "", NULL }
902- };
903- static ChatCommand accountCommandTable[] =
904- {
905- { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_ADDON, false, &HandleAccountAddonCommand, "", NULL },
906- { "create", rbac::RBAC_PERM_COMMAND_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "", NULL },
907- { "delete", rbac::RBAC_PERM_COMMAND_ACCOUNT_DELETE, true, &HandleAccountDeleteCommand, "", NULL },
908- { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_EMAIL, false, &HandleAccountEmailCommand, "", NULL },
909- { "onlinelist", rbac::RBAC_PERM_COMMAND_ACCOUNT_ONLINE_LIST, true, &HandleAccountOnlineListCommand, "", NULL },
910- { "lock", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK, false, NULL, "", accountLockCommandTable },
911- { "set", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET, true, NULL, "", accountSetCommandTable },
912- { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "", NULL },
913- { "", rbac::RBAC_PERM_COMMAND_ACCOUNT, false, &HandleAccountCommand, "", NULL },
914- { NULL, 0, false, NULL, "", NULL }
915- };
916- static ChatCommand commandTable[] =
917- {
918- { "account", rbac::RBAC_PERM_COMMAND_ACCOUNT, true, NULL, "", accountCommandTable },
919- { NULL, 0, false, NULL, "", NULL }
920- };
921- return commandTable;
922- }
923-
924- static bool HandleAccountAddonCommand(ChatHandler* handler, char const* args)
925- {
926- if (!*args)
927- {
928- handler->SendSysMessage(LANG_CMD_SYNTAX);
929- handler->SetSentErrorMessage(true);
930- return false;
931- }
932-
933- char* exp = strtok((char*)args, " ");
934-
935- uint32 accountId = handler->GetSession()->GetAccountId();
936-
937- int expansion = atoi(exp); //get int anyway (0 if error)
938- if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
939- {
940- handler->SendSysMessage(LANG_IMPROPER_VALUE);
941- handler->SetSentErrorMessage(true);
942- return false;
943- }
944-
945- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION);
946-
947- stmt->setUInt8(0, uint8(expansion));
948- stmt->setUInt32(1, accountId);
949-
950- LoginDatabase.Execute(stmt);
951-
952- handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
953- return true;
954- }
955-
956- /// Create an account
957- static bool HandleAccountCreateCommand(ChatHandler* handler, char const* args)
958- {
959- if (!*args)
960- return false;
961-
962- std::string email;
963-
964- ///- %Parse the command line arguments
965- char* accountName = strtok((char*)args, " ");
966- char* password = strtok(NULL, " ");
967- char* possibleEmail = strtok(NULL, " ' ");
968- if (possibleEmail)
969- email = possibleEmail;
970-
971- if (!accountName || !password)
972- return false;
973-
974- AccountOpResult result = sAccountMgr->CreateAccount(std::string(accountName), std::string(password), email);
975- switch (result)
976- {
977- case AOR_OK:
978- handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
979- if (handler->GetSession())
980- {
981- TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Character:[%s] (GUID: %u) created Account %s (Email: '%s')",
982- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
983- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
984- accountName, email.c_str());
985- }
986- break;
987- case AOR_NAME_TOO_LONG:
988- handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG);
989- handler->SetSentErrorMessage(true);
990- return false;
991- case AOR_NAME_ALREADY_EXIST:
992- handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST);
993- handler->SetSentErrorMessage(true);
994- return false;
995- case AOR_DB_INTERNAL_ERROR:
996- handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName);
997- handler->SetSentErrorMessage(true);
998- return false;
999- default:
1000- handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName);
1001- handler->SetSentErrorMessage(true);
1002- return false;
1003- }
1004-
1005- return true;
1006- }
1007-
1008- /// Delete a user account and all associated characters in this realm
1009- /// @todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm then delete account)
1010- static bool HandleAccountDeleteCommand(ChatHandler* handler, char const* args)
1011- {
1012- if (!*args)
1013- return false;
1014-
1015- ///- Get the account name from the command line
1016- char* account = strtok((char*)args, " ");
1017- if (!account)
1018- return false;
1019-
1020- std::string accountName = account;
1021- if (!AccountMgr::normalizeString(accountName))
1022- {
1023- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1024- handler->SetSentErrorMessage(true);
1025- return false;
1026- }
1027-
1028- uint32 accountId = AccountMgr::GetId(accountName);
1029- if (!accountId)
1030- {
1031- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1032- handler->SetSentErrorMessage(true);
1033- return false;
1034- }
1035-
1036- /// Commands not recommended call from chat, but support anyway
1037- /// can delete only for account with less security
1038- /// This is also reject self apply in fact
1039- if (handler->HasLowerSecurityAccount(NULL, accountId, true))
1040- return false;
1041-
1042- AccountOpResult result = AccountMgr::DeleteAccount(accountId);
1043- switch (result)
1044- {
1045- case AOR_OK:
1046- handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName.c_str());
1047- break;
1048- case AOR_NAME_NOT_EXIST:
1049- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1050- handler->SetSentErrorMessage(true);
1051- return false;
1052- case AOR_DB_INTERNAL_ERROR:
1053- handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName.c_str());
1054- handler->SetSentErrorMessage(true);
1055- return false;
1056- default:
1057- handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName.c_str());
1058- handler->SetSentErrorMessage(true);
1059- return false;
1060- }
1061-
1062- return true;
1063- }
1064-
1065- /// Display info on users currently in the realm
1066- static bool HandleAccountOnlineListCommand(ChatHandler* handler, char const* /*args*/)
1067- {
1068- ///- Get the list of accounts ID logged to the realm
1069- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_ONLINE);
1070-
1071- PreparedQueryResult result = CharacterDatabase.Query(stmt);
1072-
1073- if (!result)
1074- {
1075- handler->SendSysMessage(LANG_ACCOUNT_LIST_EMPTY);
1076- return true;
1077- }
1078-
1079- ///- Display the list of account/characters online
1080- handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR_HEADER);
1081- handler->SendSysMessage(LANG_ACCOUNT_LIST_HEADER);
1082- handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
1083-
1084- ///- Cycle through accounts
1085- do
1086- {
1087- Field* fieldsDB = result->Fetch();
1088- std::string name = fieldsDB[0].GetString();
1089- uint32 account = fieldsDB[1].GetUInt32();
1090-
1091- ///- Get the username, last IP and GM level of each account
1092- // No SQL injection. account is uint32.
1093- stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO);
1094- stmt->setUInt32(0, account);
1095- PreparedQueryResult resultLogin = LoginDatabase.Query(stmt);
1096-
1097- if (resultLogin)
1098- {
1099- Field* fieldsLogin = resultLogin->Fetch();
1100- handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE,
1101- fieldsLogin[0].GetCString(), name.c_str(), fieldsLogin[1].GetCString(),
1102- fieldsDB[2].GetUInt16(), fieldsDB[3].GetUInt16(), fieldsLogin[3].GetUInt8(),
1103- fieldsLogin[2].GetUInt8());
1104- }
1105- else
1106- handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
1107- }
1108- while (result->NextRow());
1109-
1110- handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
1111- return true;
1112- }
1113-
1114- static bool HandleAccountLockCountryCommand(ChatHandler* handler, char const* args)
1115- {
1116- if (!*args)
1117- {
1118- handler->SendSysMessage(LANG_USE_BOL);
1119- handler->SetSentErrorMessage(true);
1120- return false;
1121- }
1122- std::string param = (char*)args;
1123-
1124- if (!param.empty())
1125- {
1126- if (param == "on")
1127- {
1128- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
1129- uint32 ip = inet_addr(handler->GetSession()->GetRemoteAddress().c_str());
1130- EndianConvertReverse(ip);
1131- stmt->setUInt32(0, ip);
1132- PreparedQueryResult result = LoginDatabase.Query(stmt);
1133- if (result)
1134- {
1135- Field* fields = result->Fetch();
1136- std::string country = fields[0].GetString();
1137- stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
1138- stmt->setString(0, country);
1139- stmt->setUInt32(1, handler->GetSession()->GetAccountId());
1140- LoginDatabase.Execute(stmt);
1141- handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
1142- }
1143- else
1144- {
1145- handler->PSendSysMessage("[IP2NATION] Table empty");
1146- TC_LOG_DEBUG("server.authserver", "[IP2NATION] Table empty");
1147- }
1148- }
1149- else if (param == "off")
1150- {
1151- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
1152- stmt->setString(0, "00");
1153- stmt->setUInt32(1, handler->GetSession()->GetAccountId());
1154- LoginDatabase.Execute(stmt);
1155- handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
1156- }
1157- return true;
1158- }
1159- handler->SendSysMessage(LANG_USE_BOL);
1160- handler->SetSentErrorMessage(true);
1161- return false;
1162- }
1163-
1164- static bool HandleAccountLockIpCommand(ChatHandler* handler, char const* args)
1165- {
1166- if (!*args)
1167- {
1168- handler->SendSysMessage(LANG_USE_BOL);
1169- handler->SetSentErrorMessage(true);
1170- return false;
1171- }
1172-
1173- std::string param = (char*)args;
1174-
1175- if (!param.empty())
1176- {
1177- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK);
1178-
1179- if (param == "on")
1180- {
1181- stmt->setBool(0, true); // locked
1182- handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
1183- }
1184- else if (param == "off")
1185- {
1186- stmt->setBool(0, false); // unlocked
1187- handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
1188- }
1189-
1190- stmt->setUInt32(1, handler->GetSession()->GetAccountId());
1191-
1192- LoginDatabase.Execute(stmt);
1193- return true;
1194- }
1195-
1196- handler->SendSysMessage(LANG_USE_BOL);
1197- handler->SetSentErrorMessage(true);
1198- return false;
1199- }
1200-
1201- static bool HandleAccountEmailCommand(ChatHandler* handler, char const* args)
1202- {
1203- if (!*args)
1204- {
1205- handler->SendSysMessage(LANG_CMD_SYNTAX);
1206- handler->SetSentErrorMessage(true);
1207- return false;
1208- }
1209-
1210- char* oldEmail = strtok((char*)args, " ");
1211- char* password = strtok(NULL, " ");
1212- char* email = strtok(NULL, " ");
1213- char* emailConfirmation = strtok(NULL, " ");
1214-
1215- if (!oldEmail || !password || !email || !emailConfirmation)
1216- {
1217- handler->SendSysMessage(LANG_CMD_SYNTAX);
1218- handler->SetSentErrorMessage(true);
1219- return false;
1220- }
1221-
1222- if (!AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), std::string(oldEmail)))
1223- {
1224- handler->SendSysMessage(LANG_COMMAND_WRONGEMAIL);
1225- sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
1226- handler->SetSentErrorMessage(true);
1227- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided email [%s] is not equal to registration email [%s].",
1228- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
1229- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
1230- email, oldEmail);
1231- return false;
1232- }
1233-
1234- if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(password)))
1235- {
1236- handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
1237- sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
1238- handler->SetSentErrorMessage(true);
1239- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.",
1240- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
1241- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
1242- return false;
1243- }
1244-
1245- if (strcmp(email, oldEmail) == 0)
1246- {
1247- handler->SendSysMessage(LANG_OLD_EMAIL_IS_NEW_EMAIL);
1248- sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
1249- handler->SetSentErrorMessage(true);
1250- return false;
1251- }
1252-
1253- if (strcmp(email, emailConfirmation) != 0)
1254- {
1255- handler->SendSysMessage(LANG_NEW_EMAILS_NOT_MATCH);
1256- sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
1257- handler->SetSentErrorMessage(true);
1258- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.",
1259- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
1260- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
1261- return false;
1262- }
1263-
1264-
1265- AccountOpResult result = AccountMgr::ChangeEmail(handler->GetSession()->GetAccountId(), std::string(email));
1266- switch (result)
1267- {
1268- case AOR_OK:
1269- handler->SendSysMessage(LANG_COMMAND_EMAIL);
1270- sScriptMgr->OnEmailChange(handler->GetSession()->GetAccountId());
1271- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Email from [%s] to [%s].",
1272- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
1273- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
1274- oldEmail, email);
1275- break;
1276- case AOR_EMAIL_TOO_LONG:
1277- handler->SendSysMessage(LANG_EMAIL_TOO_LONG);
1278- sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
1279- handler->SetSentErrorMessage(true);
1280- return false;
1281- default:
1282- handler->SendSysMessage(LANG_COMMAND_NOTCHANGEEMAIL);
1283- handler->SetSentErrorMessage(true);
1284- return false;
1285- }
1286-
1287- return true;
1288- }
1289-
1290- static bool HandleAccountPasswordCommand(ChatHandler* handler, char const* args)
1291- {
1292- // If no args are given at all, we can return false right away.
1293- if (!*args)
1294- {
1295- handler->SendSysMessage(LANG_CMD_SYNTAX);
1296- handler->SetSentErrorMessage(true);
1297- return false;
1298- }
1299-
1300- // First, we check config. What security type (sec type) is it ? Depending on it, the command branches out
1301- uint32 pwConfig = sWorld->getIntConfig(CONFIG_ACC_PASSCHANGESEC); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC
1302-
1303- // Command is supposed to be: .account password [$oldpassword] [$newpassword] [$newpasswordconfirmation] [$emailconfirmation]
1304- char* oldPassword = strtok((char*)args, " "); // This extracts [$oldpassword]
1305- char* newPassword = strtok(NULL, " "); // This extracts [$newpassword]
1306- char* passwordConfirmation = strtok(NULL, " "); // This extracts [$newpasswordconfirmation]
1307- char const* emailConfirmation = strtok(NULL, " "); // This defines the emailConfirmation variable, which is optional depending on sec type.
1308- if (!emailConfirmation) // This extracts [$emailconfirmation]. If it doesn't exist, however...
1309- emailConfirmation = ""; // ... it's simply "" for emailConfirmation.
1310-
1311- //Is any of those variables missing for any reason ? We return false.
1312- if (!oldPassword || !newPassword || !passwordConfirmation)
1313- {
1314- handler->SendSysMessage(LANG_CMD_SYNTAX);
1315- handler->SetSentErrorMessage(true);
1316- return false;
1317- }
1318-
1319- // We compare the old, saved password to the entered old password - no chance for the unauthorized.
1320- if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(oldPassword)))
1321- {
1322- handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
1323- sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
1324- handler->SetSentErrorMessage(true);
1325- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the provided old password is wrong.",
1326- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
1327- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
1328- return false;
1329- }
1330-
1331- // This compares the old, current email to the entered email - however, only...
1332- if ((pwConfig == PW_EMAIL || (pwConfig == PW_RBAC && handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE))) // ...if either PW_EMAIL or PW_RBAC with the Permission is active...
1333- && !AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), std::string(emailConfirmation))) // ... and returns false if the comparison fails.
1334- {
1335- handler->SendSysMessage(LANG_COMMAND_WRONGEMAIL);
1336- sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
1337- handler->SetSentErrorMessage(true);
1338- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the entered email [%s] is wrong.",
1339- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
1340- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
1341- emailConfirmation);
1342- return false;
1343- }
1344-
1345- // Making sure that newly entered password is correctly entered.
1346- if (strcmp(newPassword, passwordConfirmation) != 0)
1347- {
1348- handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
1349- sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
1350- handler->SetSentErrorMessage(true);
1351- return false;
1352- }
1353-
1354- // Changes password and prints result.
1355- AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(newPassword));
1356- switch (result)
1357- {
1358- case AOR_OK:
1359- handler->SendSysMessage(LANG_COMMAND_PASSWORD);
1360- sScriptMgr->OnPasswordChange(handler->GetSession()->GetAccountId());
1361- TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Password.",
1362- handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
1363- handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
1364- break;
1365- case AOR_PASS_TOO_LONG:
1366- handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
1367- sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
1368- handler->SetSentErrorMessage(true);
1369- return false;
1370- default:
1371- handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
1372- handler->SetSentErrorMessage(true);
1373- return false;
1374- }
1375-
1376- return true;
1377- }
1378-
1379- static bool HandleAccountCommand(ChatHandler* handler, char const* /*args*/)
1380- {
1381- // GM Level
1382- AccountTypes gmLevel = handler->GetSession()->GetSecurity();
1383- handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmLevel));
1384-
1385- // Security level required
1386- bool hasRBAC = (handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE) ? true : false);
1387- uint32 pwConfig = sWorld->getIntConfig(CONFIG_ACC_PASSCHANGESEC); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC
1388-
1389- handler->PSendSysMessage(LANG_ACCOUNT_SEC_TYPE, (pwConfig == PW_NONE ? "Lowest level: No Email input required." :
1390- pwConfig == PW_EMAIL ? "Highest level: Email input required." :
1391- pwConfig == PW_RBAC ? "Special level: Your account may require email input depending on settings. That is the case if another lien is printed." :
1392- "Unknown security level: Notify technician for details."));
1393-
1394- // RBAC required display - is not displayed for console
1395- if (pwConfig == PW_RBAC && handler->GetSession() && hasRBAC)
1396- handler->PSendSysMessage(LANG_RBAC_EMAIL_REQUIRED);
1397-
1398- // Email display if sufficient rights
1399- if (handler->HasPermission(rbac::RBAC_PERM_MAY_CHECK_OWN_EMAIL))
1400- {
1401- std::string emailoutput;
1402- uint32 accountId = handler->GetSession()->GetAccountId();
1403-
1404- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_EMAIL_BY_ID);
1405- stmt->setUInt32(0, accountId);
1406- PreparedQueryResult result = LoginDatabase.Query(stmt);
1407-
1408- if (result)
1409- {
1410- emailoutput = (*result)[0].GetString();
1411- handler->PSendSysMessage(LANG_COMMAND_EMAIL_OUTPUT, emailoutput.c_str());
1412- }
1413- }
1414-
1415- return true;
1416- }
1417-
1418- /// Set/Unset the expansion level for an account
1419- static bool HandleAccountSetAddonCommand(ChatHandler* handler, char const* args)
1420- {
1421- ///- Get the command line arguments
1422- char* account = strtok((char*)args, " ");
1423- char* exp = strtok(NULL, " ");
1424-
1425- if (!account)
1426- return false;
1427-
1428- std::string accountName;
1429- uint32 accountId;
1430-
1431- if (!exp)
1432- {
1433- Player* player = handler->getSelectedPlayer();
1434- if (!player)
1435- return false;
1436-
1437- accountId = player->GetSession()->GetAccountId();
1438- AccountMgr::GetName(accountId, accountName);
1439- exp = account;
1440- }
1441- else
1442- {
1443- ///- Convert Account name to Upper Format
1444- accountName = account;
1445- if (!AccountMgr::normalizeString(accountName))
1446- {
1447- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1448- handler->SetSentErrorMessage(true);
1449- return false;
1450- }
1451-
1452- accountId = AccountMgr::GetId(accountName);
1453- if (!accountId)
1454- {
1455- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1456- handler->SetSentErrorMessage(true);
1457- return false;
1458- }
1459- }
1460-
1461- // Let set addon state only for lesser (strong) security level
1462- // or to self account
1463- if (handler->GetSession() && handler->GetSession()->GetAccountId() != accountId &&
1464- handler->HasLowerSecurityAccount(NULL, accountId, true))
1465- return false;
1466-
1467- int expansion = atoi(exp); //get int anyway (0 if error)
1468- if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
1469- return false;
1470-
1471- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION);
1472-
1473- stmt->setUInt8(0, expansion);
1474- stmt->setUInt32(1, accountId);
1475-
1476- LoginDatabase.Execute(stmt);
1477-
1478- handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion);
1479- return true;
1480- }
1481-
1482- static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, char const* args)
1483- {
1484- if (!*args)
1485- {
1486- handler->SendSysMessage(LANG_CMD_SYNTAX);
1487- handler->SetSentErrorMessage(true);
1488- return false;
1489- }
1490-
1491- std::string targetAccountName;
1492- uint32 targetAccountId = 0;
1493- uint32 targetSecurity = 0;
1494- uint32 gm = 0;
1495- char* arg1 = strtok((char*)args, " ");
1496- char* arg2 = strtok(NULL, " ");
1497- char* arg3 = strtok(NULL, " ");
1498- bool isAccountNameGiven = true;
1499-
1500- if (!arg3)
1501- {
1502- if (!handler->getSelectedPlayer())
1503- return false;
1504- isAccountNameGiven = false;
1505- }
1506-
1507- // Check for second parameter
1508- if (!isAccountNameGiven && !arg2)
1509- return false;
1510-
1511- // Check for account
1512- if (isAccountNameGiven)
1513- {
1514- targetAccountName = arg1;
1515- if (!AccountMgr::normalizeString(targetAccountName))
1516- {
1517- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, targetAccountName.c_str());
1518- handler->SetSentErrorMessage(true);
1519- return false;
1520- }
1521- }
1522-
1523- // Check for invalid specified GM level.
1524- gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
1525- if (gm > SEC_CONSOLE)
1526- {
1527- handler->SendSysMessage(LANG_BAD_VALUE);
1528- handler->SetSentErrorMessage(true);
1529- return false;
1530- }
1531-
1532- // handler->getSession() == NULL only for console
1533- targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
1534- int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
1535- uint32 playerSecurity;
1536- if (handler->GetSession())
1537- playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
1538- else
1539- playerSecurity = SEC_CONSOLE;
1540-
1541- // can set security level only for target with less security and to less security that we have
1542- // This also restricts setting handler's own security.
1543- targetSecurity = AccountMgr::GetSecurity(targetAccountId, gmRealmID);
1544- if (targetSecurity >= playerSecurity || gm >= playerSecurity)
1545- {
1546- handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
1547- handler->SetSentErrorMessage(true);
1548- return false;
1549- }
1550-
1551- // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
1552- if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
1553- {
1554- PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST);
1555-
1556- stmt->setUInt32(0, targetAccountId);
1557- stmt->setUInt8(1, uint8(gm));
1558-
1559- PreparedQueryResult result = LoginDatabase.Query(stmt);
1560-
1561- if (result)
1562- {
1563- handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
1564- handler->SetSentErrorMessage(true);
1565- return false;
1566- }
1567- }
1568-
1569- // Check if provided realmID has a negative value other than -1
1570- if (gmRealmID < -1)
1571- {
1572- handler->SendSysMessage(LANG_INVALID_REALMID);
1573- handler->SetSentErrorMessage(true);
1574- return false;
1575- }
1576-
1577- rbac::RBACData* rbac = isAccountNameGiven ? NULL : handler->getSelectedPlayer()->GetSession()->GetRBACData();
1578- sAccountMgr->UpdateAccountAccess(rbac, targetAccountId, uint8(gm), gmRealmID);
1579-
1580- handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
1581- return true;
1582- }
1583-
1584- /// Set password for account
1585- static bool HandleAccountSetPasswordCommand(ChatHandler* handler, char const* args)
1586- {
1587- if (!*args)
1588- {
1589- handler->SendSysMessage(LANG_CMD_SYNTAX);
1590- handler->SetSentErrorMessage(true);
1591- return false;
1592- }
1593-
1594- ///- Get the command line arguments
1595- char* account = strtok((char*)args, " ");
1596- char* password = strtok(NULL, " ");
1597- char* passwordConfirmation = strtok(NULL, " ");
1598-
1599- if (!account || !password || !passwordConfirmation)
1600- return false;
1601-
1602- std::string accountName = account;
1603- if (!AccountMgr::normalizeString(accountName))
1604- {
1605- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1606- handler->SetSentErrorMessage(true);
1607- return false;
1608- }
1609-
1610- uint32 targetAccountId = AccountMgr::GetId(accountName);
1611- if (!targetAccountId)
1612- {
1613- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1614- handler->SetSentErrorMessage(true);
1615- return false;
1616- }
1617-
1618- /// can set password only for target with less security
1619- /// This also restricts setting handler's own password
1620- if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
1621- return false;
1622-
1623- if (strcmp(password, passwordConfirmation))
1624- {
1625- handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
1626- handler->SetSentErrorMessage(true);
1627- return false;
1628- }
1629-
1630- AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, password);
1631-
1632- switch (result)
1633- {
1634- case AOR_OK:
1635- handler->SendSysMessage(LANG_COMMAND_PASSWORD);
1636- break;
1637- case AOR_NAME_NOT_EXIST:
1638- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1639- handler->SetSentErrorMessage(true);
1640- return false;
1641- case AOR_PASS_TOO_LONG:
1642- handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
1643- handler->SetSentErrorMessage(true);
1644- return false;
1645- default:
1646- handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
1647- handler->SetSentErrorMessage(true);
1648- return false;
1649- }
1650- return true;
1651- }
1652-
1653- /// Set normal email for account
1654- static bool HandleAccountSetEmailCommand(ChatHandler* handler, char const* args)
1655- {
1656- if (!*args)
1657- return false;
1658-
1659- ///- Get the command line arguments
1660- char* account = strtok((char*)args, " ");
1661- char* email = strtok(NULL, " ");
1662- char* emailConfirmation = strtok(NULL, " ");
1663-
1664- if (!account || !email || !emailConfirmation)
1665- {
1666- handler->SendSysMessage(LANG_CMD_SYNTAX);
1667- handler->SetSentErrorMessage(true);
1668- return false;
1669- }
1670-
1671- std::string accountName = account;
1672- if (!AccountMgr::normalizeString(accountName))
1673- {
1674- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1675- handler->SetSentErrorMessage(true);
1676- return false;
1677- }
1678-
1679- uint32 targetAccountId = AccountMgr::GetId(accountName);
1680- if (!targetAccountId)
1681- {
1682- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1683- handler->SetSentErrorMessage(true);
1684- return false;
1685- }
1686-
1687- /// can set email only for target with less security
1688- /// This also restricts setting handler's own email.
1689- if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
1690- return false;
1691-
1692- if (strcmp(email, emailConfirmation) != 0)
1693- {
1694- handler->SendSysMessage(LANG_NEW_EMAILS_NOT_MATCH);
1695- handler->SetSentErrorMessage(true);
1696- return false;
1697- }
1698-
1699- AccountOpResult result = AccountMgr::ChangeEmail(targetAccountId, email);
1700- switch (result)
1701- {
1702- case AOR_OK:
1703- handler->SendSysMessage(LANG_COMMAND_EMAIL);
1704- TC_LOG_INFO("entities.player.character", "ChangeEmail: Account %s [Id: %u] had it's email changed to %s.",
1705- accountName.c_str(), targetAccountId, email);
1706- break;
1707- case AOR_NAME_NOT_EXIST:
1708- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1709- handler->SetSentErrorMessage(true);
1710- return false;
1711- case AOR_EMAIL_TOO_LONG:
1712- handler->SendSysMessage(LANG_EMAIL_TOO_LONG);
1713- handler->SetSentErrorMessage(true);
1714- return false;
1715- default:
1716- handler->SendSysMessage(LANG_COMMAND_NOTCHANGEEMAIL);
1717- handler->SetSentErrorMessage(true);
1718- return false;
1719- }
1720-
1721- return true;
1722- }
1723-
1724- /// Change registration email for account
1725- static bool HandleAccountSetRegEmailCommand(ChatHandler* handler, char const* args)
1726- {
1727- if (!*args)
1728- return false;
1729-
1730- //- We do not want anything short of console to use this by default.
1731- //- So we force that.
1732- if (handler->GetSession())
1733- return false;
1734-
1735- ///- Get the command line arguments
1736- char* account = strtok((char*)args, " ");
1737- char* email = strtok(NULL, " ");
1738- char* emailConfirmation = strtok(NULL, " ");
1739-
1740- if (!account || !email || !emailConfirmation)
1741- {
1742- handler->SendSysMessage(LANG_CMD_SYNTAX);
1743- handler->SetSentErrorMessage(true);
1744- return false;
1745- }
1746-
1747- std::string accountName = account;
1748- if (!AccountMgr::normalizeString(accountName))
1749- {
1750- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1751- handler->SetSentErrorMessage(true);
1752- return false;
1753- }
1754-
1755- uint32 targetAccountId = AccountMgr::GetId(accountName);
1756- if (!targetAccountId)
1757- {
1758- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1759- handler->SetSentErrorMessage(true);
1760- return false;
1761- }
1762-
1763- /// can set email only for target with less security
1764- /// This also restricts setting handler's own email.
1765- if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
1766- return false;
1767-
1768- if (strcmp(email, emailConfirmation) != 0)
1769- {
1770- handler->SendSysMessage(LANG_NEW_EMAILS_NOT_MATCH);
1771- handler->SetSentErrorMessage(true);
1772- return false;
1773- }
1774-
1775- AccountOpResult result = AccountMgr::ChangeRegEmail(targetAccountId, email);
1776- switch (result)
1777- {
1778- case AOR_OK:
1779- handler->SendSysMessage(LANG_COMMAND_EMAIL);
1780- TC_LOG_INFO("entities.player.character", "ChangeRegEmail: Account %s [Id: %u] had it's Registration Email changed to %s.",
1781- accountName.c_str(), targetAccountId, email);
1782- break;
1783- case AOR_NAME_NOT_EXIST:
1784- handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
1785- handler->SetSentErrorMessage(true);
1786- return false;
1787- case AOR_EMAIL_TOO_LONG:
1788- handler->SendSysMessage(LANG_EMAIL_TOO_LONG);
1789- handler->SetSentErrorMessage(true);
1790- return false;
1791- default:
1792- handler->SendSysMessage(LANG_COMMAND_NOTCHANGEEMAIL);
1793- handler->SetSentErrorMessage(true);
1794- return false;
1795- }
1796-
1797- return true;
1798- }
1799+ account_commandscript() : CommandScript("account_commandscript") { }
1800+
1801+ ChatCommand* GetCommands() const override
1802+ {
1803+ static ChatCommand accountSetSecTable[] =
1804+ {
1805+ { "regmail", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_REGMAIL, true, &HandleAccountSetRegEmailCommand, "", NULL },
1806+ { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC_EMAIL, true, &HandleAccountSetEmailCommand, "", NULL },
1807+ { NULL, 0, false, NULL, "", NULL }
1808+ };
1809+ static ChatCommand accountSetCommandTable[] =
1810+ {
1811+ { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_ADDON, true, &HandleAccountSetAddonCommand, "", NULL },
1812+ { "sec", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_SEC, true, NULL, "", accountSetSecTable },
1813+ { "gmlevel", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleAccountSetGmLevelCommand, "", NULL },
1814+ { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_PASSWORD, true, &HandleAccountSetPasswordCommand, "", NULL },
1815+ { NULL, 0, false, NULL, "", NULL }
1816+ };
1817+ static ChatCommand accountLockCommandTable[] =
1818+ {
1819+ { "country", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_COUNTRY, true, &HandleAccountLockCountryCommand, "", NULL },
1820+ { "ip", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK_IP, true, &HandleAccountLockIpCommand, "", NULL },
1821+ { NULL, 0, false, NULL, "", NULL }
1822+ };
1823+ static ChatCommand accountCommandTable[] =
1824+ {
1825+ { "addon", rbac::RBAC_PERM_COMMAND_ACCOUNT_ADDON, false, &HandleAccountAddonCommand, "", NULL },
1826+ { "create", rbac::RBAC_PERM_COMMAND_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "", NULL },
1827+ { "delete", rbac::RBAC_PERM_COMMAND_ACCOUNT_DELETE, true, &HandleAccountDeleteCommand, "", NULL },
1828+ { "email", rbac::RBAC_PERM_COMMAND_ACCOUNT_EMAIL, false, &HandleAccountEmailCommand, "", NULL },
1829+ { "onlinelist", rbac::RBAC_PERM_COMMAND_ACCOUNT_ONLINE_LIST, true, &HandleAccountOnlineListCommand, "", NULL },
1830+ { "lock", rbac::RBAC_PERM_COMMAND_ACCOUNT_LOCK, false, NULL, "", accountLockCommandTable },
1831+ { "set", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET, true, NULL, "", accountSetCommandTable },
1832+ { "password", rbac::RBAC_PERM_COMMAND_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "", NULL },
1833+ { "", rbac::RBAC_PERM_COMMAND_ACCOUNT, false, &HandleAccountCommand, "", NULL },
1834+ { NULL, 0, false, NULL, "", NULL }
1835+ };
1836+ static ChatCommand guildhouseCommandTable[] =
1837+ {
1838+ { "tele", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleGuildhouseTeleCommand, "", NULL },
1839+ { "delete", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleGuildhouseDelCommand, "", NULL },
1840+ { "add", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, &HandleGuildhouseAddCommand, "", NULL },
1841+ { NULL, 0, false, NULL, "", NULL }
1842+ };
1843+ static ChatCommand commandTable[] =
1844+ {
1845+ { "account", rbac::RBAC_PERM_COMMAND_ACCOUNT, true, NULL, "", accountCommandTable },
1846+ { "guildhouse", rbac::RBAC_PERM_COMMAND_ACCOUNT_SET_GMLEVEL, true, NULL, "", guildhouseCommandTable },
1847+ { NULL, 0, false, NULL, "", NULL }
1848+ };
1849+ return commandTable;
1850+ }
1851+
1852+ static bool HandleGuildhouseTeleCommand(ChatHandler* handler, char const* args)
1853+ {
1854+ if (!*args) return false;
1855+
1856+ char* tailStr = handler->extractQuotedArg((char*)args);
1857+ if (!tailStr) return false;
1858+ const char* name = tailStr;
1859+ if (!name) return false;
1860+
1861+ Player* player = handler->GetSession()->GetPlayer();
1862+ if (!player) return false;
1863+
1864+ QueryResult result = CharacterDatabase.PQuery("SELECT guildid FROM guild WHERE name = '%s'", name);
1865+ if (result)
1866+ {
1867+ Field* fs = result->Fetch();
1868+ uint32 guildid = fs[0].GetUInt32();
1869+ QueryResult res = CharacterDatabase.PQuery("SELECT map, x, y, z FROM guildhouses WHERE guild = %u", guildid);
1870+ if (res)
1871+ {
1872+ Field* fields = res->Fetch();
1873+ uint32 map = fields[0].GetUInt32();
1874+ float x = fields[1].GetFloat();
1875+ float y = fields[2].GetFloat();
1876+ float z = fields[3].GetFloat();
1877+
1878+ player->TeleportTo(map, x, y, z, 0.0f, 0U);
1879+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВы были телепортированы в ГХ гильдии \"%s\"|r", name);
1880+ }
1881+ else ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eУ гильдии \"%s\" нет ГХ!|r", name);
1882+ }
1883+ else ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eГильдия \"%s\" не найдена!|r", name);
1884+ return true;
1885+ }
1886+
1887+ static bool HandleGuildhouseDelCommand(ChatHandler* handler, char const* args)
1888+ {
1889+ if (!*args) return false;
1890+
1891+ char* tailStr = handler->extractQuotedArg((char*)args);
1892+ if (!tailStr) return false;
1893+ const char* name = tailStr;
1894+ if (!name) return false;
1895+
1896+ Player* player = handler->GetSession()->GetPlayer();
1897+ if (!player) return false;
1898+ QueryResult res = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE name = '%s'", name);
1899+ if (res)
1900+ {
1901+ CharacterDatabase.PQuery("DELETE FROM guildhouses WHERE name = '%s'", name);
1902+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eМесто для Дома Гильдии под названием \"%s\" было удалено!|r", name);
1903+ }
1904+ else ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eМесто для Дома Гильдии под названием \"%s\" не найдено!|r", name);
1905+ return true;
1906+ }
1907+
1908+ static bool HandleGuildhouseAddCommand(ChatHandler* handler, char const* args)
1909+ {
1910+ if (!*args) return false;
1911+
1912+ char* tailStr = handler->extractQuotedArg((char*)args);
1913+ char* levelStr = *args != '\" ' ? strtok(NULL, "") : (char*)args;
1914+
1915+ if (!levelStr) return false;
1916+ if (!tailStr) return false;
1917+
1918+ const char* name = tailStr;
1919+ uint32 guildhouseCost = atoi(levelStr);
1920+
1921+ if (!name || !guildhouseCost) return false;
1922+
1923+ Player* player = handler->GetSession()->GetPlayer();
1924+ if (!player) return false;
1925+ QueryResult numbers = CharacterDatabase.PQuery("SELECT MAX(number), MAX(number2) FROM guildhouses");
1926+ if (numbers)
1927+ {
1928+ Field* fields = numbers->Fetch();
1929+ uint32 number = fields[0].GetUInt32();
1930+ uint32 number2 = fields[1].GetUInt32();
1931+
1932+ CharacterDatabase.PQuery("INSERT INTO guildhouses VALUES (0, '%s', %f, %f, %f, 40, %u, %u, %u, %u, 0)", name, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), guildhouseCost, number + 1, number2 + 1, player->GetMapId());
1933+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eДанное место добавлено в список мест для Домов Гильдий под названием \"%s\" за %u опыта гильдии|r", name, guildhouseCost);
1934+ }
1935+ else
1936+ {
1937+ CharacterDatabase.PQuery("INSERT INTO guildhouses VALUES (0, '%s', %f, %f, %f, 40, %u, 1000, 10000, %u, 0)", name, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), guildhouseCost, player->GetMapId());
1938+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eДанное место добавлено в список мест для Домов Гильдий под названием \"%s\" за %u опыта гильдии|r", name, guildhouseCost);
1939+ }
1940+ return true;
1941+ }
1942+
1943+
1944+ static bool HandleAccountAddonCommand(ChatHandler* handler, char const* args)
1945+ {
1946+ if (!*args)
1947+ {
1948+ handler->SendSysMessage(LANG_CMD_SYNTAX);
1949+ handler->SetSentErrorMessage(true);
1950+ return false;
1951+ }
1952+
1953+ char* exp = strtok((char*)args, " ");
1954+
1955+ uint32 accountId = handler->GetSession()->GetAccountId();
1956+
1957+ int expansion = atoi(exp); //get int anyway (0 if error)
1958+ if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
1959+ {
1960+ handler->SendSysMessage(LANG_IMPROPER_VALUE);
1961+ handler->SetSentErrorMessage(true);
1962+ return false;
1963+ }
1964+
1965+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION);
1966+
1967+ stmt->setUInt8(0, uint8(expansion));
1968+ stmt->setUInt32(1, accountId);
1969+
1970+ LoginDatabase.Execute(stmt);
1971+
1972+ handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
1973+ return true;
1974+ }
1975+
1976+ /// Create an account
1977+ static bool HandleAccountCreateCommand(ChatHandler* handler, char const* args)
1978+ {
1979+ if (!*args)
1980+ return false;
1981+
1982+ std::string email;
1983+
1984+ ///- %Parse the command line arguments
1985+ char* accountName = strtok((char*)args, " ");
1986+ char* password = strtok(NULL, " ");
1987+ char* possibleEmail = strtok(NULL, " ' ");
1988+ if (possibleEmail)
1989+ email = possibleEmail;
1990+
1991+ if (!accountName || !password)
1992+ return false;
1993+
1994+ AccountOpResult result = sAccountMgr->CreateAccount(std::string(accountName), std::string(password), email);
1995+ switch (result)
1996+ {
1997+ case AOR_OK:
1998+ handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
1999+ if (handler->GetSession())
2000+ {
2001+ TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Character:[%s] (GUID: %u) created Account %s (Email: '%s')",
2002+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2003+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
2004+ accountName, email.c_str());
2005+ }
2006+ break;
2007+ case AOR_NAME_TOO_LONG:
2008+ handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG);
2009+ handler->SetSentErrorMessage(true);
2010+ return false;
2011+ case AOR_NAME_ALREADY_EXIST:
2012+ handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST);
2013+ handler->SetSentErrorMessage(true);
2014+ return false;
2015+ case AOR_DB_INTERNAL_ERROR:
2016+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName);
2017+ handler->SetSentErrorMessage(true);
2018+ return false;
2019+ default:
2020+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName);
2021+ handler->SetSentErrorMessage(true);
2022+ return false;
2023+ }
2024+
2025+ return true;
2026+ }
2027+
2028+ /// Delete a user account and all associated characters in this realm
2029+ /// @todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm then delete account)
2030+ static bool HandleAccountDeleteCommand(ChatHandler* handler, char const* args)
2031+ {
2032+ if (!*args)
2033+ return false;
2034+
2035+ ///- Get the account name from the command line
2036+ char* account = strtok((char*)args, " ");
2037+ if (!account)
2038+ return false;
2039+
2040+ std::string accountName = account;
2041+ if (!AccountMgr::normalizeString(accountName))
2042+ {
2043+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2044+ handler->SetSentErrorMessage(true);
2045+ return false;
2046+ }
2047+
2048+ uint32 accountId = AccountMgr::GetId(accountName);
2049+ if (!accountId)
2050+ {
2051+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2052+ handler->SetSentErrorMessage(true);
2053+ return false;
2054+ }
2055+
2056+ /// Commands not recommended call from chat, but support anyway
2057+ /// can delete only for account with less security
2058+ /// This is also reject self apply in fact
2059+ if (handler->HasLowerSecurityAccount(NULL, accountId, true))
2060+ return false;
2061+
2062+ AccountOpResult result = AccountMgr::DeleteAccount(accountId);
2063+ switch (result)
2064+ {
2065+ case AOR_OK:
2066+ handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName.c_str());
2067+ break;
2068+ case AOR_NAME_NOT_EXIST:
2069+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2070+ handler->SetSentErrorMessage(true);
2071+ return false;
2072+ case AOR_DB_INTERNAL_ERROR:
2073+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName.c_str());
2074+ handler->SetSentErrorMessage(true);
2075+ return false;
2076+ default:
2077+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName.c_str());
2078+ handler->SetSentErrorMessage(true);
2079+ return false;
2080+ }
2081+
2082+ return true;
2083+ }
2084+
2085+ /// Display info on users currently in the realm
2086+ static bool HandleAccountOnlineListCommand(ChatHandler* handler, char const* /*args*/)
2087+ {
2088+ ///- Get the list of accounts ID logged to the realm
2089+ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_ONLINE);
2090+
2091+ PreparedQueryResult result = CharacterDatabase.Query(stmt);
2092+
2093+ if (!result)
2094+ {
2095+ handler->SendSysMessage(LANG_ACCOUNT_LIST_EMPTY);
2096+ return true;
2097+ }
2098+
2099+ ///- Display the list of account/characters online
2100+ handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR_HEADER);
2101+ handler->SendSysMessage(LANG_ACCOUNT_LIST_HEADER);
2102+ handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
2103+
2104+ ///- Cycle through accounts
2105+ do
2106+ {
2107+ Field* fieldsDB = result->Fetch();
2108+ std::string name = fieldsDB[0].GetString();
2109+ uint32 account = fieldsDB[1].GetUInt32();
2110+
2111+ ///- Get the username, last IP and GM level of each account
2112+ // No SQL injection. account is uint32.
2113+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO);
2114+ stmt->setUInt32(0, account);
2115+ PreparedQueryResult resultLogin = LoginDatabase.Query(stmt);
2116+
2117+ if (resultLogin)
2118+ {
2119+ Field* fieldsLogin = resultLogin->Fetch();
2120+ handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE,
2121+ fieldsLogin[0].GetCString(), name.c_str(), fieldsLogin[1].GetCString(),
2122+ fieldsDB[2].GetUInt16(), fieldsDB[3].GetUInt16(), fieldsLogin[3].GetUInt8(),
2123+ fieldsLogin[2].GetUInt8());
2124+ }
2125+ else
2126+ handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
2127+ } while (result->NextRow());
2128+
2129+ handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
2130+ return true;
2131+ }
2132+
2133+ static bool HandleAccountLockCountryCommand(ChatHandler* handler, char const* args)
2134+ {
2135+ if (!*args)
2136+ {
2137+ handler->SendSysMessage(LANG_USE_BOL);
2138+ handler->SetSentErrorMessage(true);
2139+ return false;
2140+ }
2141+ std::string param = (char*)args;
2142+
2143+ if (!param.empty())
2144+ {
2145+ if (param == "on")
2146+ {
2147+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGON_COUNTRY);
2148+ uint32 ip = inet_addr(handler->GetSession()->GetRemoteAddress().c_str());
2149+ EndianConvertReverse(ip);
2150+ stmt->setUInt32(0, ip);
2151+ PreparedQueryResult result = LoginDatabase.Query(stmt);
2152+ if (result)
2153+ {
2154+ Field* fields = result->Fetch();
2155+ std::string country = fields[0].GetString();
2156+ stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
2157+ stmt->setString(0, country);
2158+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
2159+ LoginDatabase.Execute(stmt);
2160+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
2161+ }
2162+ else
2163+ {
2164+ handler->PSendSysMessage("[IP2NATION] Table empty");
2165+ TC_LOG_DEBUG("server.authserver", "[IP2NATION] Table empty");
2166+ }
2167+ }
2168+ else if (param == "off")
2169+ {
2170+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_CONTRY);
2171+ stmt->setString(0, "00");
2172+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
2173+ LoginDatabase.Execute(stmt);
2174+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
2175+ }
2176+ return true;
2177+ }
2178+ handler->SendSysMessage(LANG_USE_BOL);
2179+ handler->SetSentErrorMessage(true);
2180+ return false;
2181+ }
2182+
2183+ static bool HandleAccountLockIpCommand(ChatHandler* handler, char const* args)
2184+ {
2185+ if (!*args)
2186+ {
2187+ handler->SendSysMessage(LANG_USE_BOL);
2188+ handler->SetSentErrorMessage(true);
2189+ return false;
2190+ }
2191+
2192+ std::string param = (char*)args;
2193+
2194+ if (!param.empty())
2195+ {
2196+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK);
2197+
2198+ if (param == "on")
2199+ {
2200+ stmt->setBool(0, true); // locked
2201+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
2202+ }
2203+ else if (param == "off")
2204+ {
2205+ stmt->setBool(0, false); // unlocked
2206+ handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
2207+ }
2208+
2209+ stmt->setUInt32(1, handler->GetSession()->GetAccountId());
2210+
2211+ LoginDatabase.Execute(stmt);
2212+ return true;
2213+ }
2214+
2215+ handler->SendSysMessage(LANG_USE_BOL);
2216+ handler->SetSentErrorMessage(true);
2217+ return false;
2218+ }
2219+
2220+ static bool HandleAccountEmailCommand(ChatHandler* handler, char const* args)
2221+ {
2222+ if (!*args)
2223+ {
2224+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2225+ handler->SetSentErrorMessage(true);
2226+ return false;
2227+ }
2228+
2229+ char* oldEmail = strtok((char*)args, " ");
2230+ char* password = strtok(NULL, " ");
2231+ char* email = strtok(NULL, " ");
2232+ char* emailConfirmation = strtok(NULL, " ");
2233+
2234+ if (!oldEmail || !password || !email || !emailConfirmation)
2235+ {
2236+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2237+ handler->SetSentErrorMessage(true);
2238+ return false;
2239+ }
2240+
2241+ if (!AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), std::string(oldEmail)))
2242+ {
2243+ handler->SendSysMessage(LANG_COMMAND_WRONGEMAIL);
2244+ sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
2245+ handler->SetSentErrorMessage(true);
2246+ TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided email [%s] is not equal to registration email [%s].",
2247+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2248+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
2249+ email, oldEmail);
2250+ return false;
2251+ }
2252+
2253+ if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(password)))
2254+ {
2255+ handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
2256+ sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
2257+ handler->SetSentErrorMessage(true);
2258+ TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.",
2259+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2260+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
2261+ return false;
2262+ }
2263+
2264+ if (strcmp(email, oldEmail) == 0)
2265+ {
2266+ handler->SendSysMessage(LANG_OLD_EMAIL_IS_NEW_EMAIL);
2267+ sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
2268+ handler->SetSentErrorMessage(true);
2269+ return false;
2270+ }
2271+
2272+ if (strcmp(email, emailConfirmation) != 0)
2273+ {
2274+ handler->SendSysMessage(LANG_NEW_EMAILS_NOT_MATCH);
2275+ sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
2276+ handler->SetSentErrorMessage(true);
2277+ TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change email, but the provided password is wrong.",
2278+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2279+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
2280+ return false;
2281+ }
2282+
2283+
2284+ AccountOpResult result = AccountMgr::ChangeEmail(handler->GetSession()->GetAccountId(), std::string(email));
2285+ switch (result)
2286+ {
2287+ case AOR_OK:
2288+ handler->SendSysMessage(LANG_COMMAND_EMAIL);
2289+ sScriptMgr->OnEmailChange(handler->GetSession()->GetAccountId());
2290+ TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Email from [%s] to [%s].",
2291+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2292+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
2293+ oldEmail, email);
2294+ break;
2295+ case AOR_EMAIL_TOO_LONG:
2296+ handler->SendSysMessage(LANG_EMAIL_TOO_LONG);
2297+ sScriptMgr->OnFailedEmailChange(handler->GetSession()->GetAccountId());
2298+ handler->SetSentErrorMessage(true);
2299+ return false;
2300+ default:
2301+ handler->SendSysMessage(LANG_COMMAND_NOTCHANGEEMAIL);
2302+ handler->SetSentErrorMessage(true);
2303+ return false;
2304+ }
2305+
2306+ return true;
2307+ }
2308+
2309+ static bool HandleAccountPasswordCommand(ChatHandler* handler, char const* args)
2310+ {
2311+ // If no args are given at all, we can return false right away.
2312+ if (!*args)
2313+ {
2314+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2315+ handler->SetSentErrorMessage(true);
2316+ return false;
2317+ }
2318+
2319+ // First, we check config. What security type (sec type) is it ? Depending on it, the command branches out
2320+ uint32 pwConfig = sWorld->getIntConfig(CONFIG_ACC_PASSCHANGESEC); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC
2321+
2322+ // Command is supposed to be: .account password [$oldpassword] [$newpassword] [$newpasswordconfirmation] [$emailconfirmation]
2323+ char* oldPassword = strtok((char*)args, " "); // This extracts [$oldpassword]
2324+ char* newPassword = strtok(NULL, " "); // This extracts [$newpassword]
2325+ char* passwordConfirmation = strtok(NULL, " "); // This extracts [$newpasswordconfirmation]
2326+ char const* emailConfirmation = strtok(NULL, " "); // This defines the emailConfirmation variable, which is optional depending on sec type.
2327+ if (!emailConfirmation) // This extracts [$emailconfirmation]. If it doesn't exist, however...
2328+ emailConfirmation = ""; // ... it's simply "" for emailConfirmation.
2329+
2330+ //Is any of those variables missing for any reason ? We return false.
2331+ if (!oldPassword || !newPassword || !passwordConfirmation)
2332+ {
2333+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2334+ handler->SetSentErrorMessage(true);
2335+ return false;
2336+ }
2337+
2338+ // We compare the old, saved password to the entered old password - no chance for the unauthorized.
2339+ if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(oldPassword)))
2340+ {
2341+ handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
2342+ sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
2343+ handler->SetSentErrorMessage(true);
2344+ TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the provided old password is wrong.",
2345+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2346+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
2347+ return false;
2348+ }
2349+
2350+ // This compares the old, current email to the entered email - however, only...
2351+ if ((pwConfig == PW_EMAIL || (pwConfig == PW_RBAC && handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE))) // ...if either PW_EMAIL or PW_RBAC with the Permission is active...
2352+ && !AccountMgr::CheckEmail(handler->GetSession()->GetAccountId(), std::string(emailConfirmation))) // ... and returns false if the comparison fails.
2353+ {
2354+ handler->SendSysMessage(LANG_COMMAND_WRONGEMAIL);
2355+ sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
2356+ handler->SetSentErrorMessage(true);
2357+ TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Tried to change password, but the entered email [%s] is wrong.",
2358+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2359+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow(),
2360+ emailConfirmation);
2361+ return false;
2362+ }
2363+
2364+ // Making sure that newly entered password is correctly entered.
2365+ if (strcmp(newPassword, passwordConfirmation) != 0)
2366+ {
2367+ handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
2368+ sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
2369+ handler->SetSentErrorMessage(true);
2370+ return false;
2371+ }
2372+
2373+ // Changes password and prints result.
2374+ AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(newPassword));
2375+ switch (result)
2376+ {
2377+ case AOR_OK:
2378+ handler->SendSysMessage(LANG_COMMAND_PASSWORD);
2379+ sScriptMgr->OnPasswordChange(handler->GetSession()->GetAccountId());
2380+ TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (GUID: %u) Changed Password.",
2381+ handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
2382+ handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUIDLow());
2383+ break;
2384+ case AOR_PASS_TOO_LONG:
2385+ handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
2386+ sScriptMgr->OnFailedPasswordChange(handler->GetSession()->GetAccountId());
2387+ handler->SetSentErrorMessage(true);
2388+ return false;
2389+ default:
2390+ handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
2391+ handler->SetSentErrorMessage(true);
2392+ return false;
2393+ }
2394+
2395+ return true;
2396+ }
2397+
2398+ static bool HandleAccountCommand(ChatHandler* handler, char const* /*args*/)
2399+ {
2400+ // GM Level
2401+ AccountTypes gmLevel = handler->GetSession()->GetSecurity();
2402+ handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmLevel));
2403+
2404+ // Security level required
2405+ bool hasRBAC = (handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE) ? true : false);
2406+ uint32 pwConfig = sWorld->getIntConfig(CONFIG_ACC_PASSCHANGESEC); // 0 - PW_NONE, 1 - PW_EMAIL, 2 - PW_RBAC
2407+
2408+ handler->PSendSysMessage(LANG_ACCOUNT_SEC_TYPE, (pwConfig == PW_NONE ? "Lowest level: No Email input required." :
2409+ pwConfig == PW_EMAIL ? "Highest level: Email input required." :
2410+ pwConfig == PW_RBAC ? "Special level: Your account may require email input depending on settings. That is the case if another lien is printed." :
2411+ "Unknown security level: Notify technician for details."));
2412+
2413+ // RBAC required display - is not displayed for console
2414+ if (pwConfig == PW_RBAC && handler->GetSession() && hasRBAC)
2415+ handler->PSendSysMessage(LANG_RBAC_EMAIL_REQUIRED);
2416+
2417+ // Email display if sufficient rights
2418+ if (handler->HasPermission(rbac::RBAC_PERM_MAY_CHECK_OWN_EMAIL))
2419+ {
2420+ std::string emailoutput;
2421+ uint32 accountId = handler->GetSession()->GetAccountId();
2422+
2423+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_EMAIL_BY_ID);
2424+ stmt->setUInt32(0, accountId);
2425+ PreparedQueryResult result = LoginDatabase.Query(stmt);
2426+
2427+ if (result)
2428+ {
2429+ emailoutput = (*result)[0].GetString();
2430+ handler->PSendSysMessage(LANG_COMMAND_EMAIL_OUTPUT, emailoutput.c_str());
2431+ }
2432+ }
2433+
2434+ return true;
2435+ }
2436+
2437+ /// Set/Unset the expansion level for an account
2438+ static bool HandleAccountSetAddonCommand(ChatHandler* handler, char const* args)
2439+ {
2440+ ///- Get the command line arguments
2441+ char* account = strtok((char*)args, " ");
2442+ char* exp = strtok(NULL, " ");
2443+
2444+ if (!account)
2445+ return false;
2446+
2447+ std::string accountName;
2448+ uint32 accountId;
2449+
2450+ if (!exp)
2451+ {
2452+ Player* player = handler->getSelectedPlayer();
2453+ if (!player)
2454+ return false;
2455+
2456+ accountId = player->GetSession()->GetAccountId();
2457+ AccountMgr::GetName(accountId, accountName);
2458+ exp = account;
2459+ }
2460+ else
2461+ {
2462+ ///- Convert Account name to Upper Format
2463+ accountName = account;
2464+ if (!AccountMgr::normalizeString(accountName))
2465+ {
2466+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2467+ handler->SetSentErrorMessage(true);
2468+ return false;
2469+ }
2470+
2471+ accountId = AccountMgr::GetId(accountName);
2472+ if (!accountId)
2473+ {
2474+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2475+ handler->SetSentErrorMessage(true);
2476+ return false;
2477+ }
2478+ }
2479+
2480+ // Let set addon state only for lesser (strong) security level
2481+ // or to self account
2482+ if (handler->GetSession() && handler->GetSession()->GetAccountId() != accountId &&
2483+ handler->HasLowerSecurityAccount(NULL, accountId, true))
2484+ return false;
2485+
2486+ int expansion = atoi(exp); //get int anyway (0 if error)
2487+ if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
2488+ return false;
2489+
2490+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION);
2491+
2492+ stmt->setUInt8(0, expansion);
2493+ stmt->setUInt32(1, accountId);
2494+
2495+ LoginDatabase.Execute(stmt);
2496+
2497+ handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion);
2498+ return true;
2499+ }
2500+
2501+ static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, char const* args)
2502+ {
2503+ if (!*args)
2504+ {
2505+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2506+ handler->SetSentErrorMessage(true);
2507+ return false;
2508+ }
2509+
2510+ std::string targetAccountName;
2511+ uint32 targetAccountId = 0;
2512+ uint32 targetSecurity = 0;
2513+ uint32 gm = 0;
2514+ char* arg1 = strtok((char*)args, " ");
2515+ char* arg2 = strtok(NULL, " ");
2516+ char* arg3 = strtok(NULL, " ");
2517+ bool isAccountNameGiven = true;
2518+
2519+ if (!arg3)
2520+ {
2521+ if (!handler->getSelectedPlayer())
2522+ return false;
2523+ isAccountNameGiven = false;
2524+ }
2525+
2526+ // Check for second parameter
2527+ if (!isAccountNameGiven && !arg2)
2528+ return false;
2529+
2530+ // Check for account
2531+ if (isAccountNameGiven)
2532+ {
2533+ targetAccountName = arg1;
2534+ if (!AccountMgr::normalizeString(targetAccountName))
2535+ {
2536+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, targetAccountName.c_str());
2537+ handler->SetSentErrorMessage(true);
2538+ return false;
2539+ }
2540+ }
2541+
2542+ // Check for invalid specified GM level.
2543+ gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
2544+ if (gm > SEC_CONSOLE)
2545+ {
2546+ handler->SendSysMessage(LANG_BAD_VALUE);
2547+ handler->SetSentErrorMessage(true);
2548+ return false;
2549+ }
2550+
2551+ // handler->getSession() == NULL only for console
2552+ targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
2553+ int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
2554+ uint32 playerSecurity;
2555+ if (handler->GetSession())
2556+ playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
2557+ else
2558+ playerSecurity = SEC_CONSOLE;
2559+
2560+ // can set security level only for target with less security and to less security that we have
2561+ // This also restricts setting handler's own security.
2562+ targetSecurity = AccountMgr::GetSecurity(targetAccountId, gmRealmID);
2563+ if (targetSecurity >= playerSecurity || gm >= playerSecurity)
2564+ {
2565+ handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
2566+ handler->SetSentErrorMessage(true);
2567+ return false;
2568+ }
2569+
2570+ // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
2571+ if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
2572+ {
2573+ PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST);
2574+
2575+ stmt->setUInt32(0, targetAccountId);
2576+ stmt->setUInt8(1, uint8(gm));
2577+
2578+ PreparedQueryResult result = LoginDatabase.Query(stmt);
2579+
2580+ if (result)
2581+ {
2582+ handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
2583+ handler->SetSentErrorMessage(true);
2584+ return false;
2585+ }
2586+ }
2587+
2588+ // Check if provided realmID has a negative value other than -1
2589+ if (gmRealmID < -1)
2590+ {
2591+ handler->SendSysMessage(LANG_INVALID_REALMID);
2592+ handler->SetSentErrorMessage(true);
2593+ return false;
2594+ }
2595+
2596+ rbac::RBACData* rbac = isAccountNameGiven ? NULL : handler->getSelectedPlayer()->GetSession()->GetRBACData();
2597+ sAccountMgr->UpdateAccountAccess(rbac, targetAccountId, uint8(gm), gmRealmID);
2598+
2599+ handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
2600+ return true;
2601+ }
2602+
2603+ /// Set password for account
2604+ static bool HandleAccountSetPasswordCommand(ChatHandler* handler, char const* args)
2605+ {
2606+ if (!*args)
2607+ {
2608+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2609+ handler->SetSentErrorMessage(true);
2610+ return false;
2611+ }
2612+
2613+ ///- Get the command line arguments
2614+ char* account = strtok((char*)args, " ");
2615+ char* password = strtok(NULL, " ");
2616+ char* passwordConfirmation = strtok(NULL, " ");
2617+
2618+ if (!account || !password || !passwordConfirmation)
2619+ return false;
2620+
2621+ std::string accountName = account;
2622+ if (!AccountMgr::normalizeString(accountName))
2623+ {
2624+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2625+ handler->SetSentErrorMessage(true);
2626+ return false;
2627+ }
2628+
2629+ uint32 targetAccountId = AccountMgr::GetId(accountName);
2630+ if (!targetAccountId)
2631+ {
2632+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2633+ handler->SetSentErrorMessage(true);
2634+ return false;
2635+ }
2636+
2637+ /// can set password only for target with less security
2638+ /// This also restricts setting handler's own password
2639+ if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
2640+ return false;
2641+
2642+ if (strcmp(password, passwordConfirmation))
2643+ {
2644+ handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
2645+ handler->SetSentErrorMessage(true);
2646+ return false;
2647+ }
2648+
2649+ AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, password);
2650+
2651+ switch (result)
2652+ {
2653+ case AOR_OK:
2654+ handler->SendSysMessage(LANG_COMMAND_PASSWORD);
2655+ break;
2656+ case AOR_NAME_NOT_EXIST:
2657+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2658+ handler->SetSentErrorMessage(true);
2659+ return false;
2660+ case AOR_PASS_TOO_LONG:
2661+ handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
2662+ handler->SetSentErrorMessage(true);
2663+ return false;
2664+ default:
2665+ handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
2666+ handler->SetSentErrorMessage(true);
2667+ return false;
2668+ }
2669+ return true;
2670+ }
2671+
2672+ /// Set normal email for account
2673+ static bool HandleAccountSetEmailCommand(ChatHandler* handler, char const* args)
2674+ {
2675+ if (!*args)
2676+ return false;
2677+
2678+ ///- Get the command line arguments
2679+ char* account = strtok((char*)args, " ");
2680+ char* email = strtok(NULL, " ");
2681+ char* emailConfirmation = strtok(NULL, " ");
2682+
2683+ if (!account || !email || !emailConfirmation)
2684+ {
2685+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2686+ handler->SetSentErrorMessage(true);
2687+ return false;
2688+ }
2689+
2690+ std::string accountName = account;
2691+ if (!AccountMgr::normalizeString(accountName))
2692+ {
2693+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2694+ handler->SetSentErrorMessage(true);
2695+ return false;
2696+ }
2697+
2698+ uint32 targetAccountId = AccountMgr::GetId(accountName);
2699+ if (!targetAccountId)
2700+ {
2701+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2702+ handler->SetSentErrorMessage(true);
2703+ return false;
2704+ }
2705+
2706+ /// can set email only for target with less security
2707+ /// This also restricts setting handler's own email.
2708+ if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
2709+ return false;
2710+
2711+ if (strcmp(email, emailConfirmation) != 0)
2712+ {
2713+ handler->SendSysMessage(LANG_NEW_EMAILS_NOT_MATCH);
2714+ handler->SetSentErrorMessage(true);
2715+ return false;
2716+ }
2717+
2718+ AccountOpResult result = AccountMgr::ChangeEmail(targetAccountId, email);
2719+ switch (result)
2720+ {
2721+ case AOR_OK:
2722+ handler->SendSysMessage(LANG_COMMAND_EMAIL);
2723+ TC_LOG_INFO("entities.player.character", "ChangeEmail: Account %s [Id: %u] had it's email changed to %s.",
2724+ accountName.c_str(), targetAccountId, email);
2725+ break;
2726+ case AOR_NAME_NOT_EXIST:
2727+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2728+ handler->SetSentErrorMessage(true);
2729+ return false;
2730+ case AOR_EMAIL_TOO_LONG:
2731+ handler->SendSysMessage(LANG_EMAIL_TOO_LONG);
2732+ handler->SetSentErrorMessage(true);
2733+ return false;
2734+ default:
2735+ handler->SendSysMessage(LANG_COMMAND_NOTCHANGEEMAIL);
2736+ handler->SetSentErrorMessage(true);
2737+ return false;
2738+ }
2739+
2740+ return true;
2741+ }
2742+
2743+ /// Change registration email for account
2744+ static bool HandleAccountSetRegEmailCommand(ChatHandler* handler, char const* args)
2745+ {
2746+ if (!*args)
2747+ return false;
2748+
2749+ //- We do not want anything short of console to use this by default.
2750+ //- So we force that.
2751+ if (handler->GetSession())
2752+ return false;
2753+
2754+ ///- Get the command line arguments
2755+ char* account = strtok((char*)args, " ");
2756+ char* email = strtok(NULL, " ");
2757+ char* emailConfirmation = strtok(NULL, " ");
2758+
2759+ if (!account || !email || !emailConfirmation)
2760+ {
2761+ handler->SendSysMessage(LANG_CMD_SYNTAX);
2762+ handler->SetSentErrorMessage(true);
2763+ return false;
2764+ }
2765+
2766+ std::string accountName = account;
2767+ if (!AccountMgr::normalizeString(accountName))
2768+ {
2769+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2770+ handler->SetSentErrorMessage(true);
2771+ return false;
2772+ }
2773+
2774+ uint32 targetAccountId = AccountMgr::GetId(accountName);
2775+ if (!targetAccountId)
2776+ {
2777+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2778+ handler->SetSentErrorMessage(true);
2779+ return false;
2780+ }
2781+
2782+ /// can set email only for target with less security
2783+ /// This also restricts setting handler's own email.
2784+ if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
2785+ return false;
2786+
2787+ if (strcmp(email, emailConfirmation) != 0)
2788+ {
2789+ handler->SendSysMessage(LANG_NEW_EMAILS_NOT_MATCH);
2790+ handler->SetSentErrorMessage(true);
2791+ return false;
2792+ }
2793+
2794+ AccountOpResult result = AccountMgr::ChangeRegEmail(targetAccountId, email);
2795+ switch (result)
2796+ {
2797+ case AOR_OK:
2798+ handler->SendSysMessage(LANG_COMMAND_EMAIL);
2799+ TC_LOG_INFO("entities.player.character", "ChangeRegEmail: Account %s [Id: %u] had it's Registration Email changed to %s.",
2800+ accountName.c_str(), targetAccountId, email);
2801+ break;
2802+ case AOR_NAME_NOT_EXIST:
2803+ handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
2804+ handler->SetSentErrorMessage(true);
2805+ return false;
2806+ case AOR_EMAIL_TOO_LONG:
2807+ handler->SendSysMessage(LANG_EMAIL_TOO_LONG);
2808+ handler->SetSentErrorMessage(true);
2809+ return false;
2810+ default:
2811+ handler->SendSysMessage(LANG_COMMAND_NOTCHANGEEMAIL);
2812+ handler->SetSentErrorMessage(true);
2813+ return false;
2814+ }
2815+
2816+ return true;
2817+ }
2818+};
2819+
2820+
2821+class item_tpguild : public ItemScript
2822+{
2823+public:
2824+ item_tpguild() : ItemScript("item_tpguild") { }
2825+
2826+ bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/)
2827+ {
2828+ uint32 guild = player->GetGuildId();
2829+ QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map FROM guildhouses WHERE guild = %u", guild);
2830+ if (result && !player->IsInCombat())
2831+ {
2832+ float x, y, z;
2833+ uint32 map;
2834+ std::string name;
2835+
2836+ Field* fields = result->Fetch();
2837+ x = fields[0].GetFloat();
2838+ y = fields[1].GetFloat();
2839+ z = fields[2].GetFloat();
2840+ map = fields[3].GetUInt32();
2841+
2842+ player->TeleportTo(map, x, y, z, 0.0f, 0U);
2843+ player->RemoveSpellCooldown(8690, true);
2844+ player->SetPhaseMask(1, true);
2845+ }
2846+
2847+ return true;
2848+ }
2849+
2850+};
2851+
2852+class npc_guild_level : public CreatureScript
2853+
2854+{
2855+
2856+public:
2857+
2858+ npc_guild_level() : CreatureScript("npc_guild_level") {}
2859+
2860+ bool OnGossipHello(Player* player, Creature* creature) {
2861+ player->PlayerTalkClass->ClearMenus();
2862+ uint32 guild = player->GetGuildId();
2863+ uint16 level;
2864+ if (!guild) {
2865+ player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
2866+ return false;
2867+ }
2868+ QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
2869+ if (result) {
2870+ Field *fields = result->Fetch();
2871+ level = fields[0].GetUInt16();
2872+ if (level < 30) {
2873+ std::ostringstream temb;
2874+ temb << "|TInterface/ICONS/INV_Inscription_ArmorScroll02:32:32:-18:0|tП";
2875+ std::ostringstream femb;
2876+ femb << "|TInterface/ICONS/INV_Sword_131:32:32:-18:0|tПожертвовать 1 эмблему (10 опыта гильдии)";
2877+ std::ostringstream hnr;
2878+ hnr << "|TInterface/ICONS/Achievement_BG_kill_flag_carrierEOS:32:32:-18:0|tПожертвовать очки чести для гильдии";
2879+ std::ostringstream arn;
2880+ arn << "|TInterface/ICONS/Achievement_Arena_2v2_1:32:32:-18:0|tПожертвовать очки арены для гильдии";
2881+ std::ostringstream gld;
2882+ gld << "|TInterface/ICONS/Achievement_Reputation_02:32:32:-18:0|tПожертвовать золото для гильдии";
2883+ //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, temb.str(), GOSSIP_SENDER_MAIN, 35);
2884+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, femb.str(), GOSSIP_SENDER_MAIN, 36);
2885+ player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_MONEY_BAG, gld.str(), GOSSIP_SENDER_MAIN, 200, "Введите сумму, которую хотите пожертвовать, 5 000 золота = 10 опыта гильдии", 0, true);
2886+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, hnr.str(), GOSSIP_SENDER_MAIN, 1);
2887+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, arn.str(), GOSSIP_SENDER_MAIN, 2);
2888+ }
2889+ }
2890+
2891+ if (player->GetRank() == 0)
2892+ {
2893+
2894+ }
2895+ std::ostringstream prg;
2896+ prg << "|TInterface/ICONS/Spell_Magic_ManaGain:32:32:-18:0|tПрогресс моей гильдии";
2897+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, prg.str(), GOSSIP_SENDER_MAIN, 3);
2898+ std::ostringstream gsr;
2899+ gsr << "|TInterface/ICONS/Spell_Shadow_Fumble:32:32:-18:0|tТОП гильдий с уровнями";
2900+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, gsr.str(), GOSSIP_SENDER_MAIN, 13);
2901+ std::ostringstream vlg;
2902+ vlg << "|TInterface/ICONS/Temp:32:32:-18:0|tСписок вложивших в гильдию";
2903+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, vlg.str(), GOSSIP_SENDER_MAIN, 9914);
2904+
2905+ std::ostringstream vxd;
2906+ vxd << "|TInterface/ICONS/Spell_ChargeNegative:32:32:-18:0|tВыход";
2907+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
2908+ player->SEND_GOSSIP_MENU(55000, creature->GetGUID());
2909+
2910+ return true;
2911+ }
2912+
2913+ void InvestedRoster(Player* player, Creature* creature) {
2914+ player->PlayerTalkClass->ClearMenus();
2915+ //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию свитков", GOSSIP_SENDER_MAIN, 9917);
2916+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию эмблем", GOSSIP_SENDER_MAIN, 9918);
2917+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию очков чести", GOSSIP_SENDER_MAIN, 9915);
2918+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию очков арены", GOSSIP_SENDER_MAIN, 9916);
2919+ //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "ТОП вложивших в гильдию золота", GOSSIP_SENDER_MAIN, 9000);
2920+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
2921+ }
2922+
2923+ void InvestedRosterGold1(Player* player, Creature* creature) {
2924+ player->PlayerTalkClass->ClearMenus();
2925+ uint32 guild = player->GetGuildId();
2926+ QueryResult result = CharacterDatabase.PQuery("SELECT name, gold, number FROM guild_level_invested WHERE gold > 0 AND guild = %u ORDER BY honor DESC", guild);
2927+ if (result) {
2928+ std::string name;
2929+ uint32 gold;
2930+ uint64 number;
2931+ uint16 go = 0;
2932+ do {
2933+ Field* fields = result->Fetch();
2934+ name = fields[0].GetString();
2935+ gold = fields[1].GetUInt32();
2936+ number = fields[2].GetUInt64();
2937+
2938+ if (go == 30) break;
2939+ std::stringstream buffer;
2940+ buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << gold << " золота" << "|r";
2941+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
2942+
2943+ go++;
2944+
2945+ } while (result->NextRow());
2946+
2947+
2948+ }
2949+
2950+
2951+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
2952+ }
2953+
2954+ void InvestedSvitok(Player* player, Creature* creature) {
2955+ player->PlayerTalkClass->ClearMenus();
2956+ uint32 guild = player->GetGuildId();
2957+ QueryResult result = CharacterDatabase.PQuery("SELECT name, svitok, number FROM guild_level_invested WHERE svitok > 0 AND guild = %u ORDER BY svitok DESC", guild);
2958+ if (result) {
2959+ std::string name;
2960+ uint32 svitok;
2961+ uint64 number;
2962+ uint16 go = 0;
2963+ do {
2964+ Field* fields = result->Fetch();
2965+ name = fields[0].GetString();
2966+ svitok = fields[1].GetUInt32();
2967+ number = fields[2].GetUInt64();
2968+
2969+ if (go == 50) {
2970+ break;
2971+ }
2972+ std::stringstream buffer;
2973+ buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << svitok << " свитков" << "|r";
2974+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
2975+
2976+ go++;
2977+
2978+ } while (result->NextRow());
2979+
2980+
2981+ }
2982+
2983+
2984+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
2985+ }
2986+
2987+ void InvestedToken(Player* player, Creature* creature) {
2988+ player->PlayerTalkClass->ClearMenus();
2989+ uint32 guild = player->GetGuildId();
2990+ QueryResult result = CharacterDatabase.PQuery("SELECT name, token, number FROM guild_level_invested WHERE token > 0 AND guild = %u ORDER BY token DESC", guild);
2991+ if (result) {
2992+ std::string name;
2993+ uint32 token;
2994+ uint64 number;
2995+ uint16 go = 0;
2996+ do {
2997+ Field* fields = result->Fetch();
2998+ name = fields[0].GetString();
2999+ token = fields[1].GetUInt32();
3000+ number = fields[2].GetUInt64();
3001+
3002+ if (go == 50) {
3003+ break;
3004+ }
3005+ std::stringstream buffer;
3006+ buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << token << " эмблем" << "|r";
3007+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
3008+
3009+ go++;
3010+
3011+ } while (result->NextRow());
3012+
3013+
3014+ }
3015+
3016+
3017+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3018+ }
3019+
3020+ void InvestedRosterHonor1(Player* player, Creature* creature) {
3021+ player->PlayerTalkClass->ClearMenus();
3022+ uint32 guild = player->GetGuildId();
3023+ QueryResult result = CharacterDatabase.PQuery("SELECT name, honor, number FROM guild_level_invested WHERE honor > 0 AND guild = %u ORDER BY honor DESC", guild);
3024+ if (result) {
3025+ std::string name;
3026+ uint32 honor;
3027+ uint64 number;
3028+ uint16 go = 0;
3029+ do {
3030+ Field* fields = result->Fetch();
3031+ name = fields[0].GetString();
3032+ honor = fields[1].GetUInt32();
3033+ number = fields[2].GetUInt64();
3034+
3035+ if (go == 30) {
3036+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 9910);
3037+ break;
3038+ }
3039+ std::stringstream buffer;
3040+ buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << honor << " чести" << "|r";
3041+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
3042+
3043+ go++;
3044+
3045+ } while (result->NextRow());
3046+
3047+
3048+ }
3049+
3050+
3051+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3052+ }
3053+
3054+ void InvestedRosterHonor2(Player* player, Creature* creature) {
3055+ player->PlayerTalkClass->ClearMenus();
3056+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 9911);
3057+ uint32 guild = player->GetGuildId();
3058+ QueryResult result = CharacterDatabase.PQuery("SELECT name, honor, number FROM guild_level_invested WHERE honor > 0 AND guild = %u ORDER BY honor DESC", guild);
3059+ if (result) {
3060+ std::string name;
3061+ uint32 honor;
3062+ uint64 number;
3063+ uint16 go = 0;
3064+ do {
3065+ if (go < 30) {
3066+ go++;
3067+ continue;
3068+ }
3069+ Field* fields = result->Fetch();
3070+ name = fields[0].GetString();
3071+ honor = fields[1].GetUInt32();
3072+ number = fields[2].GetUInt64();
3073+
3074+ if (go == 60) break;
3075+ std::stringstream buffer;
3076+ buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << honor << " чести" << "|r";
3077+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
3078+
3079+ go++;
3080+
3081+ } while (result->NextRow());
3082+
3083+
3084+ }
3085+
3086+
3087+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3088+ }
3089+
3090+ void InvestedRosterArena1(Player* player, Creature* creature) {
3091+ player->PlayerTalkClass->ClearMenus();
3092+ uint32 guild = player->GetGuildId();
3093+ QueryResult result = CharacterDatabase.PQuery("SELECT name, arena, number FROM guild_level_invested WHERE arena > 0 AND guild = %u ORDER BY arena DESC", guild);
3094+ if (result) {
3095+ std::string name;
3096+ uint32 arena;
3097+ uint64 number;
3098+ uint16 go = 0;
3099+ do {
3100+ Field* fields = result->Fetch();
3101+ name = fields[0].GetString();
3102+ arena = fields[1].GetUInt32();
3103+ number = fields[2].GetUInt64();
3104+
3105+ if (go == 30) {
3106+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 9912);
3107+ break;
3108+ }
3109+ std::stringstream buffer;
3110+ buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << arena << " арены" << "|r";
3111+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
3112+
3113+ go++;
3114+
3115+ } while (result->NextRow());
3116+
3117+
3118+ }
3119+
3120+
3121+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3122+ }
3123+
3124+ void InvestedRosterArena2(Player* player, Creature* creature) {
3125+ player->PlayerTalkClass->ClearMenus();
3126+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 9913);
3127+ uint32 guild = player->GetGuildId();
3128+ QueryResult result = CharacterDatabase.PQuery("SELECT name, arena, number FROM guild_level_invested WHERE arena > 0 AND guild = %u ORDER BY arena DESC", guild);
3129+ if (result) {
3130+ std::string name;
3131+ uint32 arena;
3132+ uint64 number;
3133+ uint16 go = 0;
3134+ do {
3135+ if (go < 30) {
3136+ go++;
3137+ continue;
3138+ }
3139+ Field* fields = result->Fetch();
3140+ name = fields[0].GetString();
3141+ arena = fields[1].GetUInt32();
3142+ number = fields[2].GetUInt64();
3143+
3144+ if (go == 60) break;
3145+ std::stringstream buffer;
3146+ buffer << "Игрок: " << "|cff790C06" << name << "|r" << " вложил " << "|cFF1E90FF" << arena << " арены" << "|r";
3147+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, number);
3148+
3149+ go++;
3150+
3151+ } while (result->NextRow());
3152+
3153+
3154+ }
3155+
3156+
3157+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3158+ }
3159+
3160+
3161+
3162+ void UpdateLevelCost(Player* player) {
3163+ uint32 guild = player->GetGuildId();
3164+ QueryResult result10 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
3165+ if (result10) {
3166+ Field *fields = result10->Fetch();
3167+ uint16 level = fields[0].GetUInt16();
3168+ uint32 xp = fields[1].GetUInt32();
3169+
3170+ QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", xp);
3171+ if (knowLevel)
3172+ {
3173+ Field *fs = knowLevel->Fetch();
3174+ uint16 gLevel = fs[0].GetUInt16();
3175+ CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u", gLevel, guild);
3176+ }
3177+
3178+ }
3179+ }
3180+
3181+
3182+
3183+ void SelectSpell5(Player* player, Creature* creature, uint32 action) {
3184+ uint32 spell;
3185+ uint32 cost;
3186+ uint32 number;
3187+ uint32 guild = player->GetGuildId();
3188+ uint64 guid;
3189+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 5");
3190+ if (result) {
3191+ do {
3192+ Field* fields = result->Fetch();
3193+ spell = fields[0].GetUInt32();
3194+ cost = fields[1].GetUInt32();
3195+ number = fields[2].GetUInt32();
3196+
3197+ if (number == action) {
3198+ // learn spell
3199+
3200+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
3201+ if (result2) {
3202+ QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
3203+ if (result15) {
3204+ Field* fields = result15->Fetch();
3205+ uint16 level = fields[0].GetUInt16();
3206+ uint32 xp = fields[1].GetUInt32();
3207+ if (xp >= cost) {
3208+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
3209+
3210+ UpdateLevelCost(player);
3211+ }
3212+ else {
3213+ player->CLOSE_GOSSIP_MENU();
3214+ player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
3215+ return;
3216+ }
3217+
3218+ }
3219+ do {
3220+ Field* fields = result2->Fetch();
3221+ guid = fields[0].GetUInt64();
3222+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
3223+ onlinePlayer->learnSpell(spell, false);
3224+ }
3225+ else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
3226+
3227+ CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
3228+
3229+
3230+ } while (result2->NextRow());
3231+
3232+ }
3233+
3234+ // learn spell
3235+ player->CLOSE_GOSSIP_MENU();
3236+ player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
3237+ }
3238+
3239+ } while (result->NextRow());
3240+ }
3241+
3242+ }
3243+
3244+ void SelectSpell10(Player* player, Creature* creature, uint32 action) {
3245+ uint32 spell;
3246+ uint32 cost;
3247+ uint32 number;
3248+ uint32 guild = player->GetGuildId();
3249+ uint64 guid;
3250+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 10");
3251+ if (result) {
3252+ do {
3253+ Field* fields = result->Fetch();
3254+ spell = fields[0].GetUInt32();
3255+ cost = fields[1].GetUInt32();
3256+ number = fields[2].GetUInt32();
3257+
3258+ if (number == action) {
3259+ // learn spell
3260+
3261+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
3262+ if (result2) {
3263+ QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
3264+ if (result15) {
3265+ Field* fields = result15->Fetch();
3266+ uint16 level = fields[0].GetUInt16();
3267+ uint32 xp = fields[1].GetUInt32();
3268+ if (xp >= cost) {
3269+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
3270+
3271+ UpdateLevelCost(player);
3272+ }
3273+ else {
3274+ player->CLOSE_GOSSIP_MENU();
3275+ player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
3276+ return;
3277+ }
3278+
3279+ }
3280+ do {
3281+ Field* fields = result2->Fetch();
3282+ guid = fields[0].GetUInt64();
3283+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
3284+ onlinePlayer->learnSpell(spell, false);
3285+ }
3286+ else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
3287+
3288+ CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
3289+
3290+
3291+ } while (result2->NextRow());
3292+
3293+ }
3294+
3295+ // learn spell
3296+ player->CLOSE_GOSSIP_MENU();
3297+ player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
3298+ }
3299+
3300+ } while (result->NextRow());
3301+ }
3302+
3303+ }
3304+
3305+ void SelectSpell15(Player* player, Creature* creature, uint32 action) {
3306+ uint32 spell;
3307+ uint32 cost;
3308+ uint32 number;
3309+ uint32 guild = player->GetGuildId();
3310+ uint64 guid;
3311+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 15");
3312+ if (result) {
3313+ do {
3314+ Field* fields = result->Fetch();
3315+ spell = fields[0].GetUInt32();
3316+ cost = fields[1].GetUInt32();
3317+ number = fields[2].GetUInt32();
3318+
3319+ if (number == action) {
3320+ // learn spell
3321+
3322+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
3323+ if (result2) {
3324+ QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
3325+ if (result15) {
3326+ Field* fields = result15->Fetch();
3327+ uint16 level = fields[0].GetUInt16();
3328+ uint32 xp = fields[1].GetUInt32();
3329+ if (xp >= cost) {
3330+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
3331+
3332+ UpdateLevelCost(player);
3333+ }
3334+ else {
3335+ player->CLOSE_GOSSIP_MENU();
3336+ player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
3337+ return;
3338+ }
3339+
3340+ }
3341+ do {
3342+ Field* fields = result2->Fetch();
3343+ guid = fields[0].GetUInt64();
3344+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
3345+ onlinePlayer->learnSpell(spell, false);
3346+ }
3347+ else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
3348+
3349+ CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
3350+
3351+
3352+ } while (result2->NextRow());
3353+
3354+ }
3355+
3356+ // learn spell
3357+ player->CLOSE_GOSSIP_MENU();
3358+ player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
3359+ }
3360+
3361+ } while (result->NextRow());
3362+ }
3363+
3364+ }
3365+
3366+ void SelectSpell20(Player* player, Creature* creature, uint32 action) {
3367+ uint32 spell;
3368+ uint32 cost;
3369+ uint32 number;
3370+ uint32 guild = player->GetGuildId();
3371+ uint64 guid;
3372+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 20");
3373+ if (result) {
3374+ do {
3375+ Field* fields = result->Fetch();
3376+ spell = fields[0].GetUInt32();
3377+ cost = fields[1].GetUInt32();
3378+ number = fields[2].GetUInt32();
3379+
3380+ if (number == action) {
3381+ // learn spell
3382+
3383+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
3384+ if (result2) {
3385+ QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
3386+ if (result15) {
3387+ Field* fields = result15->Fetch();
3388+ uint16 level = fields[0].GetUInt16();
3389+ uint32 xp = fields[1].GetUInt32();
3390+ if (xp >= cost) {
3391+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
3392+
3393+ UpdateLevelCost(player);
3394+ }
3395+ else {
3396+ player->CLOSE_GOSSIP_MENU();
3397+ player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
3398+ return;
3399+ }
3400+
3401+ }
3402+ do {
3403+ Field* fields = result2->Fetch();
3404+ guid = fields[0].GetUInt64();
3405+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
3406+ onlinePlayer->learnSpell(spell, false);
3407+ }
3408+ else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
3409+
3410+ CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
3411+
3412+
3413+ } while (result2->NextRow());
3414+
3415+ }
3416+
3417+ // learn spell
3418+ player->CLOSE_GOSSIP_MENU();
3419+ player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
3420+ }
3421+
3422+ } while (result->NextRow());
3423+ }
3424+
3425+ }
3426+
3427+ void SelectSpell25(Player* player, Creature* creature, uint32 action) {
3428+ uint32 spell;
3429+ uint32 cost;
3430+ uint32 number;
3431+ uint32 guild = player->GetGuildId();
3432+ uint64 guid;
3433+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 25");
3434+ if (result) {
3435+ do {
3436+ Field* fields = result->Fetch();
3437+ spell = fields[0].GetUInt32();
3438+ cost = fields[1].GetUInt32();
3439+ number = fields[2].GetUInt32();
3440+
3441+ if (number == action) {
3442+ // learn spell
3443+
3444+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
3445+ if (result2) {
3446+ QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
3447+ if (result15) {
3448+ Field* fields = result15->Fetch();
3449+ uint16 level = fields[0].GetUInt16();
3450+ uint32 xp = fields[1].GetUInt32();
3451+ if (xp >= cost) {
3452+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
3453+
3454+ UpdateLevelCost(player);
3455+ }
3456+ else {
3457+ player->CLOSE_GOSSIP_MENU();
3458+ player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
3459+ return;
3460+ }
3461+
3462+ }
3463+ do {
3464+ Field* fields = result2->Fetch();
3465+ guid = fields[0].GetUInt64();
3466+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
3467+ onlinePlayer->learnSpell(spell, false);
3468+ }
3469+ else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
3470+
3471+ CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
3472+
3473+
3474+ } while (result2->NextRow());
3475+
3476+ }
3477+
3478+ // learn spell
3479+ player->CLOSE_GOSSIP_MENU();
3480+ player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
3481+ }
3482+
3483+ } while (result->NextRow());
3484+ }
3485+
3486+ }
3487+
3488+ void SelectSpell30(Player* player, Creature* creature, uint32 action) {
3489+ uint32 spell;
3490+ uint32 cost;
3491+ uint32 number;
3492+ uint32 guild = player->GetGuildId();
3493+ uint64 guid;
3494+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, number FROM guild_level_spell WHERE level = 30");
3495+ if (result) {
3496+ do {
3497+ Field* fields = result->Fetch();
3498+ spell = fields[0].GetUInt32();
3499+ cost = fields[1].GetUInt32();
3500+ number = fields[2].GetUInt32();
3501+
3502+ if (number == action) {
3503+ // learn spell
3504+
3505+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
3506+ if (result2) {
3507+ QueryResult result15 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
3508+ if (result15) {
3509+ Field* fields = result15->Fetch();
3510+ uint16 level = fields[0].GetUInt16();
3511+ uint32 xp = fields[1].GetUInt32();
3512+ if (xp >= cost) {
3513+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-%u WHERE guild = %u", cost, guild);
3514+
3515+ UpdateLevelCost(player);
3516+ }
3517+ else {
3518+ player->CLOSE_GOSSIP_MENU();
3519+ player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
3520+ return;
3521+ }
3522+
3523+ }
3524+ do {
3525+ Field* fields = result2->Fetch();
3526+ guid = fields[0].GetUInt64();
3527+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
3528+ onlinePlayer->learnSpell(spell, false);
3529+ }
3530+ else CharacterDatabase.PQuery("REPLACE INTO character_spell (guid, spell, active, disabled) VALUES (%u, %u, 1, 0)", guid, spell);
3531+
3532+ CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spell) VALUES (%u, %u)", guild, spell);
3533+
3534+
3535+ } while (result2->NextRow());
3536+
3537+ }
3538+
3539+ // learn spell
3540+ player->CLOSE_GOSSIP_MENU();
3541+ player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
3542+ }
3543+
3544+ } while (result->NextRow());
3545+ }
3546+
3547+ }
3548+
3549+ /*void ReplaceColorList(Player* player, Creature* creature)
3550+ {
3551+ player->PlayerTalkClass->ClearMenus();
3552+
3553+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Красный", GOSSIP_SENDER_MAIN, 25);
3554+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Синий", GOSSIP_SENDER_MAIN, 26);
3555+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Чёрный", GOSSIP_SENDER_MAIN, 27);
3556+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Белый", GOSSIP_SENDER_MAIN, 28);
3557+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Зелёный", GOSSIP_SENDER_MAIN, 29);
3558+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, "Сменить цвет на Желтый", GOSSIP_SENDER_MAIN, 30);
3559+
3560+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3561+ }
3562+
3563+ void ReplaceColor(Player* player, Creature* creature, uint32 color)
3564+ {
3565+ switch (color)
3566+ {
3567+ case 1:
3568+ CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFF0000' WHERE guild = %u", player->GetGuildId());
3569+ break;
3570+ case 2:
3571+ CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff0000FF' WHERE guild = %u", player->GetGuildId());
3572+ break;
3573+ case 3:
3574+ CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff000000' WHERE guild = %u", player->GetGuildId());
3575+ break;
3576+ case 4:
3577+ CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFFFFFF' WHERE guild = %u", player->GetGuildId());
3578+ break;
3579+ case 5:
3580+ CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cff00FF00' WHERE guild = %u", player->GetGuildId());
3581+ break;
3582+ case 6:
3583+ CharacterDatabase.PExecute("UPDATE guild_level SET color = '|cffFFFF00' WHERE guild = %u", player->GetGuildId());
3584+ break;
3585+
3586+ }
3587+ sGuildMgr->LoadGuilds();
3588+ player->GetSession()->SendAreaTriggerMessage("Вы успешно сменили цвет названия гильдии!");
3589+ player->CLOSE_GOSSIP_MENU();
3590+ }*/
3591+
3592+ void BuySpell10(Player* player, Creature* creature) {
3593+ player->PlayerTalkClass->ClearMenus();
3594+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9900);
3595+ uint32 spell;
3596+ uint32 cost;
3597+ uint16 level;
3598+ uint32 number;
3599+ uint32 faction;
3600+ const char* name;
3601+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 10");
3602+ if (result) {
3603+ do {
3604+ Field* fields = result->Fetch();
3605+ spell = fields[0].GetUInt32();
3606+ cost = fields[1].GetUInt32();
3607+ level = fields[2].GetUInt16();
3608+ number = fields[3].GetUInt32();
3609+ faction = fields[4].GetUInt32();
3610+
3611+ if (player->HasSpell(spell)) continue;
3612+
3613+ if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
3614+
3615+ if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
3616+ const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
3617+ name = (spellEntry->SpellName[player->GetSession()->GetSessionDbLocaleIndex()]);
3618+
3619+ std::stringstream buffer;
3620+ buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
3621+
3622+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
3623+ }
3624+
3625+ while (result->NextRow());
3626+
3627+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3628+ }
3629+ }
3630+
3631+ void BuySpell15(Player* player, Creature* creature) {
3632+ player->PlayerTalkClass->ClearMenus();
3633+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9901);
3634+ uint32 spell;
3635+ uint32 cost;
3636+ uint16 level;
3637+ uint32 number;
3638+ uint32 faction;
3639+ char* name;
3640+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 15");
3641+ if (result) {
3642+ do {
3643+ Field* fields = result->Fetch();
3644+ spell = fields[0].GetUInt32();
3645+ cost = fields[1].GetUInt32();
3646+ level = fields[2].GetUInt16();
3647+ number = fields[3].GetUInt32();
3648+ faction = fields[4].GetUInt32();
3649+
3650+ if (player->HasSpell(spell)) continue;
3651+
3652+ if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
3653+
3654+ if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
3655+ const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
3656+ name = (spellEntry->SpellName[8]);
3657+
3658+ std::stringstream buffer;
3659+ buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
3660+
3661+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
3662+ }
3663+
3664+ while (result->NextRow());
3665+
3666+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3667+ }
3668+ }
3669+
3670+ void BuySpell20(Player* player, Creature* creature) {
3671+ player->PlayerTalkClass->ClearMenus();
3672+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9902);
3673+ uint32 spell;
3674+ uint32 cost;
3675+ uint16 level;
3676+ uint32 number;
3677+ uint32 faction;
3678+ char* name;
3679+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 20");
3680+ if (result) {
3681+ do {
3682+ Field* fields = result->Fetch();
3683+ spell = fields[0].GetUInt32();
3684+ cost = fields[1].GetUInt32();
3685+ level = fields[2].GetUInt16();
3686+ number = fields[3].GetUInt32();
3687+ faction = fields[4].GetUInt32();
3688+
3689+ if (player->HasSpell(spell)) continue;
3690+
3691+ if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
3692+
3693+ if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
3694+ const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
3695+ name = (spellEntry->SpellName[8]);
3696+
3697+ std::stringstream buffer;
3698+ buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
3699+
3700+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
3701+ }
3702+
3703+ while (result->NextRow());
3704+
3705+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3706+ }
3707+ }
3708+ void BuySpell25(Player* player, Creature* creature) {
3709+ player->PlayerTalkClass->ClearMenus();
3710+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9903);
3711+ uint32 spell;
3712+ uint32 cost;
3713+ uint16 level;
3714+ uint32 number;
3715+ uint32 faction;
3716+ char* name;
3717+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 25");
3718+ if (result) {
3719+ do {
3720+ Field* fields = result->Fetch();
3721+ spell = fields[0].GetUInt32();
3722+ cost = fields[1].GetUInt32();
3723+ level = fields[2].GetUInt16();
3724+ number = fields[3].GetUInt32();
3725+ faction = fields[4].GetUInt32();
3726+
3727+ if (player->HasSpell(spell)) continue;
3728+
3729+ if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
3730+
3731+ if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
3732+ const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
3733+ name = (spellEntry->SpellName[8]);
3734+
3735+ std::stringstream buffer;
3736+ buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
3737+
3738+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
3739+ }
3740+
3741+ while (result->NextRow());
3742+
3743+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3744+ }
3745+ }
3746+
3747+ void BuySpell30(Player* player, Creature* creature) {
3748+ player->PlayerTalkClass->ClearMenus();
3749+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов:", GOSSIP_SENDER_MAIN, 9904);
3750+ uint32 spell;
3751+ uint32 cost;
3752+ uint16 level;
3753+ uint32 number;
3754+ uint32 faction;
3755+ char* name;
3756+ QueryResult result = CharacterDatabase.PQuery("SELECT spell, cost, level, number, faction FROM guild_level_spell WHERE level = 30");
3757+ if (result) {
3758+ do {
3759+ Field* fields = result->Fetch();
3760+ spell = fields[0].GetUInt32();
3761+ cost = fields[1].GetUInt32();
3762+ level = fields[2].GetUInt16();
3763+ number = fields[3].GetUInt32();
3764+ faction = fields[4].GetUInt32();
3765+
3766+ if (player->HasSpell(spell)) continue;
3767+
3768+ if (player->GetTeam() == TEAM_ALLIANCE && faction == 2) continue;
3769+
3770+ if (player->GetTeam() == TEAM_HORDE && faction == 1) continue;
3771+ const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
3772+ name = (spellEntry->SpellName[8]);
3773+
3774+ std::stringstream buffer;
3775+ buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " опыта." << "|r";
3776+
3777+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
3778+ }
3779+
3780+ while (result->NextRow());
3781+
3782+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3783+ }
3784+ }
3785+
3786+ void CurrentSpellsMenu(Player* player, Creature* creature) {
3787+ player->PlayerTalkClass->ClearMenus();
3788+
3789+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Доступные уровни заклинаний:", GOSSIP_SENDER_MAIN, 9905);
3790+ uint32 guild = player->GetGuildId();
3791+ uint16 level;
3792+ QueryResult result = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", guild);
3793+ if (result) {
3794+ Field* fields = result->Fetch();
3795+ level = fields[0].GetUInt16();
3796+ }
3797+
3798+ uint32 spell;
3799+ if (level >= 5) {
3800+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 5");
3801+ if (result2) {
3802+ do {
3803+ Field* fields = result2->Fetch();
3804+ spell = fields[0].GetUInt32();
3805+ if (!player->HasSpell(spell)) {
3806+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 5-го уровня", GOSSIP_SENDER_MAIN, 24);
3807+ break;
3808+ }
3809+ } while (result2->NextRow());
3810+ }
3811+ }
3812+
3813+ if (level >= 10) {
3814+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 10");
3815+ if (result2) {
3816+ do {
3817+ Field* fields = result2->Fetch();
3818+ spell = fields[0].GetUInt32();
3819+ if (!player->HasSpell(spell)) {
3820+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 10-го уровня", GOSSIP_SENDER_MAIN, 25);
3821+ break;
3822+ }
3823+ } while (result2->NextRow());
3824+ }
3825+ }
3826+
3827+ if (level >= 15) {
3828+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 15");
3829+ if (result2) {
3830+ do {
3831+ Field* fields = result2->Fetch();
3832+ spell = fields[0].GetUInt32();
3833+ if (!player->HasSpell(spell)) {
3834+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 15-го уровня", GOSSIP_SENDER_MAIN, 26);
3835+ break;
3836+ }
3837+ } while (result2->NextRow());
3838+ }
3839+ }
3840+
3841+ if (level >= 20) {
3842+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 20");
3843+ if (result2) {
3844+ do {
3845+ Field* fields = result2->Fetch();
3846+ spell = fields[0].GetUInt32();
3847+ if (!player->HasSpell(spell)) {
3848+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 20-го уровня", GOSSIP_SENDER_MAIN, 27);
3849+ break;
3850+ }
3851+ } while (result2->NextRow());
3852+ }
3853+ }
3854+
3855+ if (level >= 25) {
3856+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 25");
3857+ if (result2) {
3858+ do {
3859+ Field* fields = result2->Fetch();
3860+ spell = fields[0].GetUInt32();
3861+ if (!player->HasSpell(spell)) {
3862+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 25-го уровня", GOSSIP_SENDER_MAIN, 28);
3863+ break;
3864+ }
3865+ } while (result2->NextRow());
3866+ }
3867+ }
3868+
3869+ if (level >= 30) {
3870+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM guild_level_spell WHERE level = 30");
3871+ if (result2) {
3872+ do {
3873+ Field* fields = result2->Fetch();
3874+ spell = fields[0].GetUInt32();
3875+ if (!player->HasSpell(spell)) {
3876+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Заклинания 30-го уровня", GOSSIP_SENDER_MAIN, 29);
3877+ break;
3878+ }
3879+ } while (result2->NextRow());
3880+ }
3881+ }
3882+
3883+
3884+
3885+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3886+ }
3887+
3888+ void AllGuilds1(Player* player, Creature* creature) {
3889+ player->PlayerTalkClass->ClearMenus();
3890+ uint32 count;
3891+ QueryResult result3 = CharacterDatabase.PQuery("SELECT COUNT(guild) FROM guild_level WHERE level > 1");
3892+ if (result3) {
3893+ Field* fields = result3->Fetch();
3894+ count = fields[0].GetUInt32();
3895+ }
3896+ QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
3897+ if (result) {
3898+ std::string name;
3899+ std::string gleader;
3900+ uint32 guild;
3901+ uint16 level;
3902+ uint16 go = 0;
3903+ uint64 leaderguid;
3904+ do {
3905+ Field* fields = result->Fetch();
3906+ guild = fields[0].GetUInt32();
3907+ level = fields[1].GetUInt16();
3908+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
3909+ if (result3) {
3910+ Field* fields = result3->Fetch();
3911+ name = fields[0].GetString();
3912+ leaderguid = fields[1].GetUInt64();
3913+ }
3914+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
3915+ if (result4) {
3916+ Field* fields = result4->Fetch();
3917+ gleader = fields[0].GetString();
3918+ }
3919+ if (go == 10) {
3920+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 14);
3921+ break;
3922+ }
3923+ std::stringstream buffer;
3924+ buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
3925+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild + 100);
3926+
3927+ go++;
3928+
3929+ } while (result->NextRow());
3930+
3931+
3932+ }
3933+
3934+
3935+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3936+ }
3937+
3938+ void AllGuilds2(Player* player, Creature* creature) {
3939+ player->PlayerTalkClass->ClearMenus();
3940+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 19);
3941+ QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
3942+ if (result) {
3943+ std::string name;
3944+ std::string gleader;
3945+ uint32 guild;
3946+ uint16 level;
3947+ uint16 go = 0;
3948+ uint64 leaderguid;
3949+ do {
3950+ if (go < 10) {
3951+ go++;
3952+ continue;
3953+ }
3954+ Field* fields = result->Fetch();
3955+ guild = fields[0].GetUInt32();
3956+ level = fields[1].GetUInt16();
3957+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
3958+ if (result3) {
3959+ Field* fields = result3->Fetch();
3960+ name = fields[0].GetString();
3961+ leaderguid = fields[1].GetUInt64();
3962+ }
3963+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
3964+ if (result4) {
3965+ Field* fields = result4->Fetch();
3966+ gleader = fields[0].GetString();
3967+ }
3968+ if (go == 20) {
3969+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше =>", GOSSIP_SENDER_MAIN, 15);
3970+ break;
3971+ }
3972+ std::stringstream buffer;
3973+ buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
3974+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild + 1000);
3975+
3976+ go++;
3977+ } while (result->NextRow());
3978+
3979+
3980+ }
3981+
3982+
3983+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
3984+ }
3985+
3986+ void AllGuilds3(Player* player, Creature* creature) {
3987+ player->PlayerTalkClass->ClearMenus();
3988+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 20);
3989+ QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
3990+ if (result) {
3991+ std::string name;
3992+ std::string gleader;
3993+ uint32 guild;
3994+ uint16 level;
3995+ uint16 go = 0;
3996+ uint64 leaderguid;
3997+ do {
3998+ if (go < 20) {
3999+ go++;
4000+ continue;
4001+ }
4002+ Field* fields = result->Fetch();
4003+ guild = fields[0].GetUInt32();
4004+ level = fields[1].GetUInt16();
4005+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
4006+ if (result3) {
4007+ Field* fields = result3->Fetch();
4008+ name = fields[0].GetString();
4009+ leaderguid = fields[1].GetUInt64();
4010+ }
4011+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
4012+ if (result4) {
4013+ Field* fields = result4->Fetch();
4014+ gleader = fields[0].GetString();
4015+ }
4016+ if (go == 30) {
4017+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше =>", GOSSIP_SENDER_MAIN, 16);
4018+ break;
4019+ }
4020+ std::stringstream buffer;
4021+ buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
4022+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild + 2000);
4023+ go++;
4024+ } while (result->NextRow());
4025+
4026+
4027+ }
4028+
4029+
4030+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
4031+ }
4032+
4033+ void AllGuilds4(Player* player, Creature* creature) {
4034+ player->PlayerTalkClass->ClearMenus();
4035+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 21);
4036+ QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
4037+ if (result) {
4038+ std::string name;
4039+ std::string gleader;
4040+ uint32 guild;
4041+ uint16 level;
4042+ uint16 go = 0;
4043+ uint64 leaderguid;
4044+ do {
4045+ if (go < 30) {
4046+ go++;
4047+ continue;
4048+ }
4049+ Field* fields = result->Fetch();
4050+ guild = fields[0].GetUInt32();
4051+ level = fields[1].GetUInt16();
4052+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
4053+ if (result3) {
4054+ Field* fields = result3->Fetch();
4055+ name = fields[0].GetString();
4056+ leaderguid = fields[1].GetUInt64();
4057+ }
4058+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
4059+ if (result4) {
4060+ Field* fields = result4->Fetch();
4061+ gleader = fields[0].GetString();
4062+ }
4063+ if (go == 40) {
4064+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше =>", GOSSIP_SENDER_MAIN, 17);
4065+ break;
4066+ }
4067+ std::stringstream buffer;
4068+ buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
4069+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild + 3000);
4070+ go++;
4071+ } while (result->NextRow());
4072+
4073+
4074+ }
4075+
4076+
4077+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
4078+ }
4079+
4080+ void AllGuilds5(Player* player, Creature* creature) {
4081+ player->PlayerTalkClass->ClearMenus();
4082+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 22);
4083+ QueryResult result = CharacterDatabase.PQuery("SELECT guild, level FROM guild_level WHERE level > 1 ORDER BY level DESC");
4084+ if (result) {
4085+ std::string name;
4086+ std::string gleader;
4087+ uint32 guild;
4088+ uint16 level;
4089+ uint16 go = 0;
4090+ uint64 leaderguid;
4091+ do {
4092+ if (go < 40) {
4093+ go++;
4094+ continue;
4095+ }
4096+ Field* fields = result->Fetch();
4097+ guild = fields[0].GetUInt32();
4098+ level = fields[1].GetUInt16();
4099+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name, leaderguid FROM guild WHERE guildid = %u", guild);
4100+ if (result3) {
4101+ Field* fields = result3->Fetch();
4102+ name = fields[0].GetString();
4103+ leaderguid = fields[1].GetUInt64();
4104+ }
4105+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = %u", leaderguid);
4106+ if (result4) {
4107+ Field* fields = result4->Fetch();
4108+ gleader = fields[0].GetString();
4109+ }
4110+ if (go == 50) {
4111+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Конец", GOSSIP_SENDER_MAIN, 18);
4112+ break;
4113+ }
4114+ std::stringstream buffer;
4115+ buffer << "|cff084E13" << name << "|r" << ". Уровень: " << "|cFF1E90FF" << level << "|r" << ". ГМ: " << "|cff790C06" << gleader << "|r";
4116+ player->ADD_GOSSIP_ITEM(4, buffer.str(), GOSSIP_SENDER_MAIN, guild + 4000);
4117+ go++;
4118+ } while (result->NextRow());
4119+
4120+
4121+ }
4122+
4123+
4124+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
4125+ }
4126+
4127+ void TakeHonorButtons(Player* player, Creature* creature) {
4128+ if (!player->GetGuildId()) {
4129+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4130+ player->CLOSE_GOSSIP_MENU();
4131+ return;
4132+ }
4133+
4134+ player->PlayerTalkClass->ClearMenus();
4135+
4136+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 2 000 чести (+10 опыта)", GOSSIP_SENDER_MAIN, 5);
4137+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 10 000 чести (+50 опыта)", GOSSIP_SENDER_MAIN, 6);
4138+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 20 000 чести (+100 опыта)", GOSSIP_SENDER_MAIN, 7);
4139+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 30 000 чести (+150 опыта)", GOSSIP_SENDER_MAIN, 8);
4140+
4141+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
4142+ }
4143+
4144+ void TakeGold(Player* player, Creature* creature, char const* code)
4145+ {
4146+ int32 gold = atoi(code) * 10000;
4147+ if (!player->GetGuildId()) {
4148+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4149+ player->CLOSE_GOSSIP_MENU();
4150+ return;
4151+ }
4152+ if (player->GetMoney() < 5000 * 10000) {
4153+ player->GetSession()->SendNotification("У вас недостаточно золота!");
4154+ player->CLOSE_GOSSIP_MENU();
4155+ return;
4156+ }
4157+ uint32 guild = player->GetGuildId();
4158+ uint32 axp = gold / 50 / 10000;
4159+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u", axp, guild);
4160+ std::string name = player->GetName();
4161+
4162+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4163+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4164+
4165+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4166+ uint32 number;
4167+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4168+ if (result2) {
4169+ Field* fields = result2->Fetch();
4170+ number = fields[0].GetUInt32();
4171+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4172+ }
4173+
4174+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET gold = gold+%u WHERE guild = %u AND name = '%s'", gold / 10000, guild, name.c_str());
4175+ player->ModifyMoney(-gold);
4176+
4177+ UpdateLevel(player);
4178+
4179+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4180+ player->CLOSE_GOSSIP_MENU();
4181+
4182+ }
4183+
4184+ void TakeArena10000(Player* player) {
4185+ if (!player->GetGuildId()) {
4186+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4187+ player->CLOSE_GOSSIP_MENU();
4188+ return;
4189+ }
4190+ if (player->GetArenaPoints() < 1500) {
4191+ player->GetSession()->SendNotification("У вас недостаточно очков арены!");
4192+ player->CLOSE_GOSSIP_MENU();
4193+ return;
4194+ }
4195+ uint32 guild = player->GetGuildId();
4196+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+150 WHERE guild = %u", guild);
4197+ std::string name = player->GetName();
4198+
4199+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4200+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4201+
4202+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4203+ uint32 number;
4204+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4205+ if (result2) {
4206+ Field* fields = result2->Fetch();
4207+ number = fields[0].GetUInt32();
4208+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4209+ }
4210+
4211+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+1500 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4212+ player->ModifyArenaPoints(-1500);
4213+
4214+ UpdateLevel(player);
4215+
4216+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4217+ player->CLOSE_GOSSIP_MENU();
4218+ }
4219+
4220+ void TakeArena7500(Player* player) {
4221+ if (!player->GetGuildId()) {
4222+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4223+ player->CLOSE_GOSSIP_MENU();
4224+ return;
4225+ }
4226+ if (player->GetArenaPoints() < 1000) {
4227+ player->GetSession()->SendNotification("У вас недостаточно очков арены!");
4228+ player->CLOSE_GOSSIP_MENU();
4229+ return;
4230+ }
4231+ uint32 guild = player->GetGuildId();
4232+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+100 WHERE guild = %u", guild);
4233+ std::string name = player->GetName();
4234+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4235+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4236+
4237+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4238+ uint32 number;
4239+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4240+ if (result2) {
4241+ Field* fields = result2->Fetch();
4242+ number = fields[0].GetUInt32();
4243+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4244+ }
4245+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+1000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4246+ player->ModifyArenaPoints(-1000);
4247+
4248+ UpdateLevel(player);
4249+
4250+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4251+ player->CLOSE_GOSSIP_MENU();
4252+ }
4253+
4254+ void TakeArena5000(Player* player) {
4255+ if (!player->GetGuildId()) {
4256+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4257+ player->CLOSE_GOSSIP_MENU();
4258+ return;
4259+ }
4260+ if (player->GetArenaPoints() < 500) {
4261+ player->GetSession()->SendNotification("У вас недостаточно очков арены!");
4262+ player->CLOSE_GOSSIP_MENU();
4263+ return;
4264+ }
4265+ uint32 guild = player->GetGuildId();
4266+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+50 WHERE guild = %u", guild);
4267+ std::string name = player->GetName();
4268+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4269+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4270+
4271+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4272+ uint32 number;
4273+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4274+ if (result2) {
4275+ Field* fields = result2->Fetch();
4276+ number = fields[0].GetUInt32();
4277+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4278+ }
4279+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+500 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4280+ player->ModifyArenaPoints(-500);
4281+
4282+ UpdateLevel(player);
4283+
4284+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4285+ player->CLOSE_GOSSIP_MENU();
4286+ }
4287+
4288+ void TakeArena2500(Player* player) {
4289+ if (!player->GetGuildId()) {
4290+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4291+ player->CLOSE_GOSSIP_MENU();
4292+ return;
4293+ }
4294+ if (player->GetArenaPoints() < 100) {
4295+ player->GetSession()->SendNotification("У вас недостаточно очков арены!");
4296+ player->CLOSE_GOSSIP_MENU();
4297+ return;
4298+ }
4299+ uint32 guild = player->GetGuildId();
4300+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
4301+ std::string name = player->GetName();
4302+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4303+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4304+
4305+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4306+ uint32 number;
4307+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4308+ if (result2) {
4309+ Field* fields = result2->Fetch();
4310+ number = fields[0].GetUInt32();
4311+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4312+ }
4313+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET arena = arena+100 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4314+ player->ModifyArenaPoints(-100);
4315+
4316+ UpdateLevel(player);
4317+
4318+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4319+ player->CLOSE_GOSSIP_MENU();
4320+ }
4321+
4322+ void TakeHonor200(Player* player) {
4323+ if (!player->GetGuildId()) {
4324+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4325+ player->CLOSE_GOSSIP_MENU();
4326+ return;
4327+ }
4328+ if (player->GetHonorPoints() < 30000) {
4329+ player->GetSession()->SendNotification("У вас недостаточно очков чести!");
4330+ player->CLOSE_GOSSIP_MENU();
4331+ return;
4332+ }
4333+ uint32 guild = player->GetGuildId();
4334+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+150 WHERE guild = %u", guild);
4335+ std::string name = player->GetName();
4336+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4337+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4338+
4339+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4340+ uint32 number;
4341+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4342+ if (result2) {
4343+ Field* fields = result2->Fetch();
4344+ number = fields[0].GetUInt32();
4345+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4346+ }
4347+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+30000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4348+ player->ModifyHonorPoints(-30000);
4349+ UpdateLevel(player);
4350+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4351+ player->CLOSE_GOSSIP_MENU();
4352+ }
4353+
4354+ void TakeHonor150(Player* player) {
4355+ if (!player->GetGuildId()) {
4356+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4357+ player->CLOSE_GOSSIP_MENU();
4358+ return;
4359+ }
4360+ if (player->GetHonorPoints() < 20000) {
4361+ player->GetSession()->SendNotification("У вас недостаточно очков чести!");
4362+ player->CLOSE_GOSSIP_MENU();
4363+ return;
4364+ }
4365+ uint32 guild = player->GetGuildId();
4366+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+100 WHERE guild = %u", guild);
4367+ std::string name = player->GetName();
4368+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4369+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4370+
4371+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4372+ uint32 number;
4373+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4374+ if (result2) {
4375+ Field* fields = result2->Fetch();
4376+ number = fields[0].GetUInt32();
4377+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4378+ }
4379+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+20000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4380+ player->ModifyHonorPoints(-20000);
4381+
4382+ UpdateLevel(player);
4383+
4384+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4385+ player->CLOSE_GOSSIP_MENU();
4386+ }
4387+
4388+ void TakeHonor100(Player* player) {
4389+ if (!player->GetGuildId()) {
4390+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4391+ player->CLOSE_GOSSIP_MENU();
4392+ return;
4393+ }
4394+ if (player->GetHonorPoints() < 10000) {
4395+ player->GetSession()->SendNotification("У вас недостаточно очков чести!");
4396+ player->CLOSE_GOSSIP_MENU();
4397+ return;
4398+ }
4399+ uint32 guild = player->GetGuildId();
4400+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+50 WHERE guild = %u", guild);
4401+ std::string name = player->GetName();
4402+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4403+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4404+
4405+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4406+ uint32 number;
4407+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4408+ if (result2) {
4409+ Field* fields = result2->Fetch();
4410+ number = fields[0].GetUInt32();
4411+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4412+ }
4413+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+10000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4414+ player->ModifyHonorPoints(-10000);
4415+ UpdateLevel(player);
4416+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4417+ player->CLOSE_GOSSIP_MENU();
4418+ }
4419+
4420+ void TakeFrostEmblem(Player* player)
4421+ {
4422+ if (!player->GetGuildId()) {
4423+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4424+ player->CLOSE_GOSSIP_MENU();
4425+ return;
4426+ }
4427+
4428+ if (!player->HasItemCount(49426, 1, true)) {
4429+ player->GetSession()->SendNotification("У вас недостаточно эмблем!");
4430+ player->CLOSE_GOSSIP_MENU();
4431+ return;
4432+ }
4433+ uint32 guild = player->GetGuildId();
4434+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
4435+
4436+ std::string name = player->GetName();
4437+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4438+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4439+
4440+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4441+ uint32 number;
4442+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4443+ if (result2) {
4444+ Field* fields = result2->Fetch();
4445+ number = fields[0].GetUInt32();
4446+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4447+ }
4448+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET token = token+1 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4449+ player->DestroyItemCount(49426, 1, true);
4450+ UpdateLevel(player);
4451+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4452+ player->CLOSE_GOSSIP_MENU();
4453+ }
4454+
4455+ void TakeTriumphEmblem(Player* player)
4456+ {
4457+ if (!player->GetGuildId()) {
4458+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4459+ player->CLOSE_GOSSIP_MENU();
4460+ return;
4461+ }
4462+
4463+ if (!player->HasItemCount(18228, 50, true)) {
4464+ player->GetSession()->SendNotification("У вас недостаточно свитков!");
4465+ player->CLOSE_GOSSIP_MENU();
4466+ return;
4467+ }
4468+ uint32 guild = player->GetGuildId();
4469+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
4470+
4471+ std::string name = player->GetName();
4472+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4473+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4474+
4475+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4476+ uint32 number;
4477+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4478+ if (result2) {
4479+ Field* fields = result2->Fetch();
4480+ number = fields[0].GetUInt32();
4481+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4482+ }
4483+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET svitok = svitok+50 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4484+ player->DestroyItemCount(18228, 50, true);
4485+ UpdateLevel(player);
4486+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4487+ player->CLOSE_GOSSIP_MENU();
4488+ }
4489+
4490+ void TakeHonor50(Player* player) {
4491+ if (!player->GetGuildId()) {
4492+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4493+ player->CLOSE_GOSSIP_MENU();
4494+ return;
4495+ }
4496+ if (player->GetHonorPoints() < 2000) {
4497+ player->GetSession()->SendNotification("У вас недостаточно очков чести!");
4498+ player->CLOSE_GOSSIP_MENU();
4499+ return;
4500+ }
4501+ uint32 guild = player->GetGuildId();
4502+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+10 WHERE guild = %u", guild);
4503+
4504+ std::string name = player->GetName();
4505+ QueryResult result4 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested");
4506+ if (!result4) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, 10000, 0, 0, 0)", guild, name.c_str());
4507+
4508+ QueryResult result3 = CharacterDatabase.PQuery("SELECT name FROM guild_level_invested WHERE guild = %u AND name = '%s'", guild, name.c_str());
4509+ uint32 number;
4510+ QueryResult result2 = CharacterDatabase.PQuery("SELECT MAX(number) FROM guild_level_invested");
4511+ if (result2) {
4512+ Field* fields = result2->Fetch();
4513+ number = fields[0].GetUInt32();
4514+ if (!result3) CharacterDatabase.PQuery("REPLACE INTO guild_level_invested (guild, name, honor, arena, number, gold, svitok, token) VALUES (%u, '%s', 0, 0, %u, 0)", guild, name.c_str(), number + 1);
4515+ }
4516+ CharacterDatabase.PQuery("UPDATE guild_level_invested SET honor = honor+2000 WHERE guild = %u AND name = '%s'", guild, name.c_str());
4517+ player->ModifyHonorPoints(-2000);
4518+ UpdateLevel(player);
4519+ player->GetSession()->SendAreaTriggerMessage("Пожертвование прошло успешно!");
4520+ player->CLOSE_GOSSIP_MENU();
4521+ }
4522+
4523+
4524+
4525+ void TakeArenaButtons(Player* player, Creature* creature) {
4526+ if (!player->GetGuildId()) {
4527+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4528+ player->CLOSE_GOSSIP_MENU();
4529+ return;
4530+ }
4531+
4532+ player->PlayerTalkClass->ClearMenus();
4533+
4534+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 100 арены (+10 опыта)", GOSSIP_SENDER_MAIN, 9);
4535+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 500 арены (+50 опыта)", GOSSIP_SENDER_MAIN, 10);
4536+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 1000 арены (+100 опыта)", GOSSIP_SENDER_MAIN, 11);
4537+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Пожертвовать гильдии 1500 арены (+150 опыта)", GOSSIP_SENDER_MAIN, 12);
4538+
4539+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
4540+ }
4541+
4542+ void GuildInfo(Player* player) {
4543+ if (!player->GetGuildId()) {
4544+ player->GetSession()->SendNotification("Вы не состоите в гильдии!");
4545+ player->CLOSE_GOSSIP_MENU();
4546+ return;
4547+ }
4548+ uint32 guild = player->GetGuildId();
4549+ QueryResult result = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
4550+ if (result) {
4551+ Field *fields = result->Fetch();
4552+ uint16 level = fields[0].GetUInt16();
4553+ uint32 xp = fields[1].GetUInt32();
4554+
4555+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eУровень вашей гильдии:|r |cfffcedbb%u|r", level);
4556+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eПрогресс уровня вашей гильдии:|r |cfffcedbb%u|r", xp);
4557+
4558+ QueryResult result1 = CharacterDatabase.PQuery("SELECT xp FROM guild_xp_table WHERE level = %u", level);
4559+ if (result1) {
4560+ Field *fields = result1->Fetch();
4561+ uint32 reqXp = fields[0].GetUInt32();
4562+ uint32 ReqXp = reqXp - xp;
4563+ if (level < 30) ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eДо %u-го уровня гильдии осталось накопить:|r |cfffcedbb%u опыта|r", level + 1, ReqXp);
4564+ else ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВаша гильдия имеет максимальный уровень!|r");
4565+
4566+ }
4567+
4568+ }
4569+ player->CLOSE_GOSSIP_MENU();
4570+ }
4571+
4572+ bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action) {
4573+ switch (action) {
4574+ case 1:
4575+ TakeHonorButtons(player, creature);
4576+ break;
4577+ case 2:
4578+ TakeArenaButtons(player, creature);
4579+ break;
4580+ case 3:
4581+ GuildInfo(player);
4582+ break;
4583+ case 4:
4584+ player->CLOSE_GOSSIP_MENU();
4585+ break;
4586+ case 5:
4587+ TakeHonor50(player);
4588+ break;
4589+ case 6:
4590+ TakeHonor100(player);
4591+ break;
4592+ case 7:
4593+ TakeHonor150(player);
4594+ break;
4595+ case 8:
4596+ TakeHonor200(player);
4597+ break;
4598+ case 9:
4599+ TakeArena2500(player);
4600+ break;
4601+ case 10:
4602+ TakeArena5000(player);
4603+ break;
4604+ case 11:
4605+ TakeArena7500(player);
4606+ break;
4607+ case 12:
4608+ TakeArena10000(player);
4609+ break;
4610+ case 13:
4611+ AllGuilds1(player, creature);
4612+ break;
4613+ case 14:
4614+ AllGuilds2(player, creature);
4615+ break;
4616+ case 15:
4617+ AllGuilds3(player, creature);
4618+ break;
4619+ case 16:
4620+ AllGuilds4(player, creature);
4621+ break;
4622+ case 17:
4623+ AllGuilds5(player, creature);
4624+ break;
4625+ case 18:
4626+ player->CLOSE_GOSSIP_MENU();
4627+ break;
4628+ case 19:
4629+ AllGuilds1(player, creature);
4630+ break;
4631+ case 20:
4632+ AllGuilds2(player, creature);
4633+ break;
4634+ case 21:
4635+ AllGuilds3(player, creature);
4636+ break;
4637+ case 22:
4638+ AllGuilds4(player, creature);
4639+ break;
4640+ case 23:
4641+ CurrentSpellsMenu(player, creature);
4642+ break;
4643+ /*case 24:
4644+ ReplaceColorList(player, creature);
4645+ break;
4646+ case 25:
4647+ ReplaceColor(player, creature, 1);
4648+ break;
4649+ case 26:
4650+ ReplaceColor(player, creature, 2);
4651+ break;
4652+ case 27:
4653+ ReplaceColor(player, creature, 3);
4654+ break;
4655+ case 28:
4656+ ReplaceColor(player, creature, 4);
4657+ break;
4658+ case 29:
4659+ ReplaceColor(player, creature, 5);
4660+ break;
4661+ case 30:
4662+ ReplaceColor(player, creature, 6);
4663+ break;*/
4664+ case 35:
4665+ TakeTriumphEmblem(player);
4666+ break;
4667+ case 36:
4668+ TakeFrostEmblem(player);
4669+ break;
4670+ /*case 9998:
4671+ BuySpell5(player, creature);
4672+ break;
4673+ case 9900:
4674+ BuySpell10(player, creature);
4675+ break;
4676+ case 9901:
4677+ BuySpell15(player, creature);
4678+ break;
4679+ case 9902:
4680+ BuySpell20(player, creature);
4681+ break;
4682+ case 9903:
4683+ BuySpell25(player, creature);
4684+ break;
4685+ case 9904:
4686+ BuySpell30(player, creature);
4687+ break;
4688+ case 9905:
4689+ CurrentSpellsMenu(player, creature);
4690+ break;*/
4691+ case 9000:
4692+ InvestedRosterGold1(player, creature);
4693+ break;
4694+ case 9910:
4695+ InvestedRosterHonor2(player, creature);
4696+ break;
4697+ case 9911:
4698+ InvestedRosterHonor1(player, creature);
4699+ break;
4700+ case 9912:
4701+ InvestedRosterArena2(player, creature);
4702+ break;
4703+ case 9913:
4704+ InvestedRosterArena1(player, creature);
4705+ break;
4706+ case 9914:
4707+ InvestedRoster(player, creature);
4708+ break;
4709+ case 9917:
4710+ InvestedSvitok(player, creature);
4711+ break;
4712+ case 9918:
4713+ InvestedToken(player, creature);
4714+ break;
4715+ case 9915:
4716+ InvestedRosterHonor1(player, creature);
4717+ break;
4718+ case 9916:
4719+ InvestedRosterArena1(player, creature);
4720+ break;
4721+
4722+ }
4723+
4724+ if (action > 100 && action < 1000) AllGuilds1(player, creature);
4725+ if (action > 1000 && action < 2000) AllGuilds2(player, creature);
4726+ if (action > 2000 && action < 3000) AllGuilds3(player, creature);
4727+ if (action > 3000 && action < 4000) AllGuilds4(player, creature);
4728+ if (action > 4000 && action < 5000) AllGuilds5(player, creature);
4729+ if (action >= 10000) InvestedRoster(player, creature);
4730+
4731+ /*SelectSpell5(player, creature, action);
4732+ SelectSpell10(player, creature, action);
4733+ SelectSpell15(player, creature, action);
4734+ SelectSpell20(player, creature, action);
4735+ SelectSpell25(player, creature, action);
4736+ SelectSpell30(player, creature, action);*/
4737+
4738+ return true;
4739+ }
4740+ bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
4741+ {
4742+ switch (action)
4743+ {
4744+ case 200:
4745+ TakeGold(player, creature, code);
4746+ break;
4747+ }
4748+ return true;
4749+ }
4750+
4751+};
4752+
4753+class npc_guildhouse : public CreatureScript
4754+
4755+{
4756+
4757+public:
4758+
4759+ npc_guildhouse() : CreatureScript("npc_guildhouse") {}
4760+
4761+ bool OnGossipHello(Player* player, Creature* creature) {
4762+ player->PlayerTalkClass->ClearMenus();
4763+ uint16 count;
4764+ if (uint32 guild = player->GetGuildId())
4765+ {
4766+ if (player->GetRankFromDB(player->GetGUID()) == 0)
4767+ {
4768+ QueryResult result = CharacterDatabase.PQuery("SELECT COUNT(guild) FROM guildhouses WHERE guild = 0");
4769+ if (result)
4770+ {
4771+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
4772+ if (!result2)
4773+ {
4774+ Field* fields = result->Fetch();
4775+ count = fields[0].GetUInt16();
4776+ if (count > 0)
4777+ {
4778+ std::ostringstream psm;
4779+ psm << "|TInterface/ICONS/Spell_Arcane_TeleportTheramore:32:32:-18:0|tПосмотреть место для Дома Гильдии";
4780+ std::ostringstream kpt;
4781+ kpt << "|TInterface/ICONS/Spell_Arcane_TeleportSilvermoon:32:32:-18:0|tКупить место для Дома Гильдии";
4782+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, psm.str(), GOSSIP_SENDER_MAIN, 1);
4783+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, kpt.str(), GOSSIP_SENDER_MAIN, 2);
4784+ }
4785+ }
4786+ else
4787+ {
4788+ std::ostringstream kptm;
4789+ kptm << "|TInterface/ICONS/Achievement_Reputation_02:32:32:-18:0|tПродать свой Дом Гильдии!";
4790+ player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, kptm.str(), GOSSIP_SENDER_MAIN, 6, "Введите цену |cffE024B4(опыт гильдии)|r, за которую вы хотите выставить на продажу свой ГХ.", 0, true);
4791+ }
4792+ }
4793+ else
4794+ {
4795+ player->GetSession()->SendNotification("Свободных мест нет!");
4796+ player->CLOSE_GOSSIP_MENU();
4797+ return false;
4798+ }
4799+ }
4800+ std::ostringstream tpd;
4801+ tpd << "|TInterface/ICONS/Spell_Arcane_TeleportThunderBluff:32:32:-18:0|tТелепорт в Дом своей гильдии";
4802+ QueryResult result5 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
4803+ if (result5) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, tpd.str(), GOSSIP_SENDER_MAIN, 3);
4804+
4805+ std::ostringstream vxd;
4806+ vxd << "|TInterface/ICONS/Spell_ChargeNegative:32:32:-18:0|tВыход";
4807+
4808+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
4809+ }
4810+ else
4811+ {
4812+ player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
4813+ return false;
4814+ }
4815+ player->SEND_GOSSIP_MENU(55001, creature->GetGUID());
4816+
4817+ return true;
4818+ }
4819+
4820+ void SellGuildHouse(Player* player, Creature* creature, char const* code)
4821+ {
4822+ player->PlayerTalkClass->ClearMenus();
4823+ uint32 cost = atoi(code);
4824+ if (uint32 guild = player->GetGuildId())
4825+ {
4826+ QueryResult haveGH = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE guild = %u", guild);
4827+ if (haveGH)
4828+ {
4829+ Field* fields = haveGH->Fetch();
4830+ const char* name = fields[0].GetCString();
4831+ CharacterDatabase.PQuery("UPDATE guildhouses SET guild = 0, sellerGuild=%u, cost=%u WHERE guild = %u", guild, cost, guild);
4832+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВы выставили на продажу свой Дом Гильдии за %u опыта гильдии|r", cost);
4833+ }
4834+ }
4835+ player->CLOSE_GOSSIP_MENU();
4836+ }
4837+
4838+ bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
4839+ {
4840+ if (action == 6) SellGuildHouse(player, creature, code);
4841+
4842+ return true;
4843+ }
4844+
4845+ void LookGuildHouses(Player* player, Creature* creature)
4846+ {
4847+ player->PlayerTalkClass->ClearMenus();
4848+ player->ADD_GOSSIP_ITEM(4, "Список доступных ГХ:", GOSSIP_SENDER_MAIN, 200);
4849+ QueryResult result = CharacterDatabase.PQuery("SELECT name, x, y, z, radius, cost, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
4850+ if (result)
4851+ {
4852+ float x, y, z, radius;
4853+ uint32 cost, number, number_2;
4854+ const char* name;
4855+ uint16 go = 0;
4856+ do
4857+ {
4858+ Field* fields = result->Fetch();
4859+ name = fields[0].GetCString();
4860+ x = fields[1].GetFloat();
4861+ y = fields[2].GetFloat();
4862+ z = fields[3].GetFloat();
4863+ radius = fields[4].GetFloat();
4864+ cost = fields[5].GetUInt32();
4865+ number = fields[6].GetUInt32();
4866+ number_2 = fields[7].GetUInt32();
4867+
4868+ if (go == 30)
4869+ {
4870+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 101);
4871+ break;
4872+ }
4873+
4874+ std::stringstream buffer;
4875+
4876+ if (i == 1) buffer << "Посмотреть ГХ: " << "|cff177245" << name << "|r";
4877+ else buffer << "Купить ГХ: " << "|cff177245" << name << "|r" << ". Цена: " << "|cffE024B4" << cost << " опыта" << "|r";
4878+ if (i == 1) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
4879+ if (i == 2) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number_2);
4880+
4881+ go++;
4882+ } while (result->NextRow());
4883+ }
4884+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
4885+ }
4886+
4887+ void LookGuildHouses2(Player* player, Creature* creature)
4888+ {
4889+ player->PlayerTalkClass->ClearMenus();
4890+ player->ADD_GOSSIP_ITEM(4, "Список доступных ГХ:", GOSSIP_SENDER_MAIN, 201);
4891+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 100);
4892+ QueryResult result = CharacterDatabase.PQuery("SELECT name, x, y, z, radius, cost, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
4893+ if (result)
4894+ {
4895+ float x, y, z, radius;
4896+ uint32 cost, number, number_2;
4897+ const char* name;
4898+ uint16 go = 0;
4899+ do
4900+ {
4901+ if (go < 30)
4902+ {
4903+ go++;
4904+ continue;
4905+ }
4906+ Field* fields = result->Fetch();
4907+ name = fields[0].GetCString();
4908+ x = fields[1].GetFloat();
4909+ y = fields[2].GetFloat();
4910+ z = fields[3].GetFloat();
4911+ radius = fields[4].GetFloat();
4912+ cost = fields[5].GetUInt32();
4913+ number = fields[6].GetUInt32();
4914+ number_2 = fields[7].GetUInt32();
4915+
4916+ if (go == 60) break;
4917+
4918+ std::stringstream buffer;
4919+ if (i == 1) buffer << "Посмотреть ГХ: " << "|cff177245" << name << "|r";
4920+ else buffer << "Купить ГХ: " << "|cff177245" << name << "|r" << ". Цена: " << "|cffE024B4" << cost << " опыта" << "|r";
4921+ if (i == 1) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
4922+ if (i == 2) player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number_2);
4923+
4924+ go++;
4925+ } while (result->NextRow());
4926+ }
4927+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
4928+ }
4929+
4930+ uint8 i;
4931+
4932+ bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
4933+ {
4934+ switch (action)
4935+ {
4936+ case 1:
4937+ i = 1;
4938+ LookGuildHouses(player, creature);
4939+ break;
4940+ case 2:
4941+ i = 2;
4942+ LookGuildHouses(player, creature);
4943+ break;
4944+ case 3:
4945+ TeleportToGH(player);
4946+ break;
4947+ case 100:
4948+ LookGuildHouses(player, creature);
4949+ break;
4950+ case 101:
4951+ LookGuildHouses2(player, creature);
4952+ break;
4953+ case 4:
4954+ player->CLOSE_GOSSIP_MENU();
4955+ break;
4956+ case 200:
4957+ LookGuildHouses(player, creature);
4958+ break;
4959+ case 201:
4960+ LookGuildHouses2(player, creature);
4961+ break;
4962+ }
4963+ if (i == 1) TeleportToLook(player, action);
4964+ if (i == 2) BuyGuildHouse(player, action);
4965+ return true;
4966+ }
4967+
4968+ void BuyGuildHouse(Player* player, uint32 action)
4969+ {
4970+ QueryResult result = CharacterDatabase.PQuery("SELECT number2, cost, name, sellerGuild FROM guildhouses WHERE guild = 0 ORDER BY cost");
4971+ if (result)
4972+ {
4973+ uint16 level;
4974+ uint32 number_2, cost, xp, sellerGuild;
4975+ uint32 guild = player->GetGuildId();
4976+ std::string name;
4977+ do
4978+ {
4979+ Field* fields = result->Fetch();
4980+ number_2 = fields[0].GetUInt32();
4981+ cost = fields[1].GetUInt32();
4982+ name = fields[2].GetString();
4983+ sellerGuild = fields[3].GetUInt32();
4984+
4985+ if (action == number_2)
4986+ {
4987+
4988+ QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
4989+ if (result2)
4990+ {
4991+ Field *fields = result2->Fetch();
4992+ level = fields[0].GetUInt16();
4993+ xp = fields[1].GetUInt32();
4994+
4995+
4996+ QueryResult existGuild = CharacterDatabase.PQuery("SELECT xp FROM guild_level WHERE guild = %u", sellerGuild);
4997+ if (existGuild && sellerGuild != 0)
4998+ {
4999+ CharacterDatabase.PQuery("UPDATE guild_level SET xp=xp+%u WHERE guild = %u", cost, sellerGuild);
5000+
5001+ QueryResult upd = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", sellerGuild);
5002+ if (upd)
5003+ {
5004+ Field *upt = upd->Fetch();
5005+ uint16 level = upt[0].GetUInt16();
5006+ uint32 sellerXp = upt[1].GetUInt32();
5007+
5008+ QueryResult knowLevel = CharacterDatabase.PQuery("SELECT level FROM guild_xp_table WHERE xp > %u", sellerXp);
5009+ if (knowLevel)
5010+ {
5011+ Field *kl = knowLevel->Fetch();
5012+ uint16 gLevel = kl[0].GetUInt16();
5013+ CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u", gLevel, sellerGuild);
5014+ }
5015+
5016+ }
5017+
5018+ sGuildMgr->LoadGuilds();
5019+
5020+ //ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВаша гильдия получает %u опыта за успешную продажу ГХ. Поздравляем!|r", sellerCost);
5021+ }
5022+
5023+ if (xp >= cost)
5024+ {
5025+ CharacterDatabase.PQuery("UPDATE guildhouses SET guild = %u WHERE number2 = %u", guild, number_2);
5026+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
5027+ if (!player->HasSpell(69541)) player->learnSpell(69541, false);
5028+ UpdateLevel(player);
5029+ player->GetSession()->SendAreaTriggerMessage("Место для дома гильдии куплено!");
5030+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВы купили место для дома гильдии. |r");
5031+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eЧтобы начать его обустраивать вызовите пандарена-монаха из списка небоевых спутников.|r");
5032+ player->CLOSE_GOSSIP_MENU();
5033+ break;
5034+ }
5035+ else
5036+ {
5037+ player->GetSession()->SendNotification("Недостаточно опыта гильдии!");
5038+ player->CLOSE_GOSSIP_MENU();
5039+ break;
5040+ }
5041+ }
5042+ }
5043+ } while (result->NextRow());
5044+ }
5045+ }
5046+
5047+
5048+
5049+ void TeleportToGH(Player* player)
5050+ {
5051+ uint32 guild = player->GetGuildId();
5052+ QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map FROM guildhouses WHERE guild = %u", guild);
5053+ if (result)
5054+ {
5055+ float x, y, z;
5056+ uint32 map;
5057+ std::string name;
5058+
5059+ Field* fields = result->Fetch();
5060+ x = fields[0].GetFloat();
5061+ y = fields[1].GetFloat();
5062+ z = fields[2].GetFloat();
5063+ map = fields[3].GetUInt32();
5064+
5065+ player->TeleportTo(map, x, y, z, 0.0f, 0U);
5066+ player->RemoveSpellCooldown(8690, true);
5067+ player->SetPhaseMask(1, true);
5068+ }
5069+ }
5070+
5071+ void TeleportToLook(Player* player, uint32 action)
5072+ {
5073+ QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map, number, number2 FROM guildhouses WHERE guild = 0 ORDER BY cost");
5074+ if (result)
5075+ {
5076+ float x, y, z;
5077+ uint32 number, map;
5078+ std::string name;
5079+ do
5080+ {
5081+ Field* fields = result->Fetch();
5082+ x = fields[0].GetFloat();
5083+ y = fields[1].GetFloat();
5084+ z = fields[2].GetFloat();
5085+ map = fields[3].GetUInt32();
5086+ number = fields[4].GetUInt32();
5087+
5088+ if (action == number)
5089+ {
5090+ player->SaveRecallPosition();
5091+ player->TeleportTo(map, x, y, z, 0.0f, 0U);
5092+ player->RemoveArenaSpellCooldowns();
5093+ player->RemoveSpellCooldown(8690, true);
5094+ player->SetPhaseMask(1, true);
5095+ if (!player->HasSpell(69541)) player->learnSpell(69541, false);
5096+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eВы решили посмотреть место для дома гильдии.|r");
5097+ ChatHandler(player->GetSession()).PSendSysMessage("|cfff4b25eЧтобы телепортироваться обратно вызовите пандарена-монаха из списка небоевых спутников|r");
5098+ break;
5099+ }
5100+
5101+ } while (result->NextRow());
5102+ }
5103+ }
5104+
5105+};
5106+
5107+class npc_guildhouse_builder : public CreatureScript
5108+
5109+{
5110+
5111+public:
5112+
5113+ npc_guildhouse_builder() : CreatureScript("npc_guildhouse_builder") {}
5114+
5115+
5116+ bool OnGossipHello(Player* player, Creature* creature) {
5117+ player->PlayerTalkClass->ClearMenus();
5118+ if (uint32 guild = player->GetGuildId()) {
5119+ if (player->GetRankFromDB(player->GetGUID()) == 0) {
5120+ QueryResult haveGuildHouse = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE guild = %u", guild);
5121+ if (haveGuildHouse)
5122+ {
5123+ QueryResult result5 = CharacterDatabase.PQuery("SELECT guild FROM guildhouses WHERE guild = %u", guild);
5124+ std::ostringstream pnp;
5125+ pnp << "|TInterface/ICONS/Spell_Holy_Rapture:32:32:-18:0|tПоставить НПС";
5126+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, pnp.str(), GOSSIP_SENDER_MAIN, 8);
5127+ std::ostringstream pob;
5128+ pob << "|TInterface/ICONS/Spell_Nature_NullWard:32:32:-18:0|tПоставить объект";
5129+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, pob.str(), GOSSIP_SENDER_MAIN, 1);
5130+ std::ostringstream dnpc;
5131+ dnpc << "|TInterface/ICONS/Spell_Shadow_DeathScream:32:32:-18:0|tУдалить поставленного НПС";
5132+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, dnpc.str(), GOSSIP_SENDER_MAIN, 9);
5133+ std::ostringstream danpc;
5134+ danpc << "|TInterface/ICONS/Spell_Shadow_DeadofNight:32:32:-18:0|tУдалить всех НПС в Доме Гильдии";
5135+ player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, danpc.str(), GOSSIP_SENDER_MAIN, 11, "Вы действительно хотите удалить всех НПС? Введите 123 для удаления!", 0, true);
5136+ std::ostringstream dobj;
5137+ dobj << "|TInterface/ICONS/Spell_Shadow_FingerOfDeath:32:32:-18:0|tУдалить ближайший объект";
5138+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, dobj.str(), GOSSIP_SENDER_MAIN, 2);
5139+ std::ostringstream daobj;
5140+ daobj << "|TInterface/ICONS/Spell_Shadow_GrimWard:32:32:-18:0|tУдалить все объекты в Доме Гильдии";
5141+ player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_BATTLE, daobj.str(), GOSSIP_SENDER_MAIN, 3, "Вы действительно хотите удалить все объекты? Введите 123 для удаления!", 0, true);
5142+ std::ostringstream prad;
5143+ prad << "|TInterface/ICONS/Spell_ChargePositive:32:32:-18:0|tРасширить радиус ГХ на 10 ярдов(500 опыта)";
5144+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, prad.str(), GOSSIP_SENDER_MAIN, 5);
5145+ std::ostringstream zst;
5146+ zst << "|TInterface/ICONS/Spell_Fire_FelHellfire:32:32:-18:0|tЗАСТРЯЛ!";
5147+ if (result5) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, zst.str(), GOSSIP_SENDER_MAIN, 7);
5148+ }
5149+ else player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Телепортироваться обратно", GOSSIP_SENDER_MAIN, 15);
5150+ }
5151+ }
5152+ else
5153+ {
5154+ player->SEND_GOSSIP_MENU(55004, creature->GetGUID());
5155+ return false;
5156+ }
5157+ std::ostringstream vxd;
5158+ vxd << "|TInterface/ICONS/Spell_ChargeNegative:32:32:-18:0|tВыход";
5159+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, vxd.str(), GOSSIP_SENDER_MAIN, 4);
5160+ player->SEND_GOSSIP_MENU(55002, creature->GetGUID());
5161+
5162+ return true;
5163+ }
5164+
5165+ void AddGobject1(Player* player, Creature* creature)
5166+ {
5167+ player->PlayerTalkClass->ClearMenus();
5168+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5169+ if (result)
5170+ {
5171+ const char* name;
5172+ uint32 cost, number;
5173+ uint16 go = 0;
5174+ do
5175+ {
5176+ Field* fields = result->Fetch();
5177+ name = fields[0].GetCString();
5178+ cost = fields[1].GetUInt32();
5179+ number = fields[2].GetUInt32();
5180+ if (go == 30)
5181+ {
5182+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 101);
5183+ break;
5184+ }
5185+
5186+ std::stringstream buffer;
5187+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5188+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5189+ go++;
5190+ } while (result->NextRow());
5191+ }
5192+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5193+ }
5194+
5195+ void AddGobject2(Player* player, Creature* creature)
5196+ {
5197+ player->PlayerTalkClass->ClearMenus();
5198+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 100);
5199+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5200+ if (result)
5201+ {
5202+ const char* name;
5203+ uint32 cost, number;
5204+ uint16 go = 0;
5205+ do
5206+ {
5207+ if (go < 30)
5208+ {
5209+ go++;
5210+ continue;
5211+ }
5212+ Field* fields = result->Fetch();
5213+ name = fields[0].GetCString();
5214+ cost = fields[1].GetUInt32();
5215+ number = fields[2].GetUInt32();
5216+
5217+ if (go == 60)
5218+ {
5219+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 102);
5220+ break;
5221+ }
5222+
5223+ std::stringstream buffer;
5224+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5225+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5226+ go++;
5227+ } while (result->NextRow());
5228+ }
5229+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5230+
5231+ }
5232+
5233+ void AddGobject3(Player* player, Creature* creature)
5234+ {
5235+ player->PlayerTalkClass->ClearMenus();
5236+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 101);
5237+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5238+ if (result)
5239+ {
5240+ const char* name;
5241+ uint32 cost, number;
5242+ uint16 go = 0;
5243+ do
5244+ {
5245+ if (go < 60)
5246+ {
5247+ go++;
5248+ continue;
5249+ }
5250+ Field* fields = result->Fetch();
5251+ name = fields[0].GetCString();
5252+ cost = fields[1].GetUInt32();
5253+ number = fields[2].GetUInt32();
5254+
5255+ if (go == 90)
5256+ {
5257+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 103);
5258+ break;
5259+ }
5260+
5261+ std::stringstream buffer;
5262+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5263+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5264+ go++;
5265+ } while (result->NextRow());
5266+ }
5267+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5268+
5269+ }
5270+
5271+ void AddGobject4(Player* player, Creature* creature)
5272+ {
5273+ player->PlayerTalkClass->ClearMenus();
5274+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 102);
5275+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5276+
5277+ if (result)
5278+ {
5279+ const char* name;
5280+ uint32 cost, number;
5281+ uint16 go = 0;
5282+ do
5283+ {
5284+ if (go < 90)
5285+ {
5286+ go++;
5287+ continue;
5288+ }
5289+ Field* fields = result->Fetch();
5290+ name = fields[0].GetCString();
5291+ cost = fields[1].GetUInt32();
5292+ number = fields[2].GetUInt32();
5293+
5294+ if (go == 120)
5295+ {
5296+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 104);
5297+ break;
5298+ }
5299+
5300+ std::stringstream buffer;
5301+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5302+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5303+ go++;
5304+ } while (result->NextRow());
5305+ }
5306+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5307+
5308+ }
5309+
5310+ void AddGobject5(Player* player, Creature* creature)
5311+ {
5312+ player->PlayerTalkClass->ClearMenus();
5313+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 103);
5314+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5315+
5316+ if (result)
5317+ {
5318+ const char* name;
5319+ uint32 cost, number;
5320+ uint16 go = 0;
5321+ do
5322+ {
5323+ if (go < 120)
5324+ {
5325+ go++;
5326+ continue;
5327+ }
5328+ Field* fields = result->Fetch();
5329+ name = fields[0].GetCString();
5330+ cost = fields[1].GetUInt32();
5331+ number = fields[2].GetUInt32();
5332+
5333+ if (go == 150)
5334+ {
5335+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 105);
5336+ break;
5337+ }
5338+
5339+ std::stringstream buffer;
5340+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5341+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5342+ go++;
5343+ } while (result->NextRow());
5344+ }
5345+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5346+
5347+ }
5348+
5349+ void AddGobject6(Player* player, Creature* creature)
5350+ {
5351+ player->PlayerTalkClass->ClearMenus();
5352+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 104);
5353+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5354+
5355+ if (result)
5356+ {
5357+ const char* name;
5358+ uint32 cost, number;
5359+ uint16 go = 0;
5360+ do
5361+ {
5362+ if (go < 150)
5363+ {
5364+ go++;
5365+ continue;
5366+ }
5367+ Field* fields = result->Fetch();
5368+ name = fields[0].GetCString();
5369+ cost = fields[1].GetUInt32();
5370+ number = fields[2].GetUInt32();
5371+
5372+ if (go == 180)
5373+ {
5374+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 106);
5375+ break;
5376+ }
5377+
5378+ std::stringstream buffer;
5379+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5380+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5381+ go++;
5382+ } while (result->NextRow());
5383+ }
5384+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5385+
5386+ }
5387+
5388+ void AddGobject7(Player* player, Creature* creature)
5389+ {
5390+ player->PlayerTalkClass->ClearMenus();
5391+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 105);
5392+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5393+
5394+ if (result)
5395+ {
5396+ const char* name;
5397+ uint32 cost, number;
5398+ uint16 go = 0;
5399+ do
5400+ {
5401+ if (go < 180)
5402+ {
5403+ go++;
5404+ continue;
5405+ }
5406+ Field* fields = result->Fetch();
5407+ name = fields[0].GetCString();
5408+ cost = fields[1].GetUInt32();
5409+ number = fields[2].GetUInt32();
5410+
5411+ if (go == 210)
5412+ {
5413+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 107);
5414+ break;
5415+ }
5416+
5417+ std::stringstream buffer;
5418+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5419+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5420+ go++;
5421+ } while (result->NextRow());
5422+ }
5423+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5424+
5425+ }
5426+
5427+ void AddGobject8(Player* player, Creature* creature)
5428+ {
5429+ player->PlayerTalkClass->ClearMenus();
5430+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 106);
5431+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5432+
5433+ if (result)
5434+ {
5435+ const char* name;
5436+ uint32 cost, number;
5437+ uint16 go = 0;
5438+ do
5439+ {
5440+ if (go < 210)
5441+ {
5442+ go++;
5443+ continue;
5444+ }
5445+ Field* fields = result->Fetch();
5446+ name = fields[0].GetCString();
5447+ cost = fields[1].GetUInt32();
5448+ number = fields[2].GetUInt32();
5449+
5450+ if (go == 240)
5451+ {
5452+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 108);
5453+ break;
5454+ }
5455+
5456+ std::stringstream buffer;
5457+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5458+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5459+ go++;
5460+ } while (result->NextRow());
5461+ }
5462+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5463+
5464+ }
5465+
5466+ void AddGobject9(Player* player, Creature* creature)
5467+ {
5468+ player->PlayerTalkClass->ClearMenus();
5469+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 107);
5470+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5471+
5472+ if (result)
5473+ {
5474+ const char* name;
5475+ uint32 cost, number;
5476+ uint16 go = 0;
5477+ do
5478+ {
5479+ if (go < 240)
5480+ {
5481+ go++;
5482+ continue;
5483+ }
5484+ Field* fields = result->Fetch();
5485+ name = fields[0].GetCString();
5486+ cost = fields[1].GetUInt32();
5487+ number = fields[2].GetUInt32();
5488+
5489+ if (go == 270)
5490+ {
5491+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 109);
5492+ break;
5493+ }
5494+
5495+ std::stringstream buffer;
5496+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5497+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5498+ go++;
5499+ } while (result->NextRow());
5500+ }
5501+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5502+
5503+ }
5504+
5505+ void AddGobject10(Player* player, Creature* creature)
5506+ {
5507+ player->PlayerTalkClass->ClearMenus();
5508+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 108);
5509+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_go ORDER BY name");
5510+
5511+ if (result)
5512+ {
5513+ const char* name;
5514+ uint32 cost, number;
5515+ uint16 go = 0;
5516+ do
5517+ {
5518+ if (go < 270)
5519+ {
5520+ go++;
5521+ continue;
5522+ }
5523+ Field* fields = result->Fetch();
5524+ name = fields[0].GetCString();
5525+ cost = fields[1].GetUInt32();
5526+ number = fields[2].GetUInt32();
5527+
5528+ if (go == 300) break;
5529+
5530+ std::stringstream buffer;
5531+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5532+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5533+ go++;
5534+ } while (result->NextRow());
5535+ }
5536+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5537+
5538+ }
5539+
5540+
5541+ void AddNPC1(Player* player, Creature* creature)
5542+ {
5543+ player->PlayerTalkClass->ClearMenus();
5544+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5545+
5546+ if (result)
5547+ {
5548+ const char* name;
5549+ uint32 cost, number;
5550+ uint16 go = 0;
5551+ do
5552+ {
5553+ Field* fields = result->Fetch();
5554+ name = fields[0].GetCString();
5555+ cost = fields[1].GetUInt32();
5556+ number = fields[2].GetUInt32();
5557+ if (go == 30)
5558+ {
5559+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 151);
5560+ break;
5561+ }
5562+
5563+ std::stringstream buffer;
5564+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5565+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5566+ go++;
5567+ } while (result->NextRow());
5568+ }
5569+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5570+ }
5571+
5572+
5573+
5574+ void AddNPC2(Player* player, Creature* creature)
5575+ {
5576+ player->PlayerTalkClass->ClearMenus();
5577+ //player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 150);
5578+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5579+
5580+ if (result)
5581+ {
5582+ const char* name;
5583+ uint32 cost, number;
5584+ uint16 go = 0;
5585+ do
5586+ {
5587+ if (go < 30)
5588+ {
5589+ go++;
5590+ continue;
5591+ }
5592+ Field* fields = result->Fetch();
5593+ name = fields[0].GetCString();
5594+ cost = fields[1].GetUInt32();
5595+ number = fields[2].GetUInt32();
5596+
5597+ if (go == 60)
5598+ {
5599+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 152);
5600+ break;
5601+ }
5602+
5603+ std::stringstream buffer;
5604+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5605+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5606+ go++;
5607+ } while (result->NextRow());
5608+ }
5609+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5610+
5611+ }
5612+
5613+ void AddNPC3(Player* player, Creature* creature)
5614+ {
5615+ player->PlayerTalkClass->ClearMenus();
5616+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 151);
5617+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5618+
5619+ if (result)
5620+ {
5621+ const char* name;
5622+ uint32 cost, number;
5623+ uint16 go = 0;
5624+ do
5625+ {
5626+ if (go < 60)
5627+ {
5628+ go++;
5629+ continue;
5630+ }
5631+ Field* fields = result->Fetch();
5632+ name = fields[0].GetCString();
5633+ cost = fields[1].GetUInt32();
5634+ number = fields[2].GetUInt32();
5635+
5636+ if (go == 90)
5637+ {
5638+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 153);
5639+ break;
5640+ }
5641+
5642+ std::stringstream buffer;
5643+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5644+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5645+ go++;
5646+ } while (result->NextRow());
5647+ }
5648+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5649+
5650+ }
5651+
5652+ void AddNPC4(Player* player, Creature* creature)
5653+ {
5654+ player->PlayerTalkClass->ClearMenus();
5655+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 152);
5656+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5657+
5658+ if (result)
5659+ {
5660+ const char* name;
5661+ uint32 cost, number;
5662+ uint16 go = 0;
5663+ do
5664+ {
5665+ if (go < 90)
5666+ {
5667+ go++;
5668+ continue;
5669+ }
5670+ Field* fields = result->Fetch();
5671+ name = fields[0].GetCString();
5672+ cost = fields[1].GetUInt32();
5673+ number = fields[2].GetUInt32();
5674+
5675+ if (go == 120)
5676+ {
5677+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 154);
5678+ break;
5679+ }
5680+
5681+ std::stringstream buffer;
5682+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5683+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5684+ go++;
5685+ } while (result->NextRow());
5686+ }
5687+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5688+
5689+ }
5690+
5691+ void AddNPC5(Player* player, Creature* creature)
5692+ {
5693+ player->PlayerTalkClass->ClearMenus();
5694+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 153);
5695+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5696+
5697+ if (result)
5698+ {
5699+ const char* name;
5700+ uint32 cost, number;
5701+ uint16 go = 0;
5702+ do
5703+ {
5704+ if (go < 120)
5705+ {
5706+ go++;
5707+ continue;
5708+ }
5709+ Field* fields = result->Fetch();
5710+ name = fields[0].GetCString();
5711+ cost = fields[1].GetUInt32();
5712+ number = fields[2].GetUInt32();
5713+
5714+ if (go == 150)
5715+ {
5716+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 155);
5717+ break;
5718+ }
5719+
5720+ std::stringstream buffer;
5721+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5722+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5723+ go++;
5724+ } while (result->NextRow());
5725+ }
5726+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5727+
5728+ }
5729+
5730+ void AddNPC6(Player* player, Creature* creature)
5731+ {
5732+ player->PlayerTalkClass->ClearMenus();
5733+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 154);
5734+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5735+
5736+ if (result)
5737+ {
5738+ const char* name;
5739+ uint32 cost, number;
5740+ uint16 go = 0;
5741+ do
5742+ {
5743+ if (go < 150)
5744+ {
5745+ go++;
5746+ continue;
5747+ }
5748+ Field* fields = result->Fetch();
5749+ name = fields[0].GetCString();
5750+ cost = fields[1].GetUInt32();
5751+ number = fields[2].GetUInt32();
5752+
5753+ if (go == 180)
5754+ {
5755+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 156);
5756+ break;
5757+ }
5758+
5759+ std::stringstream buffer;
5760+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5761+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5762+ go++;
5763+ } while (result->NextRow());
5764+ }
5765+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5766+
5767+ }
5768+
5769+ void AddNPC7(Player* player, Creature* creature)
5770+ {
5771+ player->PlayerTalkClass->ClearMenus();
5772+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 155);
5773+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5774+
5775+ if (result)
5776+ {
5777+ const char* name;
5778+ uint32 cost, number;
5779+ uint16 go = 0;
5780+ do
5781+ {
5782+ if (go < 180)
5783+ {
5784+ go++;
5785+ continue;
5786+ }
5787+ Field* fields = result->Fetch();
5788+ name = fields[0].GetCString();
5789+ cost = fields[1].GetUInt32();
5790+ number = fields[2].GetUInt32();
5791+
5792+ if (go == 210)
5793+ {
5794+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 157);
5795+ break;
5796+ }
5797+
5798+ std::stringstream buffer;
5799+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5800+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5801+ go++;
5802+ } while (result->NextRow());
5803+ }
5804+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5805+
5806+ }
5807+
5808+ void AddNPC8(Player* player, Creature* creature)
5809+ {
5810+ player->PlayerTalkClass->ClearMenus();
5811+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 156);
5812+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5813+
5814+ if (result)
5815+ {
5816+ const char* name;
5817+ uint32 cost, number;
5818+ uint16 go = 0;
5819+ do
5820+ {
5821+ if (go < 210)
5822+ {
5823+ go++;
5824+ continue;
5825+ }
5826+ Field* fields = result->Fetch();
5827+ name = fields[0].GetCString();
5828+ cost = fields[1].GetUInt32();
5829+ number = fields[2].GetUInt32();
5830+
5831+ if (go == 240)
5832+ {
5833+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 158);
5834+ break;
5835+ }
5836+
5837+ std::stringstream buffer;
5838+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5839+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5840+ go++;
5841+ } while (result->NextRow());
5842+ }
5843+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5844+
5845+ }
5846+
5847+ void AddNPC9(Player* player, Creature* creature)
5848+ {
5849+ player->PlayerTalkClass->ClearMenus();
5850+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 157);
5851+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5852+
5853+ if (result)
5854+ {
5855+ const char* name;
5856+ uint32 cost, number;
5857+ uint16 go = 0;
5858+ do
5859+ {
5860+ if (go < 240)
5861+ {
5862+ go++;
5863+ continue;
5864+ }
5865+ Field* fields = result->Fetch();
5866+ name = fields[0].GetCString();
5867+ cost = fields[1].GetUInt32();
5868+ number = fields[2].GetUInt32();
5869+
5870+ if (go == 270)
5871+ {
5872+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Дальше", GOSSIP_SENDER_MAIN, 159);
5873+ break;
5874+ }
5875+
5876+ std::stringstream buffer;
5877+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5878+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5879+ go++;
5880+ } while (result->NextRow());
5881+ }
5882+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5883+
5884+ }
5885+
5886+ void AddNPC10(Player* player, Creature* creature)
5887+ {
5888+ player->PlayerTalkClass->ClearMenus();
5889+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "<= Назад", GOSSIP_SENDER_MAIN, 158);
5890+ QueryResult result = CharacterDatabase.PQuery("SELECT name, cost, number FROM guildhouse_npc ORDER BY name");
5891+
5892+ if (result)
5893+ {
5894+ const char* name;
5895+ uint32 cost, number;
5896+ uint16 go = 0;
5897+ do
5898+ {
5899+ if (go < 270)
5900+ {
5901+ go++;
5902+ continue;
5903+ }
5904+ Field* fields = result->Fetch();
5905+ name = fields[0].GetCString();
5906+ cost = fields[1].GetUInt32();
5907+ number = fields[2].GetUInt32();
5908+
5909+ if (go == 300) break;
5910+
5911+ std::stringstream buffer;
5912+ buffer << "Поставить: " << "|cff177245" << name << "|r" << ". Цена: " << "|cff242DFF" << cost << " опыта" << "|r";
5913+ player->ADD_GOSSIP_ITEM(4, buffer.str().c_str(), GOSSIP_SENDER_MAIN, number);
5914+ go++;
5915+ } while (result->NextRow());
5916+ }
5917+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
5918+
5919+ }
5920+
5921+ void PlusRadius(Player* player)
5922+ {
5923+
5924+ uint32 guild = player->GetGuildId();
5925+ QueryResult result15 = CharacterDatabase.PQuery("SELECT * FROM guildhouses WHERE guild = %u", guild);
5926+ if (!result15)
5927+ {
5928+ player->CLOSE_GOSSIP_MENU();
5929+ player->GetSession()->SendNotification("У вас нет Дома Гильдии!");
5930+ return;
5931+ }
5932+ QueryResult result10 = CharacterDatabase.PQuery("SELECT radius FROM guildhouses WHERE guild = %u AND radius >= 80", guild);
5933+ if (result10)
5934+ {
5935+ player->CLOSE_GOSSIP_MENU();
5936+ player->GetSession()->SendNotification("У вас максимальный радиус ГХ!");
5937+ return;
5938+ }
5939+ uint32 xp;
5940+ QueryResult result2 = CharacterDatabase.PQuery("SELECT xp FROM guild_level WHERE guild = %u", guild);
5941+ if (result2)
5942+ {
5943+ Field *fields = result2->Fetch();
5944+ xp = fields[0].GetUInt32();
5945+ }
5946+ if (xp < 500)
5947+ {
5948+ player->CLOSE_GOSSIP_MENU();
5949+ player->GetSession()->SendNotification("Недостаточно гильдейского опыта!");
5950+ return;
5951+ }
5952+ CharacterDatabase.PQuery("UPDATE guildhouses SET radius = radius+10 WHERE guild = %u", guild);
5953+ player->GetSession()->SendAreaTriggerMessage("Радиус вашего дома гильдии расширен на 10 ярдов!");
5954+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp-500 WHERE guild = %u", guild);
5955+
5956+ UpdateLevel(player);
5957+ }
5958+
5959+ uint32 GetGuildhouseNumber(Player* player)
5960+ {
5961+ if (uint32 guild = player->GetGuildId())
5962+ {
5963+ QueryResult result = CharacterDatabase.PQuery("SELECT number FROM guildhouses WHERE guild = %u", guild);
5964+ if (result)
5965+ {
5966+ Field* fields = result->Fetch();
5967+ uint32 number = fields[0].GetUInt32();
5968+ return number;
5969+ }
5970+ }
5971+ return 0;
5972+ }
5973+
5974+ void DeleteAllGobjects(Player* player, Creature* creature, char const* code)
5975+ {
5976+
5977+ uint32 da = atoi(code);
5978+ if (da != 123) return;
5979+ uint32 lowguid;
5980+ uint32 guildhouse = GetGuildhouseNumber(player);
5981+ QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_spawned WHERE guildhouse = %u", guildhouse);
5982+ if (!result)
5983+ {
5984+ player->CLOSE_GOSSIP_MENU();
5985+ player->GetSession()->SendNotification("Вы не поставили не единого объекта!");
5986+ return;
5987+ }
5988+ if (result)
5989+ {
5990+ do
5991+ {
5992+ Field* fields = result->Fetch();
5993+ lowguid = fields[0].GetUInt32();
5994+ if (!lowguid)
5995+ return;
5996+
5997+ GameObject* obj = NULL;
5998+ // by DB guid
5999+ if (GameObjectData const* go_data = sObjectMgr->GetGOData(lowguid))
6000+ obj = ChatHandler(player->GetSession()).GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, go_data->id);
6001+
6002+ if (!obj)
6003+ {
6004+ ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
6005+ ChatHandler(player->GetSession()).SetSentErrorMessage(true);
6006+ return;
6007+ }
6008+
6009+ QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_go WHERE id = %u", obj->GetEntry());
6010+ if (res)
6011+ {
6012+ Field* ff = res->Fetch();
6013+ uint32 cost = ff[0].GetUInt32();
6014+
6015+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u", cost, player->GetGuildId());
6016+ UpdateLevel(player);
6017+ }
6018+
6019+ uint64 owner_guid = obj->GetOwnerGUID();
6020+ if (owner_guid)
6021+ {
6022+ Unit* owner = ObjectAccessor::GetUnit(*ChatHandler(player->GetSession()).GetSession()->GetPlayer(), owner_guid);
6023+ if (!owner || !IS_PLAYER_GUID(owner_guid))
6024+ {
6025+ ChatHandler(player->GetSession()).PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
6026+ ChatHandler(player->GetSession()).SetSentErrorMessage(true);
6027+ return;
6028+ }
6029+
6030+ owner->RemoveGameObject(obj, false);
6031+ }
6032+
6033+ obj->SetRespawnTime(0); // not save respawn time
6034+ obj->Delete();
6035+ obj->DeleteFromDB();
6036+
6037+ player->CLOSE_GOSSIP_MENU();
6038+ } while (result->NextRow());
6039+ CharacterDatabase.PQuery("DELETE FROM guildhouse_spawned WHERE guildhouse = %u", guildhouse);
6040+ ChatHandler(player->GetSession()).PSendSysMessage("Объекты были успешно удалены!");
6041+ }
6042+ }
6043+
6044+ void DeleteAllNPC(Player* player, Creature* creature, char const* code)
6045+ {
6046+
6047+ uint32 da = atoi(code);
6048+ if (da != 123) return;
6049+ uint32 lowguid;
6050+ uint32 guildhouse = GetGuildhouseNumber(player);
6051+ QueryResult result = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_npc_spawned WHERE guildhouse = %u", guildhouse);
6052+ if (!result)
6053+ {
6054+ player->CLOSE_GOSSIP_MENU();
6055+ player->GetSession()->SendNotification("Вы не поставили не единого НПС!");
6056+ return;
6057+ }
6058+ if (result)
6059+ {
6060+ do
6061+ {
6062+ Field* fields = result->Fetch();
6063+ lowguid = fields[0].GetUInt32();
6064+ if (!lowguid) return;
6065+ Creature* unit = NULL;
6066+ if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid))
6067+ unit = player->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT));
6068+
6069+ QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_npc WHERE id = %u", unit->GetEntry());
6070+ if (res)
6071+ {
6072+ Field* ff = res->Fetch();
6073+ uint32 cost = ff[0].GetUInt32();
6074+
6075+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u", cost, player->GetGuildId());
6076+ UpdateLevel(player);
6077+ }
6078+
6079+ if (!unit || unit->IsPet() || unit->IsTotem()) return;
6080+
6081+ // Delete the creature
6082+ unit->CombatStop();
6083+ unit->DeleteFromDB();
6084+ unit->AddObjectToRemoveList();
6085+ CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE guid = %u", lowguid);
6086+
6087+ player->GetSession()->SendAreaTriggerMessage("НПС успешно удален!");
6088+
6089+ player->CLOSE_GOSSIP_MENU();
6090+ } while (result->NextRow());
6091+ CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE guildhouse = %u", guildhouse);
6092+ ChatHandler(player->GetSession()).PSendSysMessage("НПС были успешно удалены!");
6093+ }
6094+ }
6095+
6096+ void DeleteNPC(Player* player, Creature* creature)
6097+ {
6098+
6099+ Creature* unit = player->GetSelectedUnit()->ToCreature();
6100+
6101+ uint32 guildhouse = GetGuildhouseNumber(player);
6102+ uint64 lowguid = unit->GetGUIDLow();;
6103+
6104+
6105+ QueryResult result = CharacterDatabase.PQuery("SELECT guid, guildhouse FROM guildhouse_npc_spawned WHERE guildhouse = %u AND guid = %u", guildhouse, lowguid);
6106+ if (!result)
6107+ {
6108+ player->CLOSE_GOSSIP_MENU();
6109+ player->GetSession()->SendNotification("НПС с таким номером не найден!", lowguid, guildhouse);
6110+ return;
6111+ }
6112+
6113+ if (!unit || unit->IsPet() || unit->IsTotem()) return;
6114+
6115+ QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_npc WHERE id = %u", unit->GetEntry());
6116+ if (res)
6117+ {
6118+ Field* ff = res->Fetch();
6119+ uint32 cost = ff[0].GetUInt32();
6120+
6121+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u", cost, player->GetGuildId());
6122+ UpdateLevel(player);
6123+ }
6124+
6125+ // Delete the creature
6126+ unit->CombatStop();
6127+ unit->DeleteFromDB();
6128+ unit->AddObjectToRemoveList();
6129+ CharacterDatabase.PQuery("DELETE FROM guildhouse_npc_spawned WHERE guid = %u", lowguid);
6130+
6131+ player->GetSession()->SendAreaTriggerMessage("НПС успешно удален!");
6132+ player->CLOSE_GOSSIP_MENU();
6133+ }
6134+
6135+ void ActivateGobject(Player* player, Creature* creature)
6136+ {
6137+ QueryResult result;
6138+ GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr->GetActiveEventList();
6139+
6140+ std::ostringstream eventFilter;
6141+ eventFilter << " AND (eventEntry IS NULL ";
6142+ bool initString = true;
6143+
6144+ for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
6145+ {
6146+ if (initString)
6147+ {
6148+ eventFilter << "OR eventEntry IN (" << *itr;
6149+ initString = false;
6150+ }
6151+ else
6152+ eventFilter << ',' << *itr;
6153+ }
6154+
6155+ if (!initString)
6156+ eventFilter << "))";
6157+ else
6158+ eventFilter << ')';
6159+
6160+ result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, "
6161+ "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject "
6162+ "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10",
6163+ player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), eventFilter.str().c_str());
6164+
6165+ if (!result)
6166+ {
6167+ player->GetSession()->SendNotification("Поблизости не найдено объектов вашего Дома Гильдии!");
6168+ return;
6169+ }
6170+
6171+ bool found = false;
6172+ float x, y, z, o;
6173+ uint32 guidLow, id, phase;
6174+ uint16 mapId;
6175+
6176+ do
6177+ {
6178+ Field* fields = result->Fetch();
6179+ guidLow = fields[0].GetUInt32();
6180+ id = fields[1].GetUInt32();
6181+ x = fields[2].GetFloat();
6182+ y = fields[3].GetFloat();
6183+ z = fields[4].GetFloat();
6184+ o = fields[5].GetFloat();
6185+ mapId = fields[6].GetUInt16();
6186+ phase = fields[7].GetUInt32();
6187+ QueryResult result15 = CharacterDatabase.PQuery("SELECT guid FROM guildhouse_spawned WHERE guildhouse = %u AND guid = %u", GetGuildhouseNumber(player), guidLow);
6188+ if (result15) found = true;
6189+ } while (result->NextRow() && !found);
6190+
6191+ if (!found)
6192+ {
6193+ player->GetSession()->SendNotification("Поблизости не найдено объектов вашего Дома Гильдии!");
6194+ return;
6195+ }
6196+
6197+ GameObjectTemplate const* objectInfo = sObjectMgr->GetGameObjectTemplate(id);
6198+
6199+ if (!objectInfo)
6200+ {
6201+ // player->GetSession()->SendNotification(LANG_GAMEOBJECT_NOT_EXIST);
6202+ return;
6203+ }
6204+
6205+ GameObject* target = player->GetMap()->GetGameObject(MAKE_NEW_GUID(guidLow, id, HIGHGUID_GAMEOBJECT));
6206+
6207+ if (target)
6208+ {
6209+ QueryResult res = CharacterDatabase.PQuery("SELECT cost FROM guildhouse_go WHERE id = %u", target->GetEntry());
6210+ if (res)
6211+ {
6212+ Field* ff = res->Fetch();
6213+ uint32 cost = ff[0].GetUInt32();
6214+
6215+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp+%u WHERE guild = %u", cost, player->GetGuildId());
6216+ UpdateLevel(player);
6217+ }
6218+
6219+ target->SetRespawnTime(0);
6220+ target->Delete();
6221+ target->DeleteFromDB();
6222+ player->GetSession()->SendAreaTriggerMessage("Объект успешно удален!");
6223+ CharacterDatabase.PQuery("DELETE FROM guildhouse_spawned WHERE guid = %u AND guildhouse = %u", guidLow, player->GetGUIDLow());
6224+ }
6225+
6226+
6227+
6228+ player->CLOSE_GOSSIP_MENU();
6229+ }
6230+
6231+ void SpawnNPC(Player* player, Creature* creature, uint32 action)
6232+ {
6233+
6234+ uint32 guildhouse = GetGuildhouseNumber(player);
6235+ float x_p, y_p, z_p, radius;
6236+ float p_x = player->GetPositionX();
6237+ float p_y = player->GetPositionY();
6238+ float p_z = player->GetPositionZ();
6239+ uint32 guild = player->GetGuildId();
6240+ QueryResult result = CharacterDatabase.PQuery("SELECT id, number, cost FROM guildhouse_npc ORDER BY cost");
6241+ if (result)
6242+ {
6243+ uint32 number, id, cost, level, xp;
6244+ do
6245+ {
6246+ Field* fields = result->Fetch();
6247+ id = fields[0].GetUInt32();
6248+ number = fields[1].GetUInt32();
6249+ cost = fields[2].GetUInt32();
6250+
6251+ if (action == number)
6252+ {
6253+ QueryResult result10 = CharacterDatabase.PQuery("SELECT x, y, z, radius FROM guildhouses WHERE guild = %u", guild);
6254+ if (result10)
6255+ {
6256+ Field* fields = result10->Fetch();
6257+ x_p = fields[0].GetFloat();
6258+ y_p = fields[1].GetFloat();
6259+ z_p = fields[2].GetFloat();
6260+ radius = fields[3].GetFloat();
6261+ }
6262+ if (!result10)
6263+ {
6264+ player->CLOSE_GOSSIP_MENU();
6265+ player->GetSession()->SendNotification("У вас нет гильдхауса!");
6266+ return;
6267+ }
6268+ if (p_x > x_p + radius || p_x < x_p - radius || p_y > y_p + radius || p_y < y_p - radius || p_z > z_p + radius || p_z < z_p - radius)
6269+ {
6270+ player->CLOSE_GOSSIP_MENU();
6271+ player->GetSession()->SendNotification("Вы не в своем ГХ!");
6272+ return;
6273+ }
6274+
6275+ QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
6276+ if (result2)
6277+ {
6278+ Field* fields = result2->Fetch();
6279+ level = fields[0].GetUInt32();
6280+ xp = fields[1].GetUInt32();
6281+ }
6282+ if (cost > xp)
6283+ {
6284+ player->GetSession()->SendNotification("Недостаточно гильдейского опыта!");
6285+ return;
6286+ }
6287+ Player* chr = player;
6288+ float x = chr->GetPositionX();
6289+ float y = chr->GetPositionY();
6290+ float z = chr->GetPositionZ();
6291+ float o = chr->GetOrientation();
6292+ Map *map = chr->GetMap();
6293+
6294+ Creature* creature1 = new Creature;
6295+ if (!creature1->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, x, y, z, o))
6296+ {
6297+ delete creature1;
6298+ return;
6299+ }
6300+
6301+ creature1->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
6302+
6303+ uint32 db_guid = creature1->GetDBTableGUIDLow();
6304+
6305+ // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
6306+ creature1->LoadFromDB(db_guid, map);
6307+
6308+ map->AddToMap(creature1);
6309+ sObjectMgr->AddCreatureToGrid(db_guid, sObjectMgr->GetCreatureData(db_guid));
6310+
6311+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
6312+
6313+ CharacterDatabase.PQuery("REPLACE INTO guildhouse_npc_spawned (guid, guildhouse) VALUES (%u, %u)", db_guid, guildhouse);
6314+
6315+ UpdateLevel(player);
6316+
6317+ AddNPC1(player, creature);
6318+ break;
6319+ }
6320+
6321+ } while (result->NextRow());
6322+ }
6323+ }
6324+
6325+ void Recall(Player* player)
6326+ {
6327+ player->TeleportTo(player->m_recallMap, player->m_recallX, player->m_recallY, player->m_recallZ, player->m_recallO);
6328+ }
6329+
6330+ void SpawnGobject(Player* player, Creature* creature, uint32 action)
6331+ {
6332+
6333+ uint32 guildhouse = GetGuildhouseNumber(player);
6334+ float x_p, y_p, z_p, radius;
6335+ float p_x = player->GetPositionX();
6336+ float p_y = player->GetPositionY();
6337+ float p_z = player->GetPositionZ();
6338+ uint32 guild = player->GetGuildId();
6339+ QueryResult result = CharacterDatabase.PQuery("SELECT id, number, cost FROM guildhouse_go ORDER BY cost");
6340+ if (result)
6341+ {
6342+ uint32 number, id, cost, level, xp, level_table, xp_table;
6343+ do
6344+ {
6345+ Field* fields = result->Fetch();
6346+ id = fields[0].GetUInt32();
6347+ number = fields[1].GetUInt32();
6348+ cost = fields[2].GetUInt32();
6349+
6350+ if (action == number)
6351+ {
6352+ QueryResult result10 = CharacterDatabase.PQuery("SELECT x, y, z, radius FROM guildhouses WHERE guild = %u", guild);
6353+ if (result10)
6354+ {
6355+ Field* fields = result10->Fetch();
6356+ x_p = fields[0].GetFloat();
6357+ y_p = fields[1].GetFloat();
6358+ z_p = fields[2].GetFloat();
6359+ radius = fields[3].GetFloat();
6360+ }
6361+ if (!result10)
6362+ {
6363+ player->CLOSE_GOSSIP_MENU();
6364+ player->GetSession()->SendNotification("У вас нет гильдхауса!");
6365+ return;
6366+ }
6367+ if (p_x > x_p + radius || p_x < x_p - radius || p_y > y_p + radius || p_y < y_p - radius || p_z > z_p + radius || p_z < z_p - radius)
6368+ {
6369+ player->CLOSE_GOSSIP_MENU();
6370+ player->GetSession()->SendNotification("Вы не в своем ГХ!");
6371+ return;
6372+ }
6373+
6374+ QueryResult result2 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_level WHERE guild = %u", guild);
6375+ if (result2)
6376+ {
6377+ Field* fields = result2->Fetch();
6378+ level = fields[0].GetUInt32();
6379+ xp = fields[1].GetUInt32();
6380+ }
6381+ if (cost > xp)
6382+ {
6383+ player->GetSession()->SendNotification("Недостаточно гильдейского опыта!");
6384+ return;
6385+ }
6386+ const GameObjectTemplate *gInfo = sObjectMgr->GetGameObjectTemplate(id);
6387+ if (!gInfo)
6388+ {
6389+ player->GetSession()->SendNotification("Неверный ID");
6390+ return;
6391+ }
6392+ Player* chr = player;
6393+ float x = float(chr->GetPositionX());
6394+ float y = float(chr->GetPositionY());
6395+ float z = float(chr->GetPositionZ());
6396+ float o = float(chr->GetOrientation());
6397+ Map *map = chr->GetMap();
6398+ GameObject* pGameObj = new GameObject;
6399+ uint32 db_lowGUID = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
6400+ if (!pGameObj->Create(db_lowGUID, gInfo->entry, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
6401+ {
6402+
6403+ delete pGameObj;
6404+ return;
6405+ }
6406+ pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
6407+ if (!pGameObj->LoadFromDB(db_lowGUID, map))
6408+ {
6409+ delete pGameObj;
6410+ return;
6411+ }
6412+ map->AddToMap(pGameObj);
6413+ sObjectMgr->AddGameobjectToGrid(db_lowGUID, sObjectMgr->GetGOData(db_lowGUID));
6414+
6415+ CharacterDatabase.PQuery("UPDATE guild_level SET xp = xp - %u WHERE guild = %u", cost, guild);
6416+
6417+ CharacterDatabase.PQuery("REPLACE INTO guildhouse_spawned (guid, guildhouse) VALUES (%u, %u)", db_lowGUID, guildhouse);
6418+
6419+
6420+ QueryResult result3 = CharacterDatabase.PQuery("SELECT level, xp FROM guild_xp_table ORDER BY xp DESC");
6421+ if (result3)
6422+ {
6423+ do
6424+ {
6425+ Field *fields = result3->Fetch();
6426+ level_table = fields[0].GetUInt32();
6427+ xp_table = fields[1].GetUInt32();
6428+ if ((xp - cost) < xp_table) continue;
6429+ else if ((xp - cost) < 100)
6430+ {
6431+ CharacterDatabase.PQuery("UPDATE guild_level SET level = 1 WHERE guild = %u", guild);
6432+ break;
6433+ }
6434+ else
6435+ {
6436+ CharacterDatabase.PQuery("UPDATE guild_level SET level = %u WHERE guild = %u", level_table, guild);
6437+ break;
6438+ }
6439+ } while (result3->NextRow());
6440+ }
6441+ AddGobject1(player, creature);
6442+ break;
6443+ }
6444+
6445+ } while (result->NextRow());
6446+ }
6447+ }
6448+
6449+ bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
6450+ {
6451+ switch (action)
6452+ {
6453+ case 8:
6454+ AddNPC1(player, creature);
6455+ break;
6456+ case 1:
6457+ AddGobject1(player, creature);
6458+ break;
6459+ case 100:
6460+ AddGobject1(player, creature);
6461+ break;
6462+ case 101:
6463+ AddGobject2(player, creature);
6464+ break;
6465+ case 102:
6466+ AddGobject3(player, creature);
6467+ break;
6468+ case 103:
6469+ AddGobject4(player, creature);
6470+ break;
6471+ case 104:
6472+ AddGobject5(player, creature);
6473+ break;
6474+ case 105:
6475+ AddGobject6(player, creature);
6476+ break;
6477+ case 106:
6478+ AddGobject7(player, creature);
6479+ break;
6480+ case 107:
6481+ AddGobject8(player, creature);
6482+ break;
6483+ case 108:
6484+ AddGobject9(player, creature);
6485+ break;
6486+ case 109:
6487+ AddGobject10(player, creature);
6488+ break;
6489+ case 150:
6490+ AddNPC1(player, creature);
6491+ break;
6492+ case 151:
6493+ AddNPC2(player, creature);
6494+ break;
6495+ case 152:
6496+ AddNPC3(player, creature);
6497+ break;
6498+ case 153:
6499+ AddNPC4(player, creature);
6500+ break;
6501+ case 154:
6502+ AddNPC5(player, creature);
6503+ break;
6504+ case 155:
6505+ AddNPC6(player, creature);
6506+ break;
6507+ case 156:
6508+ AddNPC7(player, creature);
6509+ break;
6510+ case 157:
6511+ AddNPC8(player, creature);
6512+ break;
6513+ case 158:
6514+ AddNPC9(player, creature);
6515+ break;
6516+ case 159:
6517+ AddNPC10(player, creature);
6518+ break;
6519+ case 2:
6520+ ActivateGobject(player, creature);
6521+ break;
6522+ case 4:
6523+ player->CLOSE_GOSSIP_MENU();
6524+ break;
6525+ case 5:
6526+ PlusRadius(player);
6527+ player->CLOSE_GOSSIP_MENU();
6528+ break;
6529+ case 7:
6530+ TeleportToGH(player);
6531+ break;
6532+ case 9:
6533+ DeleteNPC(player, creature);
6534+ break;
6535+ case 15:
6536+ Recall(player);
6537+ break;
6538+ }
6539+ if (action >= 10000) SpawnNPC(player, creature, action);
6540+ else SpawnGobject(player, creature, action);
6541+
6542+ return true;
6543+ }
6544+
6545+ void TeleportToGH(Player* player)
6546+ {
6547+
6548+ uint32 guild = player->GetGuildId();
6549+ QueryResult result = CharacterDatabase.PQuery("SELECT x, y, z, map, radius FROM guildhouses WHERE guild = %u", guild);
6550+ if (result)
6551+ {
6552+ float x, y, z, radius;
6553+ float p_x = player->GetPositionX();
6554+ float p_y = player->GetPositionY();
6555+ float p_z = player->GetPositionZ();
6556+ uint32 map;
6557+ std::string name;
6558+
6559+ Field* fields = result->Fetch();
6560+ x = fields[0].GetFloat();
6561+ y = fields[1].GetFloat();
6562+ z = fields[2].GetFloat();
6563+ map = fields[3].GetUInt32();
6564+ radius = fields[4].GetFloat();
6565+
6566+ if (p_x > x + radius || p_x < x - radius || p_y > y + radius || p_y < y - radius || p_z > z + radius || p_z < z - radius)
6567+ {
6568+ player->CLOSE_GOSSIP_MENU();
6569+ player->GetSession()->SendNotification("Вы не в своем ГХ!");
6570+ return;
6571+ }
6572+ player->TeleportTo(map, x, y, z, 0.0f, 0U);
6573+ }
6574+ }
6575+
6576+ bool OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, char const* code)
6577+ {
6578+ switch (action)
6579+ {
6580+ case 3:
6581+ DeleteAllGobjects(player, creature, code);
6582+ break;
6583+ case 11:
6584+ DeleteAllNPC(player, creature, code);
6585+ break;
6586+ }
6587+ return true;
6588+ }
6589+
6590+};
6591+
6592+class npc_guildspell : public CreatureScript
6593+{
6594+public:
6595+ npc_guildspell() : CreatureScript("npc_guildspell") { }
6596+
6597+ uint8 IsSpell;
6598+
6599+ bool OnGossipHello(Player* player, Creature* creature)
6600+ {
6601+ player->PlayerTalkClass->ClearMenus();
6602+
6603+ if (player->GetRankFromDB(player->GetGUID()) == 0 && player->GetGuildId())
6604+ {
6605+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Купить гильдейское заклинание.", GOSSIP_SENDER_MAIN, 99000);
6606+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Купить гильдейское звание.", GOSSIP_SENDER_MAIN, 99002);
6607+ }
6608+
6609+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Выход.", GOSSIP_SENDER_MAIN, 99001);
6610+
6611+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
6612+
6613+ return true;
6614+ }
6615+
6616+ void BuySpellOrTitle(Player* player, Creature* creature, uint8 isSpell) {
6617+ player->PlayerTalkClass->ClearMenus();
6618+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Список доступных спеллов или званий:", GOSSIP_SENDER_MAIN, 99005);
6619+ uint32 spell;
6620+ uint32 cost;
6621+ uint32 number;
6622+ const char* name;
6623+ uint16 _loc = 0;
6624+ if (player->GetSession()->GetSessionDbLocaleIndex() > 0)
6625+ _loc=player->GetSession()->GetSessionDbLocaleIndex();
6626+ QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, cost, number FROM guild_level_spell WHERE isSpell = %u", isSpell);
6627+ if (result) {
6628+ do {
6629+ Field* fields = result->Fetch();
6630+ spell = fields[0].GetUInt32();
6631+ cost = fields[1].GetUInt32();
6632+ number = fields[2].GetUInt32();
6633+ if (isSpell == 1)
6634+ {
6635+ if (player->HasSpell(spell)) continue;
6636+
6637+ const SpellEntry* spellEntry = sSpellStore.LookupEntry(spell);
6638+ name = (const char*)(spellEntry->SpellName[_loc]);
6639+ }
6640+ else
6641+ {
6642+
6643+ const CharTitlesEntry* titleEntry = sCharTitlesStore.LookupEntry(spell);
6644+
6645+ if (player->HasTitle(titleEntry)) continue;
6646+
6647+ name = (const char*)titleEntry->nameMale[_loc];
6648+ //std::cout << "__" << (const char*)titleEntry->nameMale[8] << " --" << (const char*)titleEntry->nameMale[7];
6649+ }
6650+ std::stringstream buffer;
6651+
6652+ buffer << "|cff084E13" << name << "|r" << ". Стоимость: " << "|cFF1E90FF" << cost << " эмблем." << "|r";
6653+
6654+ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, buffer.str(), GOSSIP_SENDER_MAIN, number);
6655+ }
6656+
6657+ while (result->NextRow());
6658+
6659+ IsSpell = isSpell;
6660+
6661+ player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
6662+ }
6663+ }
6664+
6665+ void SelectSpellOrTitle(Player* player, Creature* creature, uint32 action) {
6666+ uint32 spell;
6667+ uint32 cost;
6668+ uint32 number;
6669+ uint32 guild = player->GetGuildId();
6670+ uint64 guid;
6671+ QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle, cost, number FROM guild_level_spell WHERE isSpell = %u AND number = %u", IsSpell, action);
6672+ if (result) {
6673+ Field* fields = result->Fetch();
6674+ spell = fields[0].GetUInt32();
6675+ cost = fields[1].GetUInt32();
6676+ number = fields[2].GetUInt32();
6677+
6678+ if (number == action) {
6679+ // learn spell
6680+
6681+ QueryResult result2 = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid = %u", guild);
6682+ if (result2) {
6683+
6684+ if (!player->HasItemCount(49426, cost))
6685+ {
6686+ player->CLOSE_GOSSIP_MENU();
6687+ player->GetSession()->SendNotification("Недостаточно эмблем!");
6688+ return;
6689+ }
6690+
6691+ do {
6692+ Field* fields = result2->Fetch();
6693+ guid = fields[0].GetUInt64();
6694+ if (Player* onlinePlayer = sObjectAccessor->FindPlayer(guid)) {
6695+ if (IsSpell == 1) onlinePlayer->learnSpell(spell, false);
6696+ else onlinePlayer->SetTitle(sCharTitlesStore.LookupEntry(spell));
6697+ }
6698+
6699+ CharacterDatabase.PQuery("REPLACE INTO guild_learn_spell (guild, spellortitle, isSpell) VALUES (%u, %u, %u)", guild, spell, IsSpell);
6700+
6701+ } while (result2->NextRow());
6702+
6703+ }
6704+ player->DestroyItemCount(49426, cost, true);
6705+ // learn spell
6706+ player->CLOSE_GOSSIP_MENU();
6707+ if (IsSpell == 1) player->GetSession()->SendAreaTriggerMessage("Гильдейское заклинание успешно куплено!");
6708+ else player->GetSession()->SendAreaTriggerMessage("Гильдейское звание успешно куплено!");
6709+ }
6710+
6711+ }
6712+
6713+ }
6714+
6715+ bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
6716+ {
6717+ switch (action)
6718+ {
6719+ case 99000:
6720+ BuySpellOrTitle(player, creature, 1);
6721+ break;
6722+ case 99002:
6723+ BuySpellOrTitle(player, creature, 0);
6724+ break;
6725+ case 99001:
6726+ player->CLOSE_GOSSIP_MENU();
6727+ break;
6728+ case 99005:
6729+ OnGossipHello(player, creature);
6730+ break;
6731+
6732+ }
6733+ if (action < 5000) SelectSpellOrTitle(player, creature, action);
6734+
6735+ return true;
6736+ }
6737+
6738+
6739+};
6740+
6741+class Login_spellguild : public PlayerScript
6742+{
6743+public:
6744+ Login_spellguild() : PlayerScript("Login_spellguild") { }
6745+ void OnLogin(Player* player, bool/* firstLogin*/)
6746+ {
6747+
6748+ player->SetDrunkValue(0);
6749+
6750+ uint32 guild = player->GetGuildId();
6751+
6752+ if (!guild) return;
6753+
6754+ QueryResult result = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_learn_spell WHERE guild = %u And isSpell = 1", guild);
6755+ if (result)
6756+ {
6757+ do
6758+ {
6759+ Field* fields = result->Fetch();
6760+ uint32 spell = fields[0].GetUInt32();
6761+
6762+ if (!player->HasSpell(spell)) player->learnSpell(spell, false);
6763+ } while (result->NextRow());
6764+ }
6765+ else
6766+ {
6767+ QueryResult result2 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_level_spell WHERE isSpell = 1");
6768+ if (result2)
6769+ {
6770+ do {
6771+ Field* fields = result2->Fetch();
6772+ uint32 Spell = fields[0].GetUInt32();
6773+
6774+ if (player->HasSpell(Spell)) player->removeSpell(Spell);
6775+ } while (result2->NextRow());
6776+ }
6777+ }
6778+
6779+ QueryResult result3 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_learn_spell WHERE guild = %u And isSpell = 0", guild);
6780+ if (result3)
6781+ {
6782+ do
6783+ {
6784+ Field* fields = result3->Fetch();
6785+ uint32 title = fields[0].GetUInt32();
6786+
6787+ if (!player->HasTitle(sCharTitlesStore.LookupEntry(title))) player->SetTitle(sCharTitlesStore.LookupEntry(title));
6788+ } while (result3->NextRow());
6789+ }
6790+ else
6791+ {
6792+ QueryResult result4 = CharacterDatabase.PQuery("SELECT spellortitle FROM guild_level_spell WHERE isSpell = 0");
6793+ if (result4)
6794+ {
6795+ do {
6796+ Field* fields = result4->Fetch();
6797+ uint32 title = fields[0].GetUInt32();
6798+
6799+ if (player->HasTitle(sCharTitlesStore.LookupEntry(title)))
6800+ {
6801+ player->SetTitle(sCharTitlesStore.LookupEntry(title), true);
6802+ if (!player->HasTitle(player->GetInt32Value(PLAYER_CHOSEN_TITLE))) player->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
6803+ }
6804+ } while (result4->NextRow());
6805+ }
6806+ }
6807+ }
6808+};
6809+
6810+class guildMasterChat : public PlayerScript
6811+{
6812+public:
6813+ guildMasterChat() : PlayerScript("guildMasterChat") {}
6814+
6815+ void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Guild* guild)
6816+ {
6817+ if (player->GetRank() == 0) msg = "|cFFFFD700" + msg + "|r";
6818+
6819+ }
6820+
6821 };
6822
6823 void AddSC_account_commandscript()
6824 {
6825- new account_commandscript();
6826+ new account_commandscript();
6827+ new item_tpguild();
6828+ new npc_guild_level();
6829+ new npc_guildhouse();
6830+ new npc_guildhouse_builder();
6831+ new npc_guildspell();
6832+ new Login_spellguild();
6833+ new guildMasterChat();
6834 }
6835diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
6836index 9f1839f..01bd6f6 100644
6837--- a/src/server/scripts/Commands/cs_misc.cpp
6838+++ b/src/server/scripts/Commands/cs_misc.cpp
6839@@ -1589,6 +1589,10 @@ public:
6840
6841 // Guild data print variables defined so that they exist, but are not necessarily used
6842 uint32 guildId = 0;
6843+ uint32 guildlevel;
6844+ QueryResult res = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", target->GetGuildId());
6845+ if (res)
6846+ guildlevel = (*res)[0].GetUInt32();
6847 uint8 guildRankId = 0;
6848 std::string guildName;
6849 std::string guildRank;
6850@@ -1838,6 +1842,7 @@ public:
6851 if (!guildName.empty())
6852 {
6853 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName.c_str(), guildId);
6854+ if (guildlevel && guildlevel>0) handler->PSendSysMessage(10000, guildlevel);
6855 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank.c_str(), uint32(guildRankId));
6856 if (!note.empty())
6857 handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_NOTE, note.c_str());
6858--
68591.9.4.msysgit.2
6860
6861From a0268f5d62d7045fc993600b1763910e5188d451 Mon Sep 17 00:00:00 2001
6862From: Undead <undead02@yandex.ru>
6863Date: Sun, 10 Jan 2016 01:47:32 +0300
6864Subject: [PATCH 4/4] Fix GuildHouse Pinfo Offline Player
6865
6866---
6867 src/server/scripts/Commands/cs_misc.cpp | 7 +++++--
6868 1 file changed, 5 insertions(+), 2 deletions(-)
6869
6870diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
6871index 01bd6f6..55b00d1 100644
6872--- a/src/server/scripts/Commands/cs_misc.cpp
6873+++ b/src/server/scripts/Commands/cs_misc.cpp
6874@@ -1590,8 +1590,11 @@ public:
6875 // Guild data print variables defined so that they exist, but are not necessarily used
6876 uint32 guildId = 0;
6877 uint32 guildlevel;
6878- QueryResult res = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", target->GetGuildId());
6879- if (res)
6880+ QueryResult res = NULL;
6881+ QueryResult res2 = CharacterDatabase.PQuery("SELECT guildid FROM guild_member WHERE guid = %u", lowguid);
6882+ if (res2)
6883+ res = CharacterDatabase.PQuery("SELECT level FROM guild_level WHERE guild = %u", (*res2)[0].GetUInt32());
6884+ if (res && res2)
6885 guildlevel = (*res)[0].GetUInt32();
6886 uint8 guildRankId = 0;
6887 std::string guildName;
6888--
68891.9.4.msysgit.2