1 | /* |
---|
2 | * MangChat By |Death| And Cybrax |
---|
3 | * |
---|
4 | * This Program Is Free Software; You Can Redistribute It And/Or Modify It Under The Terms |
---|
5 | * Of The GNU General Public License |
---|
6 | * Written and Developed by Cybrax. cybraxvd@gmail.com |
---|
7 | * |Death| <death@hell360.net>, Lice <lice@yeuxverts.net>, Dj_baby & Sanaell, Tase |
---|
8 | * With Help And Support From The MaNGOS Project Community. |
---|
9 | * PLEASE RETAIN THE COPYRIGHT OF THE AUTHORS. |
---|
10 | */ |
---|
11 | #include "IRCCmd.h" |
---|
12 | #include "IRCClient.h" |
---|
13 | #include "MCS_OnlinePlayers.h" |
---|
14 | #include "WorldPacket.h" |
---|
15 | #include "Database/DatabaseEnv.h" |
---|
16 | #include "Chat.h" |
---|
17 | #include "MapManager.h" |
---|
18 | #include "World.h" |
---|
19 | #include "Guild.h" |
---|
20 | #include "ObjectMgr.h" |
---|
21 | #include "Language.h" |
---|
22 | #include "SpellAuras.h" |
---|
23 | #include "SystemConfig.h" |
---|
24 | #include "Config/ConfigEnv.h" |
---|
25 | |
---|
26 | #define Send_Player(p, m) sIRC.Send_WoW_Player(p, m) |
---|
27 | #define Send_IRCA(c, m, b, t) sIRC.Send_IRC_Channel(c, m, b, t) |
---|
28 | |
---|
29 | #ifdef WIN32 |
---|
30 | #define Delay(x) Sleep(x) |
---|
31 | #else |
---|
32 | #define Delay(x) sleep(x / 1000) |
---|
33 | #endif |
---|
34 | |
---|
35 | void IRCCmd::Handle_Login(_CDATA *CD) |
---|
36 | { |
---|
37 | std::string* _PARAMS = getArray(CD->PARAMS, 2); |
---|
38 | std::string isbanned = AcctIsBanned(_PARAMS[0]); |
---|
39 | if(isbanned == "NOTBANNED") |
---|
40 | { |
---|
41 | if(!IsLoggedIn(CD->USER)) |
---|
42 | { |
---|
43 | if(!AcctIsLoggedIn(_PARAMS[0].c_str())) |
---|
44 | { |
---|
45 | QueryResult *result = loginDatabase.PQuery("SELECT `gmlevel` FROM `account` WHERE `username`='%s' AND `sha_pass_hash`=SHA1(CONCAT(UPPER(`username`),':',UPPER('%s')));", _PARAMS[0].c_str(), _PARAMS[1].c_str()); |
---|
46 | if (result) |
---|
47 | { |
---|
48 | Field *fields = result->Fetch(); |
---|
49 | int GMLevel = fields[0].GetInt16(); |
---|
50 | if(GMLevel >= 0) |
---|
51 | { |
---|
52 | _client *NewClient = new _client(); |
---|
53 | NewClient->Name = CD->USER; |
---|
54 | NewClient->UName = MakeUpper(_PARAMS[0]); |
---|
55 | NewClient->GMLevel = fields[0].GetInt16(); |
---|
56 | _CLIENTS.push_back(NewClient); |
---|
57 | Send_IRCA(CD->USER, MakeMsg("You Are Now Logged In As %s, Welcome To MangChat Admin Mode.", _PARAMS[0].c_str()), true, CD->TYPE); |
---|
58 | |
---|
59 | if(sIRC._op_gm == 1 && GMLevel >= sIRC._op_gm_lev) |
---|
60 | { |
---|
61 | for(int i=1;i < sIRC._chan_count + 1;i++) |
---|
62 | sIRC.SendIRC("MODE #"+sIRC._irc_chan[i]+" +o "+CD->USER ); |
---|
63 | } |
---|
64 | } |
---|
65 | }else |
---|
66 | Send_IRCA(CD->USER, "\0034[ERROR] : Sorry, Your Username Or Password Is Incorrect. Please Try Again. ", true, "ERROR"); |
---|
67 | }else |
---|
68 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : %s Is Already Logged In With This Username. ", GetNameFromAcct(MakeUpper(_PARAMS[0])).c_str()), true, "ERROR"); |
---|
69 | }else |
---|
70 | Send_IRCA(CD->USER, "\0034[ERROR] : You Are Already Logged In As "+ _PARAMS[0] +"!", true, "ERROR"); |
---|
71 | }else |
---|
72 | Send_IRCA(CD->USER, "\0034[ERROR] : Sorry You Are "+isbanned+". You Cannot Log In To MangChat "+CD->USER.c_str()+"!", true, "ERROR"); |
---|
73 | } |
---|
74 | |
---|
75 | void IRCCmd::Handle_Logout(_CDATA *CD) |
---|
76 | { |
---|
77 | for(std::list<_client*>::iterator i=_CLIENTS.begin(); i!=_CLIENTS.end();i++) |
---|
78 | { |
---|
79 | if((*i)->Name == CD->USER) |
---|
80 | { |
---|
81 | _CLIENTS.erase(i); |
---|
82 | delete (*i); |
---|
83 | Send_IRCA(CD->USER, "You Are Now Logged Out!", true, CD->TYPE); |
---|
84 | return; |
---|
85 | } |
---|
86 | } |
---|
87 | Send_IRCA(CD->USER, "\0034[ERROR] : You Are Not Logged In!", true, "ERROR"); |
---|
88 | } |
---|
89 | |
---|
90 | void IRCCmd::Account_Player(_CDATA *CD) |
---|
91 | { |
---|
92 | std::string* _PARAMS = getArray(CD->PARAMS, 3); |
---|
93 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
94 | { |
---|
95 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
96 | return; |
---|
97 | } |
---|
98 | normalizePlayerName(_PARAMS[0]); |
---|
99 | uint64 guid = objmgr.GetPlayerGUIDByName(_PARAMS[0]); |
---|
100 | uint32 account_id = 0; |
---|
101 | account_id = objmgr.GetPlayerAccountIdByGUID(guid); |
---|
102 | if(account_id) |
---|
103 | { |
---|
104 | if(account_id == GetAcctIDFromName(CD->USER) || GetLevel(CD->USER) >= sIRC._op_gm_lev) |
---|
105 | { |
---|
106 | Player* plr = objmgr.GetPlayer(guid); |
---|
107 | if(_PARAMS[1] == "lock") |
---|
108 | { |
---|
109 | loginDatabase.PExecute( "UPDATE `account` SET `locked` = '1' WHERE `id` = '%d'",account_id); |
---|
110 | if(plr) Send_Player(plr, MakeMsg("Your Account Has Been Locked To Your Current IP By: %s", CD->USER.c_str())); |
---|
111 | Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Account Has Been Locked To Their Current IP Address.", true, CD->TYPE); |
---|
112 | } |
---|
113 | else if(_PARAMS[1] == "unlock") |
---|
114 | { |
---|
115 | loginDatabase.PExecute( "UPDATE `account` SET `locked` = '0' WHERE `id` = '%d'",account_id); |
---|
116 | if(plr) Send_Player(plr, MakeMsg("Your Account Has Been UnLocked From The Associated IP By: %s", CD->USER.c_str())); |
---|
117 | Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Account Has Been UnLocked From The Associated IP Address.", true, CD->TYPE); |
---|
118 | } |
---|
119 | else if(_PARAMS[1] == "mail") |
---|
120 | { |
---|
121 | loginDatabase.PExecute( "UPDATE `account` SET `email` = '%s' WHERE `id` = '%d'",_PARAMS[2].c_str() ,account_id); |
---|
122 | if (plr) Send_Player(plr, MakeMsg("%s Has Changed Your EMail Adress To: %s", CD->USER.c_str(), _PARAMS[2].c_str())); |
---|
123 | Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : EMail Address Successfully Changed To: "+_PARAMS[2], true, CD->TYPE); |
---|
124 | } |
---|
125 | else if(_PARAMS[1] == "pass") |
---|
126 | { |
---|
127 | loginDatabase.PExecute( "UPDATE `account` SET `sha_pass_hash` = SHA1(CONCAT(UPPER(`username`),':',UPPER('%s'))) WHERE `id` = '%d'",_PARAMS[2].c_str() ,account_id); |
---|
128 | if (plr) Send_Player(plr, MakeMsg("%s Has Changed Your Password To: %s", CD->USER.c_str(), _PARAMS[2].c_str())); |
---|
129 | Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Password Successfully Changed To: "+_PARAMS[2], true, CD->TYPE); |
---|
130 | } |
---|
131 | else if(_PARAMS[1] == "rename") |
---|
132 | { |
---|
133 | if(plr) |
---|
134 | { |
---|
135 | plr->SetAtLoginFlag(AT_LOGIN_RENAME); |
---|
136 | Send_Player(plr, MakeMsg("%s Has Requested You Change This Characters Name, Rename Will Be Forced On Next Login!", CD->USER.c_str())); |
---|
137 | } |
---|
138 | CharacterDatabase.PExecute("UPDATE `characters` SET `at_login` = `at_login` | '1' WHERE `guid` = '%u'", guid); |
---|
139 | Send_IRCA(ChanOrPM(CD), "\00313["+GetAcctNameFromID(account_id)+"] : Has Been Forced To Change Their Characters Name, Rename Will Be Forced On Next Login!", true, CD->TYPE); |
---|
140 | } |
---|
141 | } |
---|
142 | else |
---|
143 | Send_IRCA(CD->USER, "\0034[ERROR] : You Are Not A GM, You May Only Change Settings In Your Own Account.", true, "ERROR"); |
---|
144 | } |
---|
145 | else |
---|
146 | Send_IRCA(CD->USER, "\0034[ERROR] : No Such Player Exists, So Account Cannot Be Looked Up.", true, "ERROR"); |
---|
147 | } |
---|
148 | |
---|
149 | void IRCCmd::Ban_Player(_CDATA *CD) |
---|
150 | { |
---|
151 | std::string* _PARAMS = getArray(CD->PARAMS, 3); |
---|
152 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
153 | { |
---|
154 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
155 | return; |
---|
156 | } |
---|
157 | if(_PARAMS[1] == "ip") |
---|
158 | { |
---|
159 | std::string ip = GetIPFromPlayer(_PARAMS[0]); |
---|
160 | if(_PARAMS[2] == "") |
---|
161 | _PARAMS[2] = "No Reason"; |
---|
162 | if(ip != "") |
---|
163 | { |
---|
164 | loginDatabase.PExecute( "INSERT IGNORE INTO `ip_banned` VALUES ('%s', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '%s', '%s')", ip.c_str(), CD->USER.c_str(), _PARAMS[2].c_str()); |
---|
165 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
166 | plr->GetSession()->KickPlayer(); |
---|
167 | Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Had Their IP Address Banned. [%s] Reason: %s",_PARAMS[0].c_str() ,ip.c_str() , _PARAMS[2].c_str()), true, CD->TYPE); |
---|
168 | } |
---|
169 | else |
---|
170 | Send_IRCA(CD->USER, "\0034[ERROR] : I Cannot Locate An IP Address For The Character Name Given.", true, "ERROR"); |
---|
171 | } |
---|
172 | if(_PARAMS[1] == "acct") |
---|
173 | { |
---|
174 | uint64 guid = objmgr.GetPlayerGUIDByName(_PARAMS[0].c_str()); |
---|
175 | uint32 acctid = objmgr.GetPlayerAccountIdByGUID(guid); |
---|
176 | if(_PARAMS[2] == "") |
---|
177 | _PARAMS[2] = "No Reason"; |
---|
178 | if(acctid) |
---|
179 | { |
---|
180 | loginDatabase.PExecute( "INSERT INTO `account_banned` VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '%s', '%s', 1)", acctid, CD->USER.c_str(), _PARAMS[2].c_str()); |
---|
181 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
182 | plr->GetSession()->KickPlayer(); |
---|
183 | Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Had Their Account Banned. Reason: %s",_PARAMS[0].c_str(), _PARAMS[2].c_str()), true, CD->TYPE); |
---|
184 | } |
---|
185 | else |
---|
186 | Send_IRCA(CD->USER, "\0034[ERROR] : I Cannot Locate An Account For The Character Name Given.", true, "ERROR"); |
---|
187 | } |
---|
188 | if(_PARAMS[1] == "unban") |
---|
189 | { |
---|
190 | std::string unbani = _PARAMS[0]; |
---|
191 | if(atoi(unbani.c_str()) > 0) |
---|
192 | { |
---|
193 | loginDatabase.PExecute( "DELETE FROM ip_banned WHERE ip = '%s'", _PARAMS[0].c_str()); |
---|
194 | Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Been Removed From The IP Ban List.", _PARAMS[0].c_str()), true, CD->TYPE); |
---|
195 | } |
---|
196 | else |
---|
197 | { |
---|
198 | QueryResult *result = loginDatabase.PQuery("SELECT id FROM `account` WHERE username = '%s'", _PARAMS[0].c_str()); |
---|
199 | if(result) |
---|
200 | { |
---|
201 | Field *fields = result->Fetch(); |
---|
202 | std::string id = fields[0].GetCppString(); |
---|
203 | |
---|
204 | loginDatabase.PExecute( "DELETE FROM account_banned WHERE id = %s", id.c_str()); |
---|
205 | delete result; |
---|
206 | Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Been Removed From The Account Ban List.", _PARAMS[0].c_str()), true, CD->TYPE); |
---|
207 | |
---|
208 | } |
---|
209 | else |
---|
210 | Send_IRCA(CD->USER, "\0034[ERROR] : I Cannot Locate An Account Or IP Address For The Paramaters Given.", true, "ERROR"); |
---|
211 | } |
---|
212 | } |
---|
213 | } |
---|
214 | |
---|
215 | void IRCCmd::Chan_Control(_CDATA *CD) |
---|
216 | { |
---|
217 | std::string* _PARAMS = getArray(CD->PARAMS, 2); |
---|
218 | if(CD->FROM == sIRC._Nick) |
---|
219 | { |
---|
220 | Send_IRCA(CD->USER, "\0034[ERROR] : You Cannot Use This Command Through A PM Yet.", true, "ERROR"); |
---|
221 | return; |
---|
222 | } |
---|
223 | if(_PARAMS[0] == "op") |
---|
224 | { |
---|
225 | if(_PARAMS[1].length() > 1) |
---|
226 | sIRC.SendIRC("MODE "+CD->FROM+" +o "+_PARAMS[1] ); |
---|
227 | else |
---|
228 | sIRC.SendIRC("MODE "+CD->FROM+" +o "+CD->USER ); |
---|
229 | } |
---|
230 | if(_PARAMS[0] == "deop") |
---|
231 | { |
---|
232 | if(_PARAMS[1].length() > 1) |
---|
233 | sIRC.SendIRC("MODE "+CD->FROM+" -o "+_PARAMS[1] ); |
---|
234 | else |
---|
235 | sIRC.SendIRC("MODE "+CD->FROM+" -o "+CD->USER ); |
---|
236 | } |
---|
237 | if(_PARAMS[0] == "voice") |
---|
238 | { |
---|
239 | if(_PARAMS[1].length() > 1) |
---|
240 | sIRC.SendIRC("MODE "+CD->FROM+" +v "+_PARAMS[1] ); |
---|
241 | else |
---|
242 | sIRC.SendIRC("MODE "+CD->FROM+" +v "+CD->USER ); |
---|
243 | } |
---|
244 | if(_PARAMS[0] == "devoice") |
---|
245 | { |
---|
246 | if(_PARAMS[1].length() > 1) |
---|
247 | sIRC.SendIRC("MODE "+CD->FROM+" -v "+_PARAMS[1] ); |
---|
248 | else |
---|
249 | sIRC.SendIRC("MODE "+CD->FROM+" -v "+CD->USER ); |
---|
250 | } |
---|
251 | } |
---|
252 | |
---|
253 | void IRCCmd::Char_Player(_CDATA *CD) |
---|
254 | { |
---|
255 | std::string* _PARAMS = getArray(CD->PARAMS, 5); |
---|
256 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
257 | { |
---|
258 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
259 | return; |
---|
260 | } |
---|
261 | normalizePlayerName(_PARAMS[0]); |
---|
262 | uint64 guid = objmgr.GetPlayerGUIDByName(_PARAMS[0]); |
---|
263 | Player* plr = objmgr.GetPlayer(guid); |
---|
264 | if(plr) |
---|
265 | { |
---|
266 | if(_PARAMS[1] == "mapcheat") |
---|
267 | { |
---|
268 | bool explore = false; |
---|
269 | if (_PARAMS[2] != "0") |
---|
270 | explore = true; |
---|
271 | for (uint8 i=0; i<64; i++) |
---|
272 | { |
---|
273 | if (_PARAMS[2] != "0") |
---|
274 | plr->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0xFFFFFFFF); |
---|
275 | else |
---|
276 | plr->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0); |
---|
277 | } |
---|
278 | if(explore) |
---|
279 | { |
---|
280 | Send_Player(plr, MakeMsg("All Your Zones Have Been Set To Explored By: %s", CD->USER.c_str())); |
---|
281 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Now Explored All Zones.", true, CD->TYPE); |
---|
282 | } |
---|
283 | else |
---|
284 | { |
---|
285 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Now Had All Zones Set To Un-Explored.", true, CD->TYPE); |
---|
286 | Send_Player(plr, MakeMsg("All Your Zones Have Been Set To Un-Explored By: %s", CD->USER.c_str())); |
---|
287 | } |
---|
288 | } |
---|
289 | if(_PARAMS[1] == "taxicheat") |
---|
290 | { |
---|
291 | if (_PARAMS[2] != "0") |
---|
292 | { |
---|
293 | plr->SetTaxiCheater(true); |
---|
294 | Send_Player(plr, MakeMsg("Taxi Node Cheat Has Been Enabled By: %s", CD->USER.c_str())); |
---|
295 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Taxi Node Cheat Has Been Enabled.", true, CD->TYPE); |
---|
296 | } |
---|
297 | else |
---|
298 | { |
---|
299 | plr->SetTaxiCheater(false); |
---|
300 | Send_Player(plr, MakeMsg("Taxi Node Cheat Has Been Disabled By: %s", CD->USER.c_str())); |
---|
301 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Taxi Node Cheat Has Been Disabled.", true, CD->TYPE); |
---|
302 | } |
---|
303 | } |
---|
304 | if(_PARAMS[1] == "maxskill") |
---|
305 | { |
---|
306 | plr->UpdateSkillsToMaxSkillsForLevel(); |
---|
307 | Send_Player(plr, MakeMsg("Your Skills Have Been Maxed Out By: %s", CD->USER.c_str())); |
---|
308 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Skills Have Been Maxed Out.", true, CD->TYPE); |
---|
309 | } |
---|
310 | if(_PARAMS[1] == "setskill") |
---|
311 | { |
---|
312 | std::string* _PARAMSA = getArray(_PARAMS[2], 4); |
---|
313 | uint32 skill = atoi(_PARAMS[2].c_str()); |
---|
314 | uint32 level = atol(_PARAMS[3].c_str()); |
---|
315 | int32 max = _PARAMS[4].c_str() ? atol (_PARAMS[4].c_str()) : plr->GetPureMaxSkillValue(skill); |
---|
316 | SkillLineEntry const* skilllookup = sSkillLineStore.LookupEntry(skill); |
---|
317 | //if skillid entered is not a number and greater then 0 then the command is being used wrong |
---|
318 | if(skill >= 0) |
---|
319 | { |
---|
320 | //does the skill even exist |
---|
321 | if(skilllookup) |
---|
322 | { |
---|
323 | //does player have the skill yet |
---|
324 | if(plr->GetSkillValue(skill)) |
---|
325 | { |
---|
326 | plr->SetSkill(skill,level,max); |
---|
327 | Send_Player(plr, MakeMsg("Skill: %s Has Been Set To Level: %i Max: %i By: %s",skilllookup->name[0], level, max, CD->USER.c_str())); |
---|
328 | Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Had Skill: %s Set To Level: %d Max: %d",_PARAMS[0].c_str() , skilllookup->name[0], level, max), true, CD->TYPE); |
---|
329 | } |
---|
330 | else |
---|
331 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Player Does Not Have The %s Skill Yet.", skilllookup->name[0]), true, "ERROR"); |
---|
332 | } |
---|
333 | else |
---|
334 | Send_IRCA(CD->USER, "\0034[ERROR] : That Skill ID Does Not Exist.", true, "ERROR"); |
---|
335 | } |
---|
336 | else |
---|
337 | Send_IRCA(CD->USER, "\0034[ERROR] : The Skill ID Entered Is Invalid.", true, "ERROR"); |
---|
338 | } |
---|
339 | } |
---|
340 | else |
---|
341 | Send_IRCA(CD->USER, "\0034[ERROR] : No Character With That Name Exists.", true, "ERROR"); |
---|
342 | } |
---|
343 | |
---|
344 | void IRCCmd::Fun_Player(_CDATA *CD) |
---|
345 | { |
---|
346 | std::string* _PARAMS = getArray(CD->PARAMS, 3); |
---|
347 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
348 | { |
---|
349 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
350 | return; |
---|
351 | } |
---|
352 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
353 | { |
---|
354 | if(_PARAMS[1] == "say") |
---|
355 | { |
---|
356 | plr->Say(_PARAMS[2], LANG_UNIVERSAL); |
---|
357 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Was Forced To Say: "+_PARAMS[2]+".", true, CD->TYPE); |
---|
358 | } |
---|
359 | if(_PARAMS[1] == "sound") |
---|
360 | { |
---|
361 | uint32 sndid = atoi(_PARAMS[2].c_str()); |
---|
362 | plr->SendPlaySound(sndid ,true); |
---|
363 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Just Heard Sound ID: "+_PARAMS[2]+".", true, CD->TYPE); |
---|
364 | } |
---|
365 | } |
---|
366 | else |
---|
367 | Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Online!", true, "ERROR"); |
---|
368 | } |
---|
369 | |
---|
370 | void IRCCmd::Help_IRC(_CDATA *CD) |
---|
371 | { |
---|
372 | std::string* _PARAMS = getArray(CD->PARAMS, 1); |
---|
373 | QueryResult *result = WorldDatabase.PQuery("SELECT `Command`, `Description`, `gmlevel` FROM `IRC_Commands`"); |
---|
374 | if(result) |
---|
375 | { |
---|
376 | if(IsLoggedIn(CD->USER)) |
---|
377 | { |
---|
378 | if(_PARAMS[0] == "") |
---|
379 | { |
---|
380 | QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `IRC_Commands` WHERE `gmlevel` <= %u ORDER BY `Command`", GetLevel(CD->USER)); |
---|
381 | if(result) |
---|
382 | { |
---|
383 | std::string output = "\002MangChat IRC Commands:\017 "; |
---|
384 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
385 | { |
---|
386 | Field *fields = result->Fetch(); |
---|
387 | output += fields[0].GetCppString() + ", "; |
---|
388 | result->NextRow(); |
---|
389 | } |
---|
390 | delete result; |
---|
391 | Send_IRCA(CD->USER, output, true, CD->TYPE.c_str()); |
---|
392 | } |
---|
393 | } |
---|
394 | else |
---|
395 | { |
---|
396 | QueryResult *result = WorldDatabase.PQuery("SELECT `Description`, `gmlevel` FROM `IRC_Commands` WHERE `Command` = '%s'", _PARAMS[0].c_str()); |
---|
397 | if(result) |
---|
398 | { |
---|
399 | Field *fields = result->Fetch(); |
---|
400 | if(fields[1].GetUInt32() > GetLevel(CD->USER)) |
---|
401 | { |
---|
402 | Send_IRCA(CD->USER, "You Do Not Have Access To That Command, So No Help Is Available.", true, CD->TYPE.c_str()); |
---|
403 | return; |
---|
404 | } |
---|
405 | if(result) |
---|
406 | { |
---|
407 | std::string cmdhlp = fields[0].GetCppString(); |
---|
408 | delete result; |
---|
409 | Send_IRCA(CD->USER, cmdhlp, true, CD->TYPE.c_str()); |
---|
410 | } |
---|
411 | } |
---|
412 | else |
---|
413 | Send_IRCA(CD->USER, "\0034[ERROR] : No Such Command Exists, Please Check The Spelling And Try Again.", true, "ERROR"); |
---|
414 | } |
---|
415 | } |
---|
416 | else if(!IsLoggedIn(CD->USER)) |
---|
417 | { |
---|
418 | if(_PARAMS[0] == "") |
---|
419 | { |
---|
420 | QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `IRC_Commands` WHERE `gmlevel` = 0 ORDER BY `Command`"); |
---|
421 | if(result) |
---|
422 | { |
---|
423 | std::string output = "\002MangChat IRC Commands:\017 "; |
---|
424 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
425 | { |
---|
426 | Field *fields = result->Fetch(); |
---|
427 | output += fields[0].GetCppString() + ", "; |
---|
428 | result->NextRow(); |
---|
429 | } |
---|
430 | delete result; |
---|
431 | Send_IRCA(CD->USER, output, true, CD->TYPE.c_str()); |
---|
432 | Send_IRCA(CD->USER, "You Are Currently Not Logged In, Please Login To See A Complete List Of Commands Available To You.", true, CD->TYPE.c_str()); |
---|
433 | } |
---|
434 | } |
---|
435 | else |
---|
436 | { |
---|
437 | QueryResult *result = WorldDatabase.PQuery("SELECT `Description`, `gmlevel` FROM `IRC_Commands` WHERE `Command` = '%s'", _PARAMS[0].c_str()); |
---|
438 | if(result) |
---|
439 | { |
---|
440 | Field *fields = result->Fetch(); |
---|
441 | if(fields[1].GetUInt32() > 0) |
---|
442 | { |
---|
443 | Send_IRCA(CD->USER, "You Do Not Have Access To That Command, So No Help Is Available.", true, CD->TYPE.c_str()); |
---|
444 | return; |
---|
445 | } |
---|
446 | std::string cmdhlp = fields[0].GetCppString(); |
---|
447 | delete result; |
---|
448 | Send_IRCA(CD->USER, cmdhlp, true, CD->TYPE.c_str()); |
---|
449 | } |
---|
450 | else |
---|
451 | Send_IRCA(CD->USER, "\0034[ERROR] : No Such Command Exists, Please Check The Spelling And Try Again.", true, "ERROR"); |
---|
452 | } |
---|
453 | } |
---|
454 | } |
---|
455 | else |
---|
456 | Send_IRCA(CD->USER, "\0034[ERROR] : Database Error! Please Make Sure You Used IRC_Commands.sql, You Must Have A Table In Your World Database (IRC_Commands)!", true, "ERROR"); |
---|
457 | } |
---|
458 | |
---|
459 | void IRCCmd::Inchan_Server(_CDATA *CD) |
---|
460 | { |
---|
461 | std::string* _PARAMS = getArray(CD->PARAMS, 1); |
---|
462 | if(_PARAMS[0] == "") |
---|
463 | { |
---|
464 | Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"inchan <ChannelName> )", true, "ERROR"); |
---|
465 | return; |
---|
466 | } |
---|
467 | QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `IRC_Inchan` WHERE `channel` = '%s' ORDER BY `name`", _PARAMS[0].c_str()); |
---|
468 | if(result) |
---|
469 | { |
---|
470 | Field *fields = result->Fetch(); |
---|
471 | std::string output = "\002Players In The [ "+fields[2].GetCppString()+" ] Channel:\017 "; |
---|
472 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
473 | { |
---|
474 | output += fields[1].GetCppString() + ", "; |
---|
475 | result->NextRow(); |
---|
476 | } |
---|
477 | delete result; |
---|
478 | Send_IRCA(ChanOrPM(CD), output, true, CD->TYPE); |
---|
479 | } |
---|
480 | else |
---|
481 | Send_IRCA(ChanOrPM(CD), "No Players Are Currently In [ "+_PARAMS[0]+" ] Channel!", true, CD->TYPE.c_str()); |
---|
482 | } |
---|
483 | |
---|
484 | void IRCCmd::Info_Server(_CDATA *CD) |
---|
485 | { |
---|
486 | std::string* _PARAMS = getArray(CD->PARAMS, 1); |
---|
487 | char clientsNum [50]; |
---|
488 | sprintf(clientsNum, "%u", sWorld.GetActiveSessionCount()); |
---|
489 | char maxClientsNum [50]; |
---|
490 | sprintf(maxClientsNum, "%u", sWorld.GetMaxActiveSessionCount()); |
---|
491 | std::string str = secsToTimeString(sWorld.GetUptime()); |
---|
492 | std::string svnrev = _FULLVERSION; |
---|
493 | Send_IRCA(ChanOrPM(CD), "\x2 Number of players online:\x3\x31\x30 " + (std::string)clientsNum + "\xF |\x2 Max since last restart:\x3\x31\x30 "+(std::string)maxClientsNum+"\xF |\x2 Uptime:\x3\x31\x30 "+str, true, CD->TYPE); |
---|
494 | Send_IRCA(ChanOrPM(CD), "\x2 Trinity Core SVN revision:\x3\x31\x30 "+svnrev, true, CD->TYPE); |
---|
495 | } |
---|
496 | |
---|
497 | void IRCCmd::Item_Player(_CDATA *CD) |
---|
498 | { |
---|
499 | std::string* _PARAMS = getArray(CD->PARAMS, 3); |
---|
500 | |
---|
501 | normalizePlayerName(_PARAMS[0]); |
---|
502 | Player *chr = GetPlayer(_PARAMS[0].c_str()); |
---|
503 | if(_PARAMS[1] == "add") |
---|
504 | { |
---|
505 | std::string s_param = _PARAMS[2]; |
---|
506 | |
---|
507 | char *args = (char*)s_param.c_str(); |
---|
508 | uint32 itemId = 0; |
---|
509 | if(args[0]=='[') |
---|
510 | { |
---|
511 | char* citemName = citemName = strtok((char*)args, "]"); |
---|
512 | if(citemName && citemName[0]) |
---|
513 | { |
---|
514 | std::string itemName = citemName+1; |
---|
515 | WorldDatabase.escape_string(itemName); |
---|
516 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); |
---|
517 | if (!result) |
---|
518 | { |
---|
519 | Send_IRCA(CD->USER, "\0034[ERROR] : Item Not Found!", true, "ERROR"); |
---|
520 | return; |
---|
521 | } |
---|
522 | itemId = result->Fetch()->GetUInt16(); |
---|
523 | delete result; |
---|
524 | } |
---|
525 | else |
---|
526 | { |
---|
527 | Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"item <Player> <add> [Exact Item Name] <Amount> )", true, "ERROR"); |
---|
528 | return; |
---|
529 | } |
---|
530 | } |
---|
531 | else |
---|
532 | { |
---|
533 | std::string itemName = s_param; |
---|
534 | WorldDatabase.escape_string(itemName); |
---|
535 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); |
---|
536 | if (result) |
---|
537 | { |
---|
538 | itemId = result->Fetch()->GetUInt16(); |
---|
539 | } |
---|
540 | delete result; |
---|
541 | |
---|
542 | char* cId = strtok(args, " "); |
---|
543 | if(!cId) |
---|
544 | { |
---|
545 | Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"item <Player> <add> <ItemID> <Amount> )", true, "ERROR"); |
---|
546 | return; |
---|
547 | } |
---|
548 | itemId = atol(cId); |
---|
549 | } |
---|
550 | char* ccount = strtok(NULL, " "); |
---|
551 | int32 count = 1; |
---|
552 | if (ccount) { count = atol(ccount); } |
---|
553 | Player* plTarget = chr; |
---|
554 | if(!plTarget) |
---|
555 | { |
---|
556 | Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR"); |
---|
557 | return; |
---|
558 | } |
---|
559 | ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); |
---|
560 | //Subtract |
---|
561 | if (count < 0) |
---|
562 | { |
---|
563 | plTarget->DestroyItemCount(itemId, -count, true, false); |
---|
564 | char itemid2[255]; |
---|
565 | sprintf(itemid2,"%d",itemId); |
---|
566 | std::string itake = " \00313["+ _PARAMS[0] +"] : Has Had Item " +itemid2+ " Taken From Them!"; |
---|
567 | Send_IRCA(ChanOrPM(CD), itake, true, CD->TYPE); |
---|
568 | return; |
---|
569 | } |
---|
570 | //Adding items |
---|
571 | uint32 noSpaceForCount = 0; |
---|
572 | |
---|
573 | // check space and find places |
---|
574 | ItemPosCountVec dest; |
---|
575 | uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount ); |
---|
576 | if( msg == EQUIP_ERR_INVENTORY_FULL ) // convert to possibel store amount |
---|
577 | count -= noSpaceForCount; |
---|
578 | else if( msg != EQUIP_ERR_OK ) // other error, can't add |
---|
579 | { |
---|
580 | char s_countForStore[255]; |
---|
581 | sprintf(s_countForStore,"%d",count); |
---|
582 | std::string ierror = " \00313["+ _PARAMS[0] +"] : Could Not Create All Items! " +s_countForStore+ " Item(s) Were Not Created!"; |
---|
583 | Send_IRCA(ChanOrPM(CD), ierror, true, CD->TYPE); |
---|
584 | return; |
---|
585 | } |
---|
586 | Item* item = plTarget->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); |
---|
587 | if(count > 0 && item) |
---|
588 | { |
---|
589 | plTarget->SendNewItem(item,count,true,false); |
---|
590 | QueryResult *result = WorldDatabase.PQuery("SELECT name FROM item_template WHERE entry = %d", itemId); |
---|
591 | char* dbitemname = NULL; |
---|
592 | if (result) |
---|
593 | { |
---|
594 | dbitemname = (char*)result->Fetch()->GetString(); |
---|
595 | } |
---|
596 | std::string iinfo = " \00313[" + _PARAMS[0] + "] : Has Been Given Item "+dbitemname+". From: "+CD->USER.c_str()+"."; |
---|
597 | Send_IRCA(ChanOrPM(CD), iinfo, true, CD->TYPE); |
---|
598 | delete result; |
---|
599 | } |
---|
600 | if(noSpaceForCount > 0) |
---|
601 | { |
---|
602 | char s_countForStore[255]; |
---|
603 | sprintf(s_countForStore,"%d",noSpaceForCount); |
---|
604 | std::string ierror = " \00313["+ _PARAMS[0] +"] : Could Not Create All Items! " +s_countForStore+ " Item(s) Were Not Created!"; |
---|
605 | Send_IRCA(ChanOrPM(CD), ierror, true, CD->TYPE); |
---|
606 | return; |
---|
607 | } |
---|
608 | } |
---|
609 | else |
---|
610 | { |
---|
611 | Send_IRCA(CD->USER, "\0034[ERROR] : Syntax Error! ( "+sIRC._cmd_prefx+"item <Player> <add> <ItemID> <Amount> )", true, "ERROR"); |
---|
612 | return; |
---|
613 | } |
---|
614 | } |
---|
615 | |
---|
616 | void IRCCmd::Jail_Player(_CDATA *CD) |
---|
617 | { |
---|
618 | if(ValidParams(CD->PARAMS, 1)) |
---|
619 | { |
---|
620 | std::string* _PARAMS = getArray(CD->PARAMS, 2); |
---|
621 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
622 | { |
---|
623 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
624 | return; |
---|
625 | } |
---|
626 | if (Player *plr = GetPlayer(_PARAMS[0])) |
---|
627 | { |
---|
628 | std::string sReason = ""; |
---|
629 | if(_PARAMS[1] == "release") |
---|
630 | { |
---|
631 | float rposx, rposy, rposz, rposo = 0; |
---|
632 | uint32 rmapid = 0; |
---|
633 | CharacterDatabase.escape_string(_PARAMS[0]); |
---|
634 | QueryResult *result = CharacterDatabase.PQuery( "SELECT `map`, `position_x`, `position_y`, `position_z` FROM `character_homebind` WHERE `guid` = '" I64FMTD "'", plr->GetGUID() ); |
---|
635 | if(result) |
---|
636 | { |
---|
637 | Field *fields = result->Fetch(); |
---|
638 | rmapid = fields[0].GetUInt16(); |
---|
639 | rposx = fields[1].GetFloat(); |
---|
640 | rposy = fields[2].GetFloat(); |
---|
641 | rposz = fields[3].GetFloat(); |
---|
642 | delete result; |
---|
643 | plr->SetMovement(MOVE_UNROOT); |
---|
644 | plr->TeleportTo(rmapid, rposx, rposy, rposz, rposo); |
---|
645 | plr->RemoveAurasDueToSpell(42201); |
---|
646 | plr->RemoveAurasDueToSpell(23775); |
---|
647 | plr->RemoveAurasDueToSpell(9454); |
---|
648 | Send_Player(plr, MakeMsg("You Have Been Released By: %s.", CD->USER.c_str())); |
---|
649 | sReason = " \00313["+_PARAMS[0]+"] : Has Been Released By: "+CD->USER+"."; |
---|
650 | Send_IRCA(ChanOrPM(CD), sReason, true, CD->TYPE); |
---|
651 | } |
---|
652 | } |
---|
653 | else |
---|
654 | { |
---|
655 | if(_PARAMS[1] == "") |
---|
656 | _PARAMS[1] = "No Reason Given."; |
---|
657 | plr->TeleportTo(13, 0, 0, 0, 0); |
---|
658 | plr->SetMovement(MOVE_ROOT); |
---|
659 | plr->CastSpell(plr, 42201, true); |
---|
660 | plr->CastSpell(plr, 23775, true); |
---|
661 | plr->CastSpell(plr, 9454, true); |
---|
662 | Send_Player(plr, MakeMsg("You Have Been Jailed By: %s. Reason: %s.", CD->USER.c_str(), _PARAMS[1].c_str())); |
---|
663 | sReason = " \00313["+_PARAMS[0]+"] : Has Been Jailed By: "+CD->USER+". Reason: "+_PARAMS[1]+"."; |
---|
664 | Send_IRCA(ChanOrPM(CD), sReason, true, CD->TYPE); |
---|
665 | } |
---|
666 | } |
---|
667 | else |
---|
668 | Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR"); |
---|
669 | } |
---|
670 | } |
---|
671 | |
---|
672 | void IRCCmd::Kick_Player(_CDATA *CD) |
---|
673 | { |
---|
674 | std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT); |
---|
675 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
676 | { |
---|
677 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
678 | return; |
---|
679 | } |
---|
680 | if(_PARAMS[1] == "") |
---|
681 | _PARAMS[1] = "No Reason Given."; |
---|
682 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
683 | { |
---|
684 | plr->GetSession()->KickPlayer(); |
---|
685 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Been Kicked By: "+CD->USER+". Reason: "+_PARAMS[1]+".", true, CD->TYPE); |
---|
686 | } |
---|
687 | else |
---|
688 | Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR"); |
---|
689 | } |
---|
690 | |
---|
691 | void IRCCmd::Kill_Player(_CDATA *CD) |
---|
692 | { |
---|
693 | std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT); |
---|
694 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
695 | { |
---|
696 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
697 | return; |
---|
698 | } |
---|
699 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
700 | { |
---|
701 | if(plr->isAlive()) |
---|
702 | { |
---|
703 | plr->DealDamage(plr, plr->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
---|
704 | plr->SaveToDB(); |
---|
705 | if(_PARAMS[1] == "") |
---|
706 | _PARAMS[1] = "No Reason Given."; |
---|
707 | Send_IRCA(ChanOrPM(CD), MakeMsg("\00313[%s] : Has Been Killed By: %s.", _PARAMS[0].c_str(), CD->USER.c_str()) + + + " Reason: "+_PARAMS[1]+".", true, CD->TYPE); |
---|
708 | Send_Player(plr, MakeMsg("You Have Been Killed By: %s. Reason: %s.", CD->USER.c_str(), _PARAMS[1].c_str())); |
---|
709 | } |
---|
710 | else |
---|
711 | Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Already Dead!", true, "ERROR"); |
---|
712 | } |
---|
713 | else |
---|
714 | Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR"); |
---|
715 | } |
---|
716 | |
---|
717 | void IRCCmd::Lookup_Player(_CDATA *CD) |
---|
718 | { |
---|
719 | std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT); |
---|
720 | if(_PARAMS[0] == "acct") |
---|
721 | { |
---|
722 | uint32 acctid = atoi(_PARAMS[1].c_str()); |
---|
723 | if(objmgr.GetAccountByAccountName(_PARAMS[1])) |
---|
724 | acctid = objmgr.GetAccountByAccountName(_PARAMS[1]); |
---|
725 | if(acctid > 0) |
---|
726 | { |
---|
727 | std::string DateTime = "%a, %b %d, %Y - %h:%i%p"; |
---|
728 | QueryResult *result = loginDatabase.PQuery("SELECT id, username, gmlevel, last_ip, (SELECT banreason FROM account_banned WHERE id = %d LIMIT 1) as banned, (SELECT banreason FROM ip_banned WHERE ip = last_ip) as bannedip, DATE_FORMAT(last_login, '%s') FROM `account` WHERE id = %d", acctid, DateTime.c_str(), acctid, acctid); |
---|
729 | if(result) |
---|
730 | { |
---|
731 | Field *fields = result->Fetch(); |
---|
732 | |
---|
733 | uint32 id = fields[0].GetUInt32(); |
---|
734 | std::string usrname = fields[1].GetCppString(); |
---|
735 | uint32 gm = fields[2].GetUInt32(); |
---|
736 | std::string lastip = fields[3].GetCppString(); |
---|
737 | std::string banreason = fields[4].GetCppString(); |
---|
738 | std::string banreasonip = fields[5].GetCppString(); |
---|
739 | std::string lastlogin = fields[6].GetCppString(); |
---|
740 | delete result; |
---|
741 | |
---|
742 | QueryResult *chars = CharacterDatabase.PQuery("SELECT guid, name, (SELECT SUM(totaltime) FROM characters WHERE account = %d) AS tottime FROM characters WHERE account = %u", id, id); |
---|
743 | std::string characters = "None"; |
---|
744 | std::string totaccttime = "Never Logged In"; |
---|
745 | if(chars) |
---|
746 | { |
---|
747 | characters = ""; |
---|
748 | Field *fields = chars->Fetch(); |
---|
749 | totaccttime = SecToDay(fields[2].GetCppString()); |
---|
750 | for (uint64 i=0; i < chars->GetRowCount(); i++) |
---|
751 | { |
---|
752 | std::string guid = fields[0].GetCppString(); |
---|
753 | std::string charname = fields[1].GetCppString(); |
---|
754 | characters.append(charname+"("+guid+"), "); |
---|
755 | chars->NextRow(); |
---|
756 | } |
---|
757 | delete chars; |
---|
758 | } |
---|
759 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Username:\x3\x31\x30 %s \xF|\x2 AccountID:\x3\x31\x30 %d \xF|\x2 GM Level:\x3\x31\x30 %d \xF|\x2 Last IP:\x3\x31\x30 %s \xF|\x2 Last Login:\x3\x31\x30 %s", usrname.c_str(), id, gm, lastip.c_str(), lastlogin.c_str()), true, CD->TYPE); |
---|
760 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Total Play Time:\x3\x31\x30 %s \xF|\x2 Characters:\x3\x31\x30 %s ", totaccttime.c_str(), characters.c_str()), true, CD->TYPE); |
---|
761 | if(banreason.length() > 1) |
---|
762 | Send_IRCA(ChanOrPM(CD), MakeMsg("\0034This User Has An Account Ban. Ban Reason: %s", banreason.c_str()), true, CD->TYPE); |
---|
763 | if(banreasonip.length() > 1) |
---|
764 | Send_IRCA(ChanOrPM(CD), MakeMsg("\0034This User Has An IP Ban. Ban Reason: %s", banreasonip.c_str()), true, CD->TYPE); |
---|
765 | } |
---|
766 | else |
---|
767 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Account ID." ,true, "ERROR"); |
---|
768 | } |
---|
769 | else |
---|
770 | { |
---|
771 | QueryResult *result = loginDatabase.PQuery("SELECT id, username FROM `account` WHERE username LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str()); |
---|
772 | if(result) |
---|
773 | { |
---|
774 | Field *fields = result->Fetch(); |
---|
775 | std::string accts = "\002Account Search Results:\x3\x31\x30 "; |
---|
776 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
777 | { |
---|
778 | std::string acctid = fields[0].GetCppString(); |
---|
779 | std::string acctname = fields[1].GetCppString(); |
---|
780 | accts.append(acctname+"("+acctid+")\xF | \x3\x31\x30\x2"); |
---|
781 | result->NextRow(); |
---|
782 | } |
---|
783 | delete result; |
---|
784 | Send_IRCA(ChanOrPM(CD), accts, true, CD->TYPE); |
---|
785 | } |
---|
786 | else |
---|
787 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Username. I Cant Find Any Users With Those Search Terms." ,true, "ERROR"); |
---|
788 | } |
---|
789 | } |
---|
790 | if(_PARAMS[0] == "char") |
---|
791 | { |
---|
792 | uint32 plguid = atoi(_PARAMS[1].c_str()); |
---|
793 | if(objmgr.GetPlayerGUIDByName(_PARAMS[1].c_str())) |
---|
794 | plguid = objmgr.GetPlayerGUIDByName(_PARAMS[1].c_str()); |
---|
795 | if(plguid > 0) |
---|
796 | { |
---|
797 | QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, name, race, class, online, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 35), ' ' , -1) AS level, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 238), ' ' , -1) AS guildid, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 239), ' ' , -1) AS guildrank, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 927), ' ' , -1) AS xp, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 928), ' ' , -1) AS maxxp, SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ' , 1462), ' ' , -1) AS gold, SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, ' ' , 1454), ' ' , -1) AS hk, SEC_TO_TIME(totaltime) AS tottime FROM characters WHERE guid =%i", plguid); |
---|
798 | uint32 latency = 0; |
---|
799 | Player *chr = objmgr.GetPlayer(plguid); |
---|
800 | if(chr) |
---|
801 | { |
---|
802 | latency = chr->GetSession()->GetLatency(); |
---|
803 | } |
---|
804 | char templatency [100]; |
---|
805 | sprintf(templatency, "%ums", latency); |
---|
806 | if(result) |
---|
807 | { |
---|
808 | Field *fields = result->Fetch(); |
---|
809 | std::string pguid = fields[0].GetCppString(); |
---|
810 | std::string pacct = fields[1].GetCppString(); |
---|
811 | std::string pname = fields[2].GetCppString(); |
---|
812 | uint32 praceid = fields[3].GetUInt32(); |
---|
813 | uint32 pclassid = fields[4].GetUInt32(); |
---|
814 | std::string ponline = (fields[5].GetInt32() == 1 ? "\x3\x30\x33Online" : "\x3\x30\x34Offline\xF"); |
---|
815 | std::string plevel = fields[6].GetCppString(); |
---|
816 | uint32 pguildid = fields[7].GetUInt32(); |
---|
817 | uint32 pguildrank = fields[8].GetUInt32(); |
---|
818 | std::string pxp = fields[9].GetCppString(); |
---|
819 | std::string pmaxxp = fields[10].GetCppString(); |
---|
820 | unsigned int money = fields[11].GetInt32(); |
---|
821 | std::string hk = fields[12].GetCppString(); |
---|
822 | std::string totaltim = SecToDay(fields[13].GetCppString()); |
---|
823 | delete result; |
---|
824 | std::string sqlquery = "SELECT `gmlevel` FROM `account` WHERE `id` = '" + pacct + "';"; |
---|
825 | QueryResult *result = loginDatabase.Query(sqlquery.c_str()); |
---|
826 | Field *fields2 = result->Fetch(); |
---|
827 | std::string pgmlvl = fields2[0].GetCppString(); |
---|
828 | delete result; |
---|
829 | std::string guildinfo = ""; |
---|
830 | if (pguildid != 0) |
---|
831 | { |
---|
832 | Guild* guild = objmgr.GetGuildById(pguildid); |
---|
833 | if (guild) |
---|
834 | { |
---|
835 | guildinfo = " " + guild->GetRankName(pguildrank) + " Of " + guild->GetName(); |
---|
836 | } |
---|
837 | } |
---|
838 | else guildinfo = " None"; |
---|
839 | ChrRacesEntry const* prace = sChrRacesStore.LookupEntry(praceid); |
---|
840 | ChrClassesEntry const* pclass = sChrClassesStore.LookupEntry(pclassid); |
---|
841 | |
---|
842 | if (atoi(plevel.c_str()) < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) |
---|
843 | plevel += " (" + pxp + "/" + pmaxxp + ")"; |
---|
844 | unsigned int gold = money / 10000; |
---|
845 | unsigned int silv = (money % 10000) / 100; |
---|
846 | unsigned int cop = (money % 10000) % 100; |
---|
847 | char tempgold [100]; |
---|
848 | sprintf(tempgold, "\x2\x3\x30\x37%ug \x3\x31\x34%us \x3\x30\x35%uc\xF", gold, silv, cop); |
---|
849 | if (ponline == "\x3\x30\x33Online") |
---|
850 | { |
---|
851 | Player * plr = ObjectAccessor::Instance().FindPlayerByName(pname.c_str()); |
---|
852 | if (plr) |
---|
853 | { |
---|
854 | AreaTableEntry const* area = GetAreaEntryByAreaID(plr->GetAreaId()); |
---|
855 | ponline += " in " + (std::string) area->area_name[sWorld.GetDefaultDbcLocale()]; |
---|
856 | if (area->zone != 0) |
---|
857 | { |
---|
858 | AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone); |
---|
859 | ponline += " (" + (std::string)zone->area_name[sWorld.GetDefaultDbcLocale()] + ")"; |
---|
860 | } |
---|
861 | } |
---|
862 | } |
---|
863 | std::string pinfo = "\x2 About Player:\x3\x31\x30 " +pname+ "\xF |\x2 GM Level:\x3\x31\x30 " +pgmlvl+ "\xF |\x2 AcctID:\x3\x31\x30 " +pacct+ "\xF |\x2 CharID:\x3\x31\x30 " +pguid+ " \xF |\x2 Played Time:\x2\x3\x31\x30 " +totaltim+" \xF |\x2 Latency:\x2\x3\x31\x30 "+templatency; |
---|
864 | std::string pinfo2 = "\x2 Race:\x2\x3\x31\x30 " + (std::string)prace->name[sWorld.GetDefaultDbcLocale()] + "\xF |\x2 Class:\x2\x3\x31\x30 " + (std::string)pclass->name[sWorld.GetDefaultDbcLocale()] + "\xF |\x2 Level:\x2\x3\x31\x30 " + plevel + "\xF |\x2 Money:\x2 " + tempgold + "\xF |\x2 Guild Info:\x2\x3\x31\x30 "+guildinfo+"\xF |\x2 Status:\x2 " + ponline; |
---|
865 | // pinfo3 = " :" + " \x2Honor Kills:\x2\x3\x31\x30 " + hk; |
---|
866 | Send_IRCA(ChanOrPM(CD),pinfo , true, CD->TYPE); |
---|
867 | Send_IRCA(ChanOrPM(CD),pinfo2 , true, CD->TYPE); |
---|
868 | // Send_IRCA(ChanOrPM(CD),pinfo3 , true, CD->TYPE); |
---|
869 | } |
---|
870 | else |
---|
871 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Character ID. (GUID)" ,true, "ERROR"); |
---|
872 | } |
---|
873 | else |
---|
874 | { |
---|
875 | QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, name FROM characters WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str()); |
---|
876 | if(result) |
---|
877 | { |
---|
878 | Field *fields = result->Fetch(); |
---|
879 | std::string items = "\x2 Character Search Results:\x3\x31\x30 "; |
---|
880 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
881 | { |
---|
882 | std::string guid = fields[0].GetCppString(); |
---|
883 | std::string account = fields[1].GetCppString(); |
---|
884 | std::string name = fields[2].GetCppString(); |
---|
885 | MakeUpper(name); |
---|
886 | items.append(name+"(Account:"+account+" - GUID:"+guid+")\xF | \x3\x31\x30\x2"); |
---|
887 | result->NextRow(); |
---|
888 | } |
---|
889 | delete result; |
---|
890 | Send_IRCA(ChanOrPM(CD), items, true, CD->TYPE); |
---|
891 | } |
---|
892 | else |
---|
893 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Character. I Cant Find Any Characters With Those Search Terms." ,true, "ERROR"); |
---|
894 | } |
---|
895 | } |
---|
896 | if(_PARAMS[0] == "creature") |
---|
897 | { |
---|
898 | std::string creature = _PARAMS[1]; |
---|
899 | if(atoi(creature.c_str()) > 0) |
---|
900 | { |
---|
901 | WorldDatabase.escape_string(_PARAMS[1]); |
---|
902 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, modelid_A, name, (minlevel*maxlevel/2) as level, faction_A, armor, (SELECT count(*) FROM creature WHERE id = '%s') as spawns FROM creature_template WHERE entry = '%s';", _PARAMS[1].c_str(), _PARAMS[1].c_str()); |
---|
903 | if(result) |
---|
904 | { |
---|
905 | Field *fields = result->Fetch(); |
---|
906 | |
---|
907 | uint32 entry = fields[0].GetUInt32(); |
---|
908 | uint32 modelid = fields[1].GetUInt32(); |
---|
909 | std::string name = fields[2].GetCppString(); |
---|
910 | uint32 level = fields[3].GetUInt32(); |
---|
911 | uint32 faction = fields[4].GetUInt32(); |
---|
912 | uint32 armor = fields[5].GetUInt32(); |
---|
913 | uint32 spawns = fields[6].GetUInt32(); |
---|
914 | delete result; |
---|
915 | |
---|
916 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Name:\x3\x31\x30 %s \xF|\x2 CreatureID:\x3\x31\x30 %d \xF|\x2 DisplayID:\x3\x31\x30 %d \xF|\x2 Spawns:\x3\x31\x30 %d", name.c_str(), entry, modelid, spawns), true, CD->TYPE); |
---|
917 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Level:\x3\x31\x30 %d \xF|\x2 Faction:\x3\x31\x30 %d \xF|\x2 Armor:\x3\x31\x30 %d", level, faction, armor), true, CD->TYPE); |
---|
918 | } |
---|
919 | else |
---|
920 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Creature ID." ,true, "ERROR"); |
---|
921 | } |
---|
922 | else |
---|
923 | { |
---|
924 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, name FROM creature_template WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str()); |
---|
925 | if(result) |
---|
926 | { |
---|
927 | Field *fields = result->Fetch(); |
---|
928 | std::string items = "\002Creature Search Results:\x3\x31\x30 "; |
---|
929 | //Send_IRCA(ChanOrPM(CD), "", true, CD->TYPE); |
---|
930 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
931 | { |
---|
932 | std::string CreatureID = fields[0].GetCppString(); |
---|
933 | std::string Name = fields[1].GetCppString(); |
---|
934 | items.append(Name+"("+CreatureID+")\xF | \x3\x31\x30\x2"); |
---|
935 | result->NextRow(); |
---|
936 | } |
---|
937 | delete result; |
---|
938 | Send_IRCA(ChanOrPM(CD), items, true, CD->TYPE); |
---|
939 | } |
---|
940 | else |
---|
941 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Creature. I Cant Find Any Creatures With Those Search Terms." ,true, "ERROR"); |
---|
942 | } |
---|
943 | } |
---|
944 | if(_PARAMS[0] == "faction") |
---|
945 | { |
---|
946 | std::string faction = _PARAMS[1]; |
---|
947 | if(atoi(faction.c_str()) > 0) |
---|
948 | { |
---|
949 | FactionEntry const *factionEntry = sFactionStore.LookupEntry(atoi(faction.c_str())); |
---|
950 | if(factionEntry) |
---|
951 | { |
---|
952 | std::string name = factionEntry->name[sWorld.GetDefaultDbcLocale()]; |
---|
953 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2 Faction:\x3\x31\x30 %s \xF|\x2 FactionID:\x3\x31\x30 %s",name.c_str(), faction.c_str()), true, CD->TYPE); |
---|
954 | } |
---|
955 | else |
---|
956 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown FactionID." ,true, "ERROR"); |
---|
957 | |
---|
958 | } |
---|
959 | else |
---|
960 | { |
---|
961 | uint32 counter = 0; |
---|
962 | std::string factions = "\002Faction Search Results:\x3\x31\x30 "; |
---|
963 | for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++) |
---|
964 | { |
---|
965 | FactionEntry const *factionEntry = sFactionStore.LookupEntry(id); |
---|
966 | if(factionEntry) |
---|
967 | { |
---|
968 | MakeLower( _PARAMS[1] ); |
---|
969 | std::string name = factionEntry->name[sWorld.GetDefaultDbcLocale()]; |
---|
970 | MakeLower( name ); |
---|
971 | if (name.find(_PARAMS[1]) != std::string::npos && counter < 10) |
---|
972 | { |
---|
973 | char factionid[100]; |
---|
974 | sprintf(factionid, "%d", id); |
---|
975 | factions.append(name+"("+factionid+")\xF | \x3\x31\x30\x2"); |
---|
976 | ++counter; |
---|
977 | } |
---|
978 | } |
---|
979 | } |
---|
980 | if(counter == 0) |
---|
981 | factions.append("No Factions Found."); |
---|
982 | Send_IRCA(ChanOrPM(CD), factions, true, CD->TYPE); |
---|
983 | } |
---|
984 | } |
---|
985 | if(_PARAMS[0] == "go") |
---|
986 | { |
---|
987 | std::string gobject = _PARAMS[1]; |
---|
988 | if(atoi(gobject.c_str()) > 0) |
---|
989 | { |
---|
990 | WorldDatabase.escape_string(_PARAMS[1]); |
---|
991 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, type, displayId, name, faction, (SELECT count(*) FROM gameobject WHERE id = '%s') as spawns FROM gameobject_template WHERE entry = '%s';", _PARAMS[1].c_str(), _PARAMS[1].c_str()); |
---|
992 | if(result) |
---|
993 | { |
---|
994 | Field *fields = result->Fetch(); |
---|
995 | |
---|
996 | uint32 entry = fields[0].GetUInt32(); |
---|
997 | uint32 type = fields[1].GetUInt32(); |
---|
998 | uint32 modelid = fields[2].GetUInt32(); |
---|
999 | std::string name = fields[3].GetCppString(); |
---|
1000 | uint32 faction = fields[4].GetUInt32(); |
---|
1001 | uint32 spawns = fields[5].GetUInt32(); |
---|
1002 | delete result; |
---|
1003 | |
---|
1004 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2GO Name:\x3\x31\x30 %s \xF|\x2 GameobjectID:\x3\x31\x30 %d \xF|\x2 DisplayID:\x3\x31\x30 %d \xF|\x2 Spawns:\x3\x31\x30 %d", name.c_str(), entry, modelid, spawns), true, CD->TYPE); |
---|
1005 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Type:\x3\x31\x30 %d \xF|\x2 Faction:\x3\x31\x30 %d", type, faction), true, CD->TYPE); |
---|
1006 | } |
---|
1007 | else |
---|
1008 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Creature ID." ,true, "ERROR"); |
---|
1009 | } |
---|
1010 | else |
---|
1011 | { |
---|
1012 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, name FROM gameobject_template WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str()); |
---|
1013 | if(result) |
---|
1014 | { |
---|
1015 | Field *fields = result->Fetch(); |
---|
1016 | std::string gos = "\002Gameobject Search Results:\x3\x31\x30 "; |
---|
1017 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1018 | { |
---|
1019 | std::string GOID = fields[0].GetCppString(); |
---|
1020 | std::string GoName = fields[1].GetCppString(); |
---|
1021 | gos.append(GoName+"("+GOID+")\xF | \x3\x31\x30\x2"); |
---|
1022 | result->NextRow(); |
---|
1023 | } |
---|
1024 | delete result; |
---|
1025 | Send_IRCA(ChanOrPM(CD), gos, true, CD->TYPE); |
---|
1026 | } |
---|
1027 | else |
---|
1028 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Game Object. I Cant Find Any Game Object's With Those Search Terms." ,true, "ERROR"); |
---|
1029 | } |
---|
1030 | } |
---|
1031 | if(_PARAMS[0] == "item") |
---|
1032 | { |
---|
1033 | std::string item = _PARAMS[1]; |
---|
1034 | if(atoi(item.c_str()) > 0) |
---|
1035 | { |
---|
1036 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, name, displayid, (SELECT count(*) FROM creature_loot_template WHERE item = '%s') as loot FROM `item_template` WHERE entry = %s", _PARAMS[1].c_str(), _PARAMS[1].c_str()); |
---|
1037 | if(result) |
---|
1038 | { |
---|
1039 | Field *fields = result->Fetch(); |
---|
1040 | QueryResult *result2 = CharacterDatabase.PQuery("SELECT count(*) FROM `character_inventory` WHERE item_template = %s", _PARAMS[1].c_str()); |
---|
1041 | Field *fields2 = result2->Fetch(); |
---|
1042 | uint32 charcnt = fields2[0].GetUInt32(); |
---|
1043 | delete result2; |
---|
1044 | |
---|
1045 | uint32 ItemID = fields[0].GetUInt32(); |
---|
1046 | std::string ItmName = fields[1].GetCppString(); |
---|
1047 | uint32 DisplayID = fields[2].GetUInt32(); |
---|
1048 | uint32 loots = 0; |
---|
1049 | loots = fields[3].GetUInt32(); |
---|
1050 | delete result; |
---|
1051 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Item:\x3\x31\x30 %s \xF|\x2 ItemID:\x3\x31\x30 %d \xF|\x2 DisplayID:\x3\x31\x30 %d \xF|\x2 Owned By:\x3\x31\x30 %d players \xF|\x2 Dropped By:\x3\x31\x30 %d creatures", ItmName.c_str(), ItemID, DisplayID, charcnt, loots), true, CD->TYPE); |
---|
1052 | } |
---|
1053 | else |
---|
1054 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown ItemID." ,true, "ERROR"); |
---|
1055 | } |
---|
1056 | else |
---|
1057 | { |
---|
1058 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, name FROM `item_template` WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str()); |
---|
1059 | if(result) |
---|
1060 | { |
---|
1061 | Field *fields = result->Fetch(); |
---|
1062 | std::string items = "\002Item Search Results:\x3\x31\x30 "; |
---|
1063 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1064 | { |
---|
1065 | std::string ItemID = fields[0].GetCppString(); |
---|
1066 | std::string ItemName = fields[1].GetCppString(); |
---|
1067 | items.append(ItemName+"("+ItemID+")\xF | \x3\x31\x30\x2"); |
---|
1068 | result->NextRow(); |
---|
1069 | } |
---|
1070 | delete result; |
---|
1071 | Send_IRCA(ChanOrPM(CD), items, true, CD->TYPE); |
---|
1072 | } |
---|
1073 | else |
---|
1074 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Item. I Cant Find Any Items With Those Search Terms." ,true, "ERROR"); |
---|
1075 | } |
---|
1076 | } |
---|
1077 | if(_PARAMS[0] == "quest") |
---|
1078 | { |
---|
1079 | std::string quest = _PARAMS[1]; |
---|
1080 | if(atoi(quest.c_str()) > 0) |
---|
1081 | { |
---|
1082 | WorldDatabase.escape_string(_PARAMS[1]); |
---|
1083 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, Title FROM quest_template WHERE entry = '%s';", _PARAMS[1].c_str(), _PARAMS[1].c_str()); |
---|
1084 | if(result) |
---|
1085 | { |
---|
1086 | QueryResult *result2 = CharacterDatabase.PQuery("SELECT count(*) FROM character_queststatus WHERE quest = '%s' AND status = '1';", _PARAMS[1].c_str()); |
---|
1087 | Field *fields2 = result2->Fetch(); |
---|
1088 | uint32 status = fields2[0].GetUInt32(); |
---|
1089 | delete result2; |
---|
1090 | |
---|
1091 | Field *fields = result->Fetch(); |
---|
1092 | uint32 entry = fields[0].GetUInt32(); |
---|
1093 | std::string name = fields[1].GetCppString(); |
---|
1094 | delete result; |
---|
1095 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Quest Name:\x3\x31\x30 %s \xF|\x2 QuestID:\x3\x31\x30 %d \xF|\x2 Completed:\x3\x31\x30 %d times", name.c_str(), entry, status), true, CD->TYPE); |
---|
1096 | } |
---|
1097 | else |
---|
1098 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Quest ID." ,true, "ERROR"); |
---|
1099 | } |
---|
1100 | else |
---|
1101 | { |
---|
1102 | QueryResult *result = WorldDatabase.PQuery("SELECT entry, Title FROM quest_template WHERE Title LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str()); |
---|
1103 | if(result) |
---|
1104 | { |
---|
1105 | Field *fields = result->Fetch(); |
---|
1106 | std::string quests = "\002Quest Search Results:\x3\x31\x30 "; |
---|
1107 | //Send_IRCA(ChanOrPM(CD), "", true, CD->TYPE); |
---|
1108 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1109 | { |
---|
1110 | std::string QuestID = fields[0].GetCppString(); |
---|
1111 | std::string QuestName = fields[1].GetCppString(); |
---|
1112 | quests.append(QuestName+"("+QuestID+")\xF | \x3\x31\x30\x2"); |
---|
1113 | result->NextRow(); |
---|
1114 | } |
---|
1115 | delete result; |
---|
1116 | Send_IRCA(ChanOrPM(CD), quests, true, CD->TYPE); |
---|
1117 | } |
---|
1118 | else |
---|
1119 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Quest. I Cant Find Any Quest's With Those Search Terms." ,true, "ERROR"); |
---|
1120 | } |
---|
1121 | } |
---|
1122 | if(_PARAMS[0] == "skill") |
---|
1123 | { |
---|
1124 | std::string skill = _PARAMS[1]; |
---|
1125 | if(atoi(skill.c_str()) > 0) |
---|
1126 | { |
---|
1127 | SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(atoi(skill.c_str())); |
---|
1128 | if(skillInfo) |
---|
1129 | { |
---|
1130 | std::string name = skillInfo->name[sWorld.GetDefaultDbcLocale()]; |
---|
1131 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Skill:\x3\x31\x30 %s \xF|\x2 SkillID:\x3\x31\x30 %s",name.c_str(), skill.c_str()), true, CD->TYPE); |
---|
1132 | } |
---|
1133 | else |
---|
1134 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown SkillID." ,true, "ERROR"); |
---|
1135 | |
---|
1136 | } |
---|
1137 | else |
---|
1138 | { |
---|
1139 | uint32 counter = 0; |
---|
1140 | std::string skills = "\002Skill Search Results:\x3\x31\x30 "; |
---|
1141 | for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++) |
---|
1142 | { |
---|
1143 | SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id); |
---|
1144 | if(skillInfo) |
---|
1145 | { |
---|
1146 | MakeLower( _PARAMS[1] ); |
---|
1147 | std::string name = skillInfo->name[sWorld.GetDefaultDbcLocale()]; |
---|
1148 | MakeLower( name ); |
---|
1149 | if (name.find(_PARAMS[1]) != std::string::npos && counter < 10) |
---|
1150 | { |
---|
1151 | char skillid[100]; |
---|
1152 | sprintf(skillid, "%d", id); |
---|
1153 | skills.append(name+"("+skillid+")\xF | \x3\x31\x30\x2"); |
---|
1154 | ++counter; |
---|
1155 | } |
---|
1156 | } |
---|
1157 | } |
---|
1158 | if(counter == 0) |
---|
1159 | skills.append("No Skills Found."); |
---|
1160 | Send_IRCA(ChanOrPM(CD), skills, true, CD->TYPE); |
---|
1161 | } |
---|
1162 | } |
---|
1163 | if(_PARAMS[0] == "spell") |
---|
1164 | { |
---|
1165 | std::string spell = _PARAMS[1]; |
---|
1166 | if(atoi(spell.c_str()) > 0) |
---|
1167 | { |
---|
1168 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(atoi(spell.c_str())); |
---|
1169 | if(spellInfo) |
---|
1170 | { |
---|
1171 | std::string name = spellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; |
---|
1172 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Spell:\x3\x31\x30 %s \xF|\x2 SpellID:\x3\x31\x30 %s",name.c_str(), spell.c_str()), true, CD->TYPE); |
---|
1173 | } |
---|
1174 | else |
---|
1175 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown SpellID." ,true, "ERROR"); |
---|
1176 | |
---|
1177 | } |
---|
1178 | else |
---|
1179 | { |
---|
1180 | uint32 counter = 0; |
---|
1181 | std::string spells = "\002Spell Search Results:\x3\x31\x30 "; |
---|
1182 | for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++) |
---|
1183 | { |
---|
1184 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(id); |
---|
1185 | if(spellInfo) |
---|
1186 | { |
---|
1187 | MakeLower( _PARAMS[1] ); |
---|
1188 | std::string name = spellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; |
---|
1189 | MakeLower( name ); |
---|
1190 | if (name.find(_PARAMS[1]) != std::string::npos && counter < 10) |
---|
1191 | { |
---|
1192 | char itemid[100]; |
---|
1193 | sprintf(itemid, "%d", id); |
---|
1194 | spells.append(name+"("+itemid+")\xF | \x3\x31\x30\x2"); |
---|
1195 | ++counter; |
---|
1196 | } |
---|
1197 | } |
---|
1198 | } |
---|
1199 | if(counter == 0) |
---|
1200 | spells.append("No Spells Found."); |
---|
1201 | Send_IRCA(ChanOrPM(CD), spells, true, CD->TYPE); |
---|
1202 | } |
---|
1203 | } |
---|
1204 | if(_PARAMS[0] == "tele") |
---|
1205 | { |
---|
1206 | std::string tele = _PARAMS[1]; |
---|
1207 | if(atoi(tele.c_str()) > 0) |
---|
1208 | { |
---|
1209 | QueryResult *result = WorldDatabase.PQuery("SELECT * FROM `game_tele` WHERE id = %s", _PARAMS[1].c_str()); |
---|
1210 | if(result) |
---|
1211 | { |
---|
1212 | Field *fields = result->Fetch(); |
---|
1213 | |
---|
1214 | uint32 teleid = fields[0].GetUInt32(); |
---|
1215 | uint32 pos_x = fields[1].GetUInt32(); |
---|
1216 | uint32 pos_y = fields[2].GetUInt32(); |
---|
1217 | uint32 pos_z = fields[3].GetUInt32(); |
---|
1218 | uint32 oriet = fields[4].GetUInt32(); |
---|
1219 | uint32 map = fields[5].GetUInt32(); |
---|
1220 | std::string telname = fields[6].GetCppString(); |
---|
1221 | delete result; |
---|
1222 | |
---|
1223 | Send_IRCA(ChanOrPM(CD), MakeMsg("\x2Tele Name:\x3\x31\x30 %s \xF|\x2 TeleID:\x3\x31\x30 %d \xF|\x2 Coordinates:\x3\x31\x30 [X: %d, Y: %d, Z: %d, MAP: %d, Orientation: %d]", telname.c_str(), teleid, pos_x, pos_y, pos_z, map, oriet), true, CD->TYPE); |
---|
1224 | } |
---|
1225 | else |
---|
1226 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Teleport Location ID." ,true, "ERROR"); |
---|
1227 | } |
---|
1228 | else |
---|
1229 | { |
---|
1230 | QueryResult *result = WorldDatabase.PQuery("SELECT id, name FROM `game_tele` WHERE name LIKE '%%%s%%' LIMIT 10", _PARAMS[1].c_str()); |
---|
1231 | if(result) |
---|
1232 | { |
---|
1233 | Field *fields = result->Fetch(); |
---|
1234 | std::string teles = "\002Tele Location Search Results:\x3\x31\x30 "; |
---|
1235 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1236 | { |
---|
1237 | std::string TeleID = fields[0].GetCppString(); |
---|
1238 | std::string TeleName = fields[1].GetCppString(); |
---|
1239 | teles.append(TeleName+"("+TeleID+")\xF | \x3\x31\x30\x2"); |
---|
1240 | result->NextRow(); |
---|
1241 | } |
---|
1242 | Send_IRCA(ChanOrPM(CD), teles, true, CD->TYPE); |
---|
1243 | delete result; |
---|
1244 | } |
---|
1245 | else |
---|
1246 | Send_IRCA(CD->USER, "\0034[ERROR] : Unknown Item. I Cant Find Any Items With Those Search Terms." ,true, "ERROR"); |
---|
1247 | } |
---|
1248 | } |
---|
1249 | } |
---|
1250 | |
---|
1251 | void IRCCmd::Level_Player(_CDATA *CD) |
---|
1252 | { |
---|
1253 | std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT); |
---|
1254 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
1255 | { |
---|
1256 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
1257 | return; |
---|
1258 | } |
---|
1259 | std::string player = _PARAMS[0]; |
---|
1260 | normalizePlayerName(player); |
---|
1261 | uint64 guid = objmgr.GetPlayerGUIDByName(player.c_str()); |
---|
1262 | std::string s_newlevel = _PARAMS[1]; |
---|
1263 | uint8 i_newlvl = atoi(s_newlevel.c_str()); |
---|
1264 | if(!guid) |
---|
1265 | { |
---|
1266 | Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Found!", true, "ERROR"); |
---|
1267 | return; |
---|
1268 | } else if ( i_newlvl < 1 || i_newlvl > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL) ) |
---|
1269 | { |
---|
1270 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Level Must Be Between 1 And %i!",sConfig.GetIntDefault("MaxPlayerLevel", 70)), true, "ERROR"); |
---|
1271 | return; |
---|
1272 | } else |
---|
1273 | { |
---|
1274 | Player *chr = objmgr.GetPlayer(guid); |
---|
1275 | int32 i_oldlvl = chr ? chr->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,guid); |
---|
1276 | if(chr) |
---|
1277 | { |
---|
1278 | chr->GiveLevel(i_newlvl); |
---|
1279 | chr->InitTalentForLevel(); |
---|
1280 | chr->SetUInt32Value(PLAYER_XP,0); |
---|
1281 | WorldPacket data; |
---|
1282 | ChatHandler CH(chr->GetSession()); |
---|
1283 | if(i_oldlvl == i_newlvl) |
---|
1284 | CH.FillSystemMessageData(&data, "Your level progress has been reset."); |
---|
1285 | else |
---|
1286 | if(i_oldlvl < i_newlvl) |
---|
1287 | CH.FillSystemMessageData(&data, fmtstring("You have been leveled up (%i)",i_newlvl-i_oldlvl)); |
---|
1288 | else |
---|
1289 | if(i_oldlvl > i_newlvl) |
---|
1290 | CH.FillSystemMessageData(&data, fmtstring("You have been leveled down (%i)",i_newlvl-i_oldlvl)); |
---|
1291 | chr->GetSession()->SendPacket( &data ); |
---|
1292 | } |
---|
1293 | else |
---|
1294 | { |
---|
1295 | Tokens values; |
---|
1296 | Player::LoadValuesArrayFromDB(values,guid); |
---|
1297 | Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,i_newlvl); |
---|
1298 | Player::SetUInt32ValueInArray(values,PLAYER_XP,0); |
---|
1299 | Player::SaveValuesArrayInDB(values,guid); |
---|
1300 | } |
---|
1301 | } |
---|
1302 | Send_IRCA(ChanOrPM(CD), "\00313[" + _PARAMS[0]+ "] : Has Been Leveled To " + _PARAMS[1] + ". By: "+CD->USER+".", true, CD->TYPE); |
---|
1303 | } |
---|
1304 | |
---|
1305 | void IRCCmd::Money_Player(_CDATA *CD) |
---|
1306 | { |
---|
1307 | std::string* _PARAMS = getArray(CD->PARAMS, 2); |
---|
1308 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
1309 | { |
---|
1310 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
1311 | return; |
---|
1312 | } |
---|
1313 | std::string player = _PARAMS[0]; |
---|
1314 | normalizePlayerName(player); |
---|
1315 | uint64 guid = objmgr.GetPlayerGUIDByName(player.c_str()); |
---|
1316 | Player *chr = objmgr.GetPlayer(guid); |
---|
1317 | |
---|
1318 | std::string s_money = _PARAMS[1]; |
---|
1319 | int32 money = atoi(s_money.c_str()); |
---|
1320 | unsigned int gold = money / 10000; |
---|
1321 | unsigned int silv = (money % 10000) / 100; |
---|
1322 | unsigned int cop = (money % 10000) % 100; |
---|
1323 | char tempgold [100]; |
---|
1324 | sprintf(tempgold, "\x2\x3\x30\x37%ug \x3\x31\x34%us \x3\x30\x35%uc\xF", gold, silv, cop); |
---|
1325 | if(!guid) |
---|
1326 | { |
---|
1327 | Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Found!", true, "ERROR"); |
---|
1328 | return; |
---|
1329 | } |
---|
1330 | else |
---|
1331 | { |
---|
1332 | Player *chr = objmgr.GetPlayer(guid); |
---|
1333 | uint32 moneyuser = 0; |
---|
1334 | if(chr) |
---|
1335 | moneyuser = chr->GetMoney(); |
---|
1336 | else { |
---|
1337 | CharacterDatabase.escape_string(player); |
---|
1338 | std::string sqlquery = "SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ' , 1462), ' ' , -1) AS `gold` FROM `characters` WHERE `name` = '"+player+"';"; |
---|
1339 | QueryResult *result = CharacterDatabase.Query(sqlquery.c_str()); |
---|
1340 | Field *fields = result->Fetch(); |
---|
1341 | moneyuser = fields[0].GetInt32(); |
---|
1342 | delete result; |
---|
1343 | } |
---|
1344 | int32 addmoney = money; |
---|
1345 | int32 newmoney = moneyuser + addmoney; |
---|
1346 | char s_newmoney[255]; |
---|
1347 | sprintf(s_newmoney,"%d",newmoney); |
---|
1348 | if(addmoney < 0) |
---|
1349 | { |
---|
1350 | sLog.outDetail("USER1: %i, ADD: %i, DIF: %i\\n", moneyuser, addmoney, newmoney); |
---|
1351 | if(newmoney <= 0 ) |
---|
1352 | { |
---|
1353 | Send_IRCA(ChanOrPM(CD), "\00313["+player+"] : Has Had All Money Taken By: "+CD->USER.c_str()+".", true, CD->TYPE); |
---|
1354 | if(chr) |
---|
1355 | { |
---|
1356 | chr->SetMoney(0); |
---|
1357 | Send_Player(chr, MakeMsg("You Have Been Liquidated By: %s. Total Money Is Now 0.", CD->USER.c_str())); |
---|
1358 | } |
---|
1359 | else |
---|
1360 | CharacterDatabase.PExecute("UPDATE `characters` SET data=concat(substring_index(data,' ',1462-1),' ','%u',' ', right(data,length(data)-length(substring_index(data,' ',1462))-1) ) where guid='%u'",newmoney, guid ); |
---|
1361 | } |
---|
1362 | else |
---|
1363 | { |
---|
1364 | Send_IRCA(ChanOrPM(CD), "\00313["+player+"] : Has Had ("+s_money+"\00313) Taken From Them By: "+CD->USER.c_str()+".", true, CD->TYPE); |
---|
1365 | if(chr) |
---|
1366 | { |
---|
1367 | chr->SetMoney( newmoney ); |
---|
1368 | Send_Player(chr, MakeMsg("You Have Had %s Copper Taken From You By: %s.", _PARAMS[1].c_str(), CD->USER.c_str())); |
---|
1369 | } |
---|
1370 | else |
---|
1371 | CharacterDatabase.PExecute("UPDATE `characters` SET data=concat(substring_index(data,' ',1462-1),' ','%u',' ', right(data,length(data)-length(substring_index(data,' ',1462))-1) ) where guid='%u'",newmoney, guid ); |
---|
1372 | } |
---|
1373 | } |
---|
1374 | else |
---|
1375 | { |
---|
1376 | Send_IRCA(ChanOrPM(CD), "\00313["+player+"] : Has Been Given ("+tempgold+"\00313) From: "+CD->USER.c_str()+".", true, CD->TYPE); |
---|
1377 | if(chr) |
---|
1378 | { |
---|
1379 | chr->ModifyMoney( addmoney ); |
---|
1380 | Send_Player(chr, MakeMsg("You Have Been Given %s Copper. From: %s.", _PARAMS[1].c_str(), CD->USER.c_str())); |
---|
1381 | } |
---|
1382 | else |
---|
1383 | CharacterDatabase.PExecute("UPDATE `characters` SET data=concat(substring_index(data,' ',1462-1),' ','%u',' ', right(data,length(data)-length(substring_index(data,' ',1462))-1) ) where guid='%u'",newmoney, guid ); |
---|
1384 | } |
---|
1385 | } |
---|
1386 | } |
---|
1387 | |
---|
1388 | void IRCCmd::Mute_Player(_CDATA *CD) |
---|
1389 | { |
---|
1390 | std::string* _PARAMS = getArray(CD->PARAMS, 3); |
---|
1391 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
1392 | { |
---|
1393 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
1394 | return; |
---|
1395 | } |
---|
1396 | normalizePlayerName(_PARAMS[0]); |
---|
1397 | uint64 guid = objmgr.GetPlayerGUIDByName(_PARAMS[0]); |
---|
1398 | if(guid) |
---|
1399 | { |
---|
1400 | if(_PARAMS[1] == "release") |
---|
1401 | { |
---|
1402 | Player* plr = objmgr.GetPlayer(guid); |
---|
1403 | uint32 account_id = 0; |
---|
1404 | account_id = objmgr.GetPlayerAccountIdByGUID(guid); |
---|
1405 | loginDatabase.PExecute("UPDATE `account` SET `mutetime` = '0' WHERE `id` = '%u'", account_id ); |
---|
1406 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Been UnMuted By: "+CD->USER+"." , true, CD->TYPE); |
---|
1407 | if(plr) |
---|
1408 | { |
---|
1409 | plr->GetSession()->m_muteTime = 0; |
---|
1410 | Send_Player(plr, MakeMsg("You Have Been UnMuted By: %s.", CD->USER.c_str())); |
---|
1411 | } |
---|
1412 | } |
---|
1413 | else |
---|
1414 | { |
---|
1415 | if(_PARAMS[2] == "") |
---|
1416 | _PARAMS[2] = "No Reason Given"; |
---|
1417 | Player* plr = objmgr.GetPlayer(guid); |
---|
1418 | time_t mutetime = time(NULL) + atoi(_PARAMS[1].c_str())*60; |
---|
1419 | uint32 account_id = 0; |
---|
1420 | account_id = objmgr.GetPlayerAccountIdByGUID(guid); |
---|
1421 | if(plr) plr->GetSession()->m_muteTime = mutetime; |
---|
1422 | loginDatabase.PExecute("UPDATE `account` SET `mutetime` = " I64FMTD " WHERE `id` = '%u'",uint64(mutetime), account_id ); |
---|
1423 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Been Muted By: "+CD->USER+". For: "+_PARAMS[1]+" Minutes. Reason: "+_PARAMS[2] , true, CD->TYPE); |
---|
1424 | if(plr) Send_Player(plr, MakeMsg("You Have Been Muted By: %s. For: %s Minutes. Reason: %s", CD->USER.c_str(), _PARAMS[1].c_str(), _PARAMS[2].c_str())); |
---|
1425 | } |
---|
1426 | } |
---|
1427 | else |
---|
1428 | Send_IRCA(CD->USER, "\0034[ERROR] : Player Does Not Exist!", true, "ERROR"); |
---|
1429 | } |
---|
1430 | |
---|
1431 | void IRCCmd::Online_Players(_CDATA *CD) |
---|
1432 | { |
---|
1433 | sIRC.Script_Lock[MCS_Players_Online] = true; |
---|
1434 | ZThread::Thread script(new mcs_OnlinePlayers(CD)); |
---|
1435 | } |
---|
1436 | |
---|
1437 | void IRCCmd::PM_Player(_CDATA *CD) |
---|
1438 | { |
---|
1439 | std::string* _PARAMS = getArray(CD->PARAMS, 2); |
---|
1440 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
1441 | { |
---|
1442 | if(plr->isAcceptWhispers()) |
---|
1443 | { |
---|
1444 | std::string sMsg = MakeMsg("|cffFE87FD[<IRC>%s] Whispers: %s|r", CD->USER.c_str(), _PARAMS[1].c_str()); |
---|
1445 | WorldPacket data(SMSG_MESSAGECHAT, 200); |
---|
1446 | data << (uint8)CHAT_MSG_SYSTEM; |
---|
1447 | data << (uint32)LANG_UNIVERSAL; |
---|
1448 | data << (uint64)plr->GetGUID(); |
---|
1449 | data << (uint32)0; |
---|
1450 | data << (uint64)plr->GetGUID(); |
---|
1451 | data << (uint32)(sMsg.length()+1); |
---|
1452 | data << sMsg; |
---|
1453 | data << (uint8)0; |
---|
1454 | plr->GetSession()->SendPacket(&data); |
---|
1455 | plr->SendPlaySound(3081, true); |
---|
1456 | Send_IRCA(ChanOrPM(CD), "\00313To ["+_PARAMS[0]+"] : "+_PARAMS[1]+".", true, CD->TYPE); |
---|
1457 | } |
---|
1458 | else |
---|
1459 | Send_IRCA(CD->USER, "\0034[ERROR] : Is Not Accepting Private Messages!", true, "ERROR"); |
---|
1460 | } |
---|
1461 | else |
---|
1462 | Send_IRCA(CD->USER, "\0034[ERROR] : Player not online!", true, "ERROR"); |
---|
1463 | } |
---|
1464 | |
---|
1465 | void IRCCmd::Revive_Player(_CDATA *CD) |
---|
1466 | { |
---|
1467 | std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT); |
---|
1468 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
1469 | { |
---|
1470 | if(plr->isDead()) |
---|
1471 | { |
---|
1472 | plr->ResurrectPlayer(0.5f); |
---|
1473 | plr->SpawnCorpseBones(); |
---|
1474 | plr->SaveToDB(); |
---|
1475 | sIRC.Send_IRC_Channel(ChanOrPM(CD), " \00313["+_PARAMS[0]+"] : Has Been Revived By: " + CD->USER, true, CD->TYPE); |
---|
1476 | Send_Player(plr, MakeMsg("You Have Been Revived By: %s.", CD->USER.c_str())); |
---|
1477 | } |
---|
1478 | else |
---|
1479 | Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Dead!", true, "ERROR"); |
---|
1480 | } |
---|
1481 | else |
---|
1482 | Send_IRCA(CD->USER, "\0034[ERROR] : "+_PARAMS[0]+" Is Not Online!", true, "ERROR"); |
---|
1483 | } |
---|
1484 | |
---|
1485 | void IRCCmd::Saveall_Player(_CDATA *CD) |
---|
1486 | { |
---|
1487 | ObjectAccessor::Instance().SaveAllPlayers(); |
---|
1488 | Send_IRCA(ChanOrPM(CD), "\00313["+CD->USER+"] : Has Saved All Players!", true, CD->TYPE); |
---|
1489 | } |
---|
1490 | |
---|
1491 | void IRCCmd::Shutdown_Mangos(_CDATA *CD) |
---|
1492 | { |
---|
1493 | std::string* _PARAMS = getArray(CD->PARAMS, 1); |
---|
1494 | if(_PARAMS[0] == "cancel") |
---|
1495 | { |
---|
1496 | sWorld.ShutdownCancel(); |
---|
1497 | Send_IRCA(ChanOrPM(CD), "\0034Server Shutdown Has Been Cancelled.", true, CD->TYPE); |
---|
1498 | } |
---|
1499 | |
---|
1500 | int32 i_time = atoi(_PARAMS[0].c_str()); |
---|
1501 | if (i_time <= 0 && _PARAMS[0]!="0") |
---|
1502 | { |
---|
1503 | Send_IRCA(ChanOrPM(CD), "\00313["+CD->USER+"] : Please Enter A Number! And No Negative Numbers! "+_PARAMS[0]+" Seconds!?", true, CD->TYPE); |
---|
1504 | return; |
---|
1505 | } |
---|
1506 | if (i_time > 1) Send_IRCA(ChanOrPM(CD), "\00313["+CD->USER+"] : Has Requested Server To Be Shut Down In "+_PARAMS[0]+" Seconds!", true, CD->TYPE); |
---|
1507 | sWorld.ShutdownServ(i_time); |
---|
1508 | Delay(i_time*1000); |
---|
1509 | Send_IRCA(ChanOrPM(CD), "\0034Server Will Now Shut Down.. Good Bye!", true, CD->TYPE); |
---|
1510 | sIRC.Active = false; |
---|
1511 | sIRC.ResetIRC(); |
---|
1512 | } |
---|
1513 | |
---|
1514 | void IRCCmd::Spell_Player(_CDATA *CD) |
---|
1515 | { |
---|
1516 | std::string* _PARAMS = getArray(CD->PARAMS, 3); |
---|
1517 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
1518 | { |
---|
1519 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
1520 | return; |
---|
1521 | } |
---|
1522 | uint32 spell = atoi(_PARAMS[2].c_str()); |
---|
1523 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell); |
---|
1524 | if (Player* plr = GetPlayer(_PARAMS[0])) |
---|
1525 | { |
---|
1526 | if(spellInfo) |
---|
1527 | { |
---|
1528 | std::string name = spellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; |
---|
1529 | if(_PARAMS[1] == "cast") |
---|
1530 | { |
---|
1531 | plr->CastSpell(plr, spell, true); |
---|
1532 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Had Spell "+name+" Casted On Them.", true, CD->TYPE); |
---|
1533 | } |
---|
1534 | if(_PARAMS[1] == "learn") |
---|
1535 | { |
---|
1536 | plr->learnSpell(spell); |
---|
1537 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Learned Spell "+name+".", true, CD->TYPE); |
---|
1538 | } |
---|
1539 | if(_PARAMS[1] == "unlearn") |
---|
1540 | { |
---|
1541 | plr->removeSpell(spell); |
---|
1542 | Send_IRCA(ChanOrPM(CD), "\00313["+_PARAMS[0]+"] : Has Unlearned Spell "+name+".", true, CD->TYPE); |
---|
1543 | } |
---|
1544 | } |
---|
1545 | else |
---|
1546 | Send_IRCA(CD->USER, "\0034[ERROR] : Incorrect Spell ID!", true, "ERROR"); |
---|
1547 | } |
---|
1548 | else |
---|
1549 | Send_IRCA(CD->USER, "\0034[ERROR] : Player Not Online!", true, "ERROR"); |
---|
1550 | } |
---|
1551 | |
---|
1552 | void IRCCmd::Sysmsg_Server(_CDATA *CD) |
---|
1553 | { |
---|
1554 | std::string* _PARAMS = getArray(CD->PARAMS, CD->PCOUNT); |
---|
1555 | std::string ircchan = "#"; |
---|
1556 | ircchan += sIRC._irc_chan[sIRC.anchn].c_str(); |
---|
1557 | if(_PARAMS[0] == "a") |
---|
1558 | { |
---|
1559 | //std::string str = "|cffff0000[System Message]:|r" + _PARAMS[1]; |
---|
1560 | std::string ancmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 System Message \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str()); |
---|
1561 | sWorld.SendWorldText(LANG_SYSTEMMESSAGE, _PARAMS[1].c_str()); |
---|
1562 | sIRC.Send_IRC_Channel(ircchan, ancmsg, true); |
---|
1563 | } |
---|
1564 | else if (_PARAMS[0] == "e") |
---|
1565 | { |
---|
1566 | std::string str = "|cffff0000[Server Event]:|r " + _PARAMS[1]; |
---|
1567 | std::string notstr = "[Server Event]: " + _PARAMS[1]; |
---|
1568 | std::string notmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 Server Event \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str()); |
---|
1569 | WorldPacket data(SMSG_NOTIFICATION, (notstr.size()+1)); |
---|
1570 | data << notstr; |
---|
1571 | WorldPacket data2(SMSG_PLAY_SOUND,32); |
---|
1572 | data2 << (uint32)1400; |
---|
1573 | sWorld.SendGlobalMessage(&data2); |
---|
1574 | sWorld.SendGlobalMessage(&data); |
---|
1575 | sWorld.SendWorldText(LANG_EVENTMESSAGE, _PARAMS[1].c_str()); |
---|
1576 | sIRC.Send_IRC_Channel(ircchan, notmsg, true); |
---|
1577 | } |
---|
1578 | else if (_PARAMS[0] == "n") |
---|
1579 | { |
---|
1580 | std::string str = "Global notify: " + _PARAMS[1]; |
---|
1581 | std::string notmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 Global Notify \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str()); |
---|
1582 | WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); |
---|
1583 | data << str; |
---|
1584 | sWorld.SendGlobalMessage(&data); |
---|
1585 | sIRC.Send_IRC_Channel(ircchan, notmsg, true); |
---|
1586 | } |
---|
1587 | else if (_PARAMS[0] == "add") |
---|
1588 | { |
---|
1589 | sIRC.Send_IRC_Channel(ircchan, "This command is currently borken.", true); |
---|
1590 | // Commented for now -- timer broken |
---|
1591 | //WorldDatabase.PExecute( "INSERT INTO IRC_AutoAnnounce (message, addedby) VALUES ('%s', '%s')", _PARAMS[1].c_str(), CD->USER.c_str()); |
---|
1592 | //std::string str = "|cffff0000[Automatic]:|r" + _PARAMS[1]; |
---|
1593 | //std::string ancmsg = MakeMsg("\00304,08\037/!\\\037\017\00304 Automatic System Message \00304,08\037/!\\\037\017 %s",_PARAMS[1].c_str()); |
---|
1594 | //sWorld.SendWorldText(LANG_AUTO_ANN, _PARAMS[1].c_str()); |
---|
1595 | //sIRC.Send_IRC_Channel(ircchan, ancmsg, true); |
---|
1596 | } |
---|
1597 | else if (_PARAMS[0] == "del") |
---|
1598 | { |
---|
1599 | WorldDatabase.PExecute( "DELETE FROM IRC_AutoAnnounce WHERE id = %s", _PARAMS[1].c_str()); |
---|
1600 | Send_IRCA(ChanOrPM(CD), MakeMsg("Deleted Automatic Announcement Message ID: %s", _PARAMS[1].c_str()), true, CD->TYPE); |
---|
1601 | } |
---|
1602 | else if (_PARAMS[0] == "list") |
---|
1603 | { |
---|
1604 | QueryResult *result = WorldDatabase.PQuery("SELECT * FROM IRC_AutoAnnounce LIMIT 5;", _PARAMS[1].c_str()); |
---|
1605 | if(result) |
---|
1606 | { |
---|
1607 | Field *fields = result->Fetch(); |
---|
1608 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1609 | { |
---|
1610 | std::string id = fields[0].GetCppString(); |
---|
1611 | std::string message = fields[1].GetCppString(); |
---|
1612 | std::string addedby = fields[2].GetCppString(); |
---|
1613 | Send_IRCA(ChanOrPM(CD), MakeMsg("ID: %s - Added By: %s - Message: %s", id.c_str(), addedby.c_str(), message.c_str()), true, CD->TYPE); |
---|
1614 | result->NextRow(); |
---|
1615 | } |
---|
1616 | delete result; |
---|
1617 | } |
---|
1618 | else |
---|
1619 | Send_IRCA(CD->USER, "\0034[ERROR] : No Auto Announce Messages Are In The Database.", true, "ERROR"); |
---|
1620 | } |
---|
1621 | else |
---|
1622 | Send_IRCA(CD->USER, "\0034[ERROR] : Please Use (a-Announce)(n-Notify)(e-Event) As Second Parameter!", true, "ERROR"); |
---|
1623 | } |
---|
1624 | |
---|
1625 | void IRCCmd::Tele_Player(_CDATA *CD) |
---|
1626 | { |
---|
1627 | std::string* _PARAMS = getArray(CD->PARAMS, 4); |
---|
1628 | if(AcctLevel(_PARAMS[0]) > GetLevel(CD->USER) && (sIRC.BOTMASK & 512)!= 0) |
---|
1629 | { |
---|
1630 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : Nice Try, This Player Has A Higher GM Level Than You! [ %i ]", AcctLevel(_PARAMS[0])), true, "ERROR"); |
---|
1631 | return; |
---|
1632 | } |
---|
1633 | bool DoTeleport = false; |
---|
1634 | float pX, pY, pZ, pO = 0; |
---|
1635 | uint32 mapid = 0; |
---|
1636 | std::string rMsg = " \0034[ERROR] : Teleport Failed!"; |
---|
1637 | std::string wMsg = "Invalid Tele Location"; |
---|
1638 | Player* plr = GetPlayer(_PARAMS[0]); |
---|
1639 | if(plr) |
---|
1640 | { |
---|
1641 | if(plr->isInFlight() || plr->isInCombat()) |
---|
1642 | { |
---|
1643 | Send_IRCA(CD->USER, MakeMsg("\0034[ERROR] : %s Is Busy And Cannot Be Teleported! They Could Be In Combat, Or Flying.",_PARAMS[0].c_str()), true, "ERROR"); |
---|
1644 | return; |
---|
1645 | } |
---|
1646 | } |
---|
1647 | if(_PARAMS[1] == "l" || _PARAMS[1].size() > 2) |
---|
1648 | { |
---|
1649 | if(_PARAMS[1].size() > 1) |
---|
1650 | _PARAMS[2] = _PARAMS[1]; |
---|
1651 | WorldDatabase.escape_string(_PARAMS[2]); |
---|
1652 | QueryResult *result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map FROM game_tele WHERE name='%s';", _PARAMS[2].c_str()); |
---|
1653 | if (result) |
---|
1654 | { |
---|
1655 | Field *fields = result->Fetch(); |
---|
1656 | pX = fields[0].GetFloat(); |
---|
1657 | pY = fields[1].GetFloat(); |
---|
1658 | pZ = fields[2].GetFloat(); |
---|
1659 | pO = fields[3].GetFloat(); |
---|
1660 | mapid = fields[4].GetUInt16(); |
---|
1661 | delete result; |
---|
1662 | rMsg = MakeMsg(" \00313[%s] : Teleported To %s! By: %s.", |
---|
1663 | _PARAMS[0].c_str(), |
---|
1664 | _PARAMS[2].c_str(), |
---|
1665 | CD->USER.c_str()); |
---|
1666 | wMsg = MakeMsg("You Have Been Teleported To %s By: %s.", |
---|
1667 | _PARAMS[2].c_str(), |
---|
1668 | CD->USER.c_str()); |
---|
1669 | DoTeleport = true; |
---|
1670 | } |
---|
1671 | else |
---|
1672 | { |
---|
1673 | WorldDatabase.escape_string(_PARAMS[2]); |
---|
1674 | QueryResult *result = WorldDatabase.PQuery("SELECT name FROM game_tele WHERE name LIKE '%%%s%%' LIMIT 7;", _PARAMS[2].c_str()); |
---|
1675 | if (result) |
---|
1676 | { |
---|
1677 | std::string telename = "<> "; |
---|
1678 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1679 | { |
---|
1680 | Field *fields = result->Fetch(); |
---|
1681 | telename.append(fields[0].GetCppString()); |
---|
1682 | result->NextRow(); |
---|
1683 | telename.append(" <> "); |
---|
1684 | } |
---|
1685 | delete result; |
---|
1686 | Send_IRCA(CD->USER, "I Cannot Find Location: "+_PARAMS[2]+" . Perhaps One Of These Will Work For You.", true, "ERROR"); |
---|
1687 | Send_IRCA(CD->USER, telename, true, "ERROR"); |
---|
1688 | return; |
---|
1689 | } |
---|
1690 | else |
---|
1691 | Send_IRCA(CD->USER, "\0034[ERROR] : Location Not Found! Nothing Even Close Found!", true, "ERROR"); |
---|
1692 | return; |
---|
1693 | } |
---|
1694 | } |
---|
1695 | else if(_PARAMS[1] == "c") |
---|
1696 | { |
---|
1697 | std::string* _PARAMSA = getArray(_PARAMS[2], 4); |
---|
1698 | pX = atof(_PARAMSA[1].c_str()); |
---|
1699 | pY = atof(_PARAMSA[2].c_str()); |
---|
1700 | pZ = atof(_PARAMSA[3].c_str()); |
---|
1701 | mapid = atoi(_PARAMSA[0].c_str()); |
---|
1702 | rMsg = MakeMsg(" \00313[%s] : Teleported To Map: %s. Position: X(%s) Y(%s) Z(%s)! By: %s.", |
---|
1703 | _PARAMS[0].c_str(), |
---|
1704 | _PARAMSA[0].c_str(), |
---|
1705 | _PARAMSA[1].c_str(), |
---|
1706 | _PARAMSA[2].c_str(), |
---|
1707 | _PARAMSA[3].c_str(), |
---|
1708 | CD->USER.c_str()); |
---|
1709 | wMsg = MakeMsg("You Have Been Teleported To Map: %s. Position: X(%s) Y(%s) Z(%s)! By: %s.", |
---|
1710 | _PARAMSA[0].c_str(), |
---|
1711 | _PARAMSA[1].c_str(), |
---|
1712 | _PARAMSA[2].c_str(), |
---|
1713 | _PARAMSA[3].c_str(), |
---|
1714 | CD->USER.c_str()); |
---|
1715 | DoTeleport = true; |
---|
1716 | } |
---|
1717 | else if(_PARAMS[1] == "r") |
---|
1718 | { |
---|
1719 | if(plr) |
---|
1720 | { |
---|
1721 | pX = plr->m_recallX; |
---|
1722 | pY = plr->m_recallY; |
---|
1723 | pZ = plr->m_recallZ; |
---|
1724 | pO = plr->m_recallO; |
---|
1725 | mapid = plr->m_recallMap; |
---|
1726 | rMsg = MakeMsg(" \00313[%s] : Has Been Recalled To Their Previous Location.", |
---|
1727 | _PARAMS[0].c_str()); |
---|
1728 | wMsg = MakeMsg("You Have Been Recalled To Your Previous Location. By: %s", |
---|
1729 | CD->USER.c_str()); |
---|
1730 | DoTeleport = true; |
---|
1731 | } |
---|
1732 | else |
---|
1733 | { |
---|
1734 | Send_IRCA(CD->USER, MakeMsg("\00313[%s] : Cannot Be Recalled, They Are Not Online.", _PARAMS[0].c_str()), true, "ERROR"); |
---|
1735 | return; |
---|
1736 | } |
---|
1737 | |
---|
1738 | } |
---|
1739 | else if(_PARAMS[1] == "to") |
---|
1740 | { |
---|
1741 | Player* plr2 = GetPlayer(_PARAMS[2]); |
---|
1742 | if(plr2) |
---|
1743 | { |
---|
1744 | plr2->GetContactPoint(plr, pX, pY, pZ); |
---|
1745 | mapid = plr2->GetMapId(); |
---|
1746 | } |
---|
1747 | else |
---|
1748 | { |
---|
1749 | if(uint64 guid = objmgr.GetPlayerGUIDByName(_PARAMS[2].c_str())) |
---|
1750 | { |
---|
1751 | bool in_flight; |
---|
1752 | Player::LoadPositionFromDB(mapid, pX, pY, pZ, pO, in_flight, guid); |
---|
1753 | } |
---|
1754 | else |
---|
1755 | { |
---|
1756 | Send_IRCA(CD->USER, "\0034[ERROR] : Second Player Not Found!", true, "ERROR"); |
---|
1757 | return; |
---|
1758 | } |
---|
1759 | } |
---|
1760 | rMsg = MakeMsg(" \00313[%s] : Teleported To Player: [%s] By: %s.", |
---|
1761 | _PARAMS[0].c_str(), |
---|
1762 | _PARAMS[2].c_str(), |
---|
1763 | CD->USER.c_str()); |
---|
1764 | wMsg = MakeMsg("You Are Being Teleported To: %s. By: %s.", |
---|
1765 | _PARAMS[2].c_str(), |
---|
1766 | CD->USER.c_str()); |
---|
1767 | DoTeleport = true; |
---|
1768 | } |
---|
1769 | if(DoTeleport) |
---|
1770 | { |
---|
1771 | if(MapManager::IsValidMapCoord(mapid, pX ,pY)) |
---|
1772 | { |
---|
1773 | //if player is online teleport them in real time, if not set the DB to our coordinates. |
---|
1774 | if(plr) |
---|
1775 | { |
---|
1776 | plr->SaveRecallPosition(); |
---|
1777 | plr->TeleportTo(mapid, pX, pY, pZ, pO); |
---|
1778 | sIRC.Send_IRC_Channel(ChanOrPM(CD), rMsg, true, CD->TYPE); |
---|
1779 | Send_Player(plr, wMsg); |
---|
1780 | } |
---|
1781 | else |
---|
1782 | { |
---|
1783 | uint64 guid = objmgr.GetPlayerGUIDByName(_PARAMS[0]); |
---|
1784 | Player::SavePositionInDB(mapid,pX,pY,pZ,pO,MapManager::Instance().GetZoneId(mapid,pX,pY),guid); |
---|
1785 | sIRC.Send_IRC_Channel(ChanOrPM(CD), rMsg + " \0034*Offline Tele.* ", true, CD->TYPE); |
---|
1786 | } |
---|
1787 | } |
---|
1788 | else |
---|
1789 | Send_IRCA(CD->USER, "\0034[ERROR] : Invalid Location!", true, "ERROR"); |
---|
1790 | } |
---|
1791 | else |
---|
1792 | Send_IRCA(CD->USER, "\0034[ERROR] : Invalid Paramaters, Please Try Again [ "+sIRC._cmd_prefx+"help tele ] For More Information. ", true, "ERROR"); |
---|
1793 | } |
---|
1794 | |
---|
1795 | void IRCCmd::Top_Player(_CDATA *CD) |
---|
1796 | { |
---|
1797 | std::string* _PARAMS = getArray(CD->PARAMS, 2); |
---|
1798 | uint32 limitr = 10; |
---|
1799 | if(atoi(_PARAMS[1].c_str()) > 0 && GetLevel(CD->USER) >= sIRC._op_gm_lev) |
---|
1800 | limitr = atoi(_PARAMS[1].c_str()); |
---|
1801 | if(_PARAMS[0] == "accttime") |
---|
1802 | { |
---|
1803 | QueryResult *result = CharacterDatabase.PQuery("SELECT account, name, (SUM(totaltime)) AS combinetime FROM characters GROUP BY account ORDER BY combinetime DESC LIMIT 0, %d ", limitr); |
---|
1804 | if(result) |
---|
1805 | { |
---|
1806 | Field *fields = result->Fetch(); |
---|
1807 | std::string tptime = MakeMsg("\x2 Top%d Accounts By Played Time:\x3\x31\x30 ", limitr); |
---|
1808 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1809 | { |
---|
1810 | uint32 account = fields[0].GetUInt32(); |
---|
1811 | std::string PlName = GetAcctNameFromID(account); |
---|
1812 | std::string Time = SecToDay(fields[2].GetCppString()); |
---|
1813 | uint32 rank = i+1; |
---|
1814 | tptime.append(MakeMsg("[%u]%s %s \xF| \x3\x31\x30\x2", rank, PlName.c_str(), Time.c_str())); |
---|
1815 | result->NextRow(); |
---|
1816 | } |
---|
1817 | delete result; |
---|
1818 | Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE); |
---|
1819 | } |
---|
1820 | else |
---|
1821 | Send_IRCA(CD->USER, "\0034[ERROR] : No Accounts Returned." ,true, "ERROR"); |
---|
1822 | } |
---|
1823 | if(_PARAMS[0] == "chartime") |
---|
1824 | { |
---|
1825 | QueryResult *result = CharacterDatabase.PQuery("SELECT name, totaltime FROM characters ORDER BY totaltime DESC LIMIT 0, %d ", limitr); |
---|
1826 | if(result) |
---|
1827 | { |
---|
1828 | Field *fields = result->Fetch(); |
---|
1829 | std::string tptime = MakeMsg("\x2 Top%d Characters By Played Time:\x3\x31\x30 ", limitr); |
---|
1830 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1831 | { |
---|
1832 | std::string Name = fields[0].GetCppString(); |
---|
1833 | std::string Time = SecToDay(fields[1].GetCppString()); |
---|
1834 | uint32 rank = i+1; |
---|
1835 | tptime.append(MakeMsg("[%u]%s %s \xF| \x3\x31\x30\x2", rank, Name.c_str(), Time.c_str())); |
---|
1836 | result->NextRow(); |
---|
1837 | } |
---|
1838 | delete result; |
---|
1839 | Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE); |
---|
1840 | } |
---|
1841 | else |
---|
1842 | Send_IRCA(CD->USER, "\0034[ERROR] : No Characters Returned." ,true, "ERROR"); |
---|
1843 | } |
---|
1844 | if(_PARAMS[0] == "money") |
---|
1845 | { |
---|
1846 | QueryResult *result = CharacterDatabase.PQuery("SELECT name, CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ', 1462), ' ', -1) AS UNSIGNED) AS money FROM characters ORDER BY money DESC LIMIT 0, %d ", limitr); |
---|
1847 | if(result) |
---|
1848 | { |
---|
1849 | Field *fields = result->Fetch(); |
---|
1850 | std::string tptime = MakeMsg("\x2 Top%d Characters By Money:\x3\x31\x30 ", limitr); |
---|
1851 | for (uint64 i=0; i < result->GetRowCount(); i++) |
---|
1852 | { |
---|
1853 | std::string Name = fields[0].GetCppString(); |
---|
1854 | unsigned int money = fields[1].GetInt32(); |
---|
1855 | |
---|
1856 | uint32 rank = i+1; |
---|
1857 | |
---|
1858 | unsigned int gold = money / 10000; |
---|
1859 | unsigned int silv = (money % 10000) / 100; |
---|
1860 | unsigned int cop = (money % 10000) % 100; |
---|
1861 | char tempgold [100]; |
---|
1862 | sprintf(tempgold, "\x2\x3\x30\x37%ug \x3\x31\x34%us \x3\x30\x35%uc\xF", gold, silv, cop); |
---|
1863 | |
---|
1864 | tptime.append(MakeMsg("[%u]%s %s \xF| \x3\x31\x30\x2", rank, Name.c_str(), tempgold)); |
---|
1865 | result->NextRow(); |
---|
1866 | } |
---|
1867 | delete result; |
---|
1868 | Send_IRCA(ChanOrPM(CD), tptime, true, CD->TYPE); |
---|
1869 | } |
---|
1870 | else |
---|
1871 | Send_IRCA(CD->USER, "\0034[ERROR] : No Characters Returned." ,true, "ERROR"); |
---|
1872 | } |
---|
1873 | |
---|
1874 | } |
---|
1875 | |
---|
1876 | void IRCCmd::Who_Logged(_CDATA *CD) |
---|
1877 | { |
---|
1878 | std::string OPS = ""; |
---|
1879 | for(std::list<_client*>::iterator i=_CLIENTS.begin(); i!=_CLIENTS.end();i++) |
---|
1880 | { |
---|
1881 | OPS.append(MakeMsg(" \002[GM:%d IRC: %s - WoW: %s]\002 ", (*i)->GMLevel, (*i)->Name.c_str(), (*i)->UName.c_str())); |
---|
1882 | } |
---|
1883 | Send_IRCA(ChanOrPM(CD), OPS, true, CD->TYPE); |
---|
1884 | } |
---|