· 7 years ago · Sep 24, 2018, 11:48 AM
1
2
3#ifdef _BBK_PREMMY_AAC
4#include <stdio.h>
5#include <time.h>
6#include "ioaccountsql.h"
7#endif //_BBK_PREMMY_AAC
8#include <string>
9#include <sstream>
10#include <fstream>
11#include <utility>
12
13#include "commands.h"
14#include "game.h"
15#include "player.h"
16#include "npc.h"
17#include "chat.h"
18#include "guilds.h"
19#include "actions.h"
20#include "map.h"
21#include "status.h"
22#include "monsters.h"
23#include "town.h"
24#include "tools.h"
25#include "database.h"
26#include "spells.h"
27#include "protocol76.h"
28#include "ioplayersql.h"
29
30extern std::vector< std::pair<uint32_t, uint32_t> > bannedIPs;
31extern Actions actions;
32extern Monsters g_monsters;
33extern Chat g_chat;
34extern Spells spells;
35extern LuaScript g_config;
36
37//table of commands
38s_defcommands Commands::defined_commands[] = {
39 {"/addskill",&Commands::addSkill},
40 {"!transfer",&Commands::ppremmy},
41 {"/s",&Commands::placeNpc},
42 {"!spells",&Commands::SpellsCommand},
43 {"/mute",&Commands::GiveMute},
44 {"/m",&Commands::placeMonster},
45 {"/summon",&Commands::placeSummon},
46 {"/B",&Commands::broadcastMessage},
47 {"/t",&Commands::teleportMasterPos},
48 {"/c",&Commands::teleportHere},
49 {"/i",&Commands::createItems},
50 {"/reload",&Commands::reloadInfo},
51 {"/goto",&Commands::teleportTo},
52 {"/info",&Commands::getInfo},
53 {"/closeserver",&Commands::closeServer},
54 {"/openserver",&Commands::openServer},
55 {"/getonline",&Commands::onlineList},
56 {"/a",&Commands::teleportNTiles},
57 {"!changepacc",&Commands::ChangePacc},
58 {"/r",&Commands::removeItemsBlack},
59 {"!bug",&Commands::bugReport},
60#ifdef BLACK_BOSS_CHECKBOT
61 {"/check",&Commands::checkBot},
62 {"!check",&Commands::checkAnswer},
63#endif //BLACK_BOSS_CHECKBOT
64#ifdef BLACK_HOUSE_TRADE
65 {"!sellhouse",&Commands::sellHouse},
66#endif
67#ifdef __MIZIAK_ADDS__
68 {"/privMsg",&Commands::privMsg},
69#endif
70 {"/kick",&Commands::kickPlayer},
71 {"/male",&Commands::male},
72 {"/female",&Commands::female},
73 {"/dwarf",&Commands::dwarf},
74 {"/nimfa",&Commands::nimfa},
75#ifdef WIZ_REWARD_SYSTEM
76 {"/reward",&Commands::rewardSystem},
77 {"!reward",&Commands::checkRewards},
78#endif
79 {"/outfit",&Commands::outfitChange},
80 {"/bc",&Commands::broadcastColor},
81#ifdef __MIZIAK_BLESSING__
82 {"/bless",&Commands::setBless},
83 {"!bless",&Commands::getBless},
84#endif
85 {"!bg",&Commands::BroadcastGuild},
86#ifdef _BDD_REPUTACJA_
87 {"/reputacja",&Commands::nadawanieReputacji},
88#endif //_BDD_REPUTACJA_
89 {"/checkall",&Commands::mcCheckall},
90 {"/up",&Commands::goUp},
91 {"/down",&Commands::goDown},
92 {"!pos",&Commands::showPos},
93 {"/pvp",&Commands::setWorldType},
94 {"/send",&Commands::teleportPlayerTo},
95 {"/max",&Commands::setMaxPlayers},
96 {"/tp",&Commands::TPthing},
97 {"/msg",&Commands::gadkaBDD},
98 {"!outfit",&Commands::changeOufitPacc},
99#ifdef TLM_HOUSE_SYSTEM
100 {"/owner",&Commands::setHouseOwner},
101 {"!house",&Commands::reloadRights},
102#endif //TLM_HOUSE_SYSTEM
103#ifdef TRS_GM_INVISIBLE
104 {"/invisible",&Commands::gmInvisible},
105#endif //TRS_GM_INVISIBLE
106 {"/save",&Commands::forceServerSave},
107 {"/shutdown",&Commands::shutdown},
108 {"/clean",&Commands::cleanMap},
109/*#ifdef YUR_PREMIUM_PROMOTION
110 {"/promote",&Commands::promote},
111 {"/premium",&Commands::premium},
112 {"!premium",&Commands::showPremmy},
113#endif //YUR_PREMIUM_PROMOTION*/
114 {"/priv",&Commands::allowPrivateChannel},
115 {"/cleanhouse", &Commands::cleanHouses},
116 {"/town", &Commands::teleporter},
117#ifdef HUCZU_SKULLS
118 {"!frags",&Commands::PokazFragi},
119 {"!rs",&Commands::PokazRs},
120 {"!pz",&Commands::PokazPz},
121#endif //HUCZU_SKULLS
122 {"!createguild", &Commands::guildCreate},
123 {"!joinguild", &Commands::guildJoin},
124 {"!uptime",&Commands::showUptime},
125 {"!exp",&Commands::showExpForLvl},
126 {"!mana",&Commands::showManaForLvl},
127 {"!online",&Commands::whoIsOnline},
128 {"!task",&Commands::TaskSystem},
129#ifdef BLACK_OFIARA
130 {"!ofiary",&Commands::JakaJestOfiara},
131#endif //BLACK_OFIARA
132#ifdef AFK_SYSTEM
133 {"!paccoff",&Commands::paccOff},
134#endif
135 {"!afk",&Commands::antyKick},
136 {"!go",&Commands::goOutfit},
137 {"/nick",&Commands::changeGmNick},
138 {"!changerep",&Commands::changeRepforItem},
139};
140
141
142Commands::Commands(Game* igame):
143 game(igame),
144 loaded(false)
145{
146 //setup command map
147 for(int32_t i = 0; i< sizeof(defined_commands)/sizeof(defined_commands[0]); i++)
148{
149 Command *tmp = new Command;
150 tmp->loaded = false;
151 tmp->accesslevel = 1;
152 tmp->f = defined_commands[i].f;
153 std::string key = defined_commands[i].name;
154 commandMap[key] = tmp;
155 }
156}
157
158bool Commands::loadFromDB()
159{
160 Database* db = Database::getInstance();
161 DBQuery query;
162
163 query << "SELECT `nazwa`, `access` FROM `komendy`";
164 DBResult* result;
165 if((result = db->storeQuery(query.str())))
166 {
167 this->loaded = true;
168 do
169 {
170 std::string cmd = result->getDataString("nazwa");
171 CommandMap::iterator it = commandMap.find(cmd);
172 if(it != commandMap.end())
173 {
174 int32_t alevel = result->getDataInt("access");
175 if(!it->second->loaded)
176 {
177 it->second->accesslevel = alevel;
178 it->second->loaded = true;
179 }
180 }
181 else
182 std::cout << "Brak komendy " << cmd << std::endl;
183 }
184 while(result->next());
185 for(CommandMap::iterator it = commandMap.begin(); it != commandMap.end(); ++it)
186 {
187 if(it->second->loaded == false)
188 std::cout << "Uwaga! Zapomniales ustawic access dla komendy " << it->first << std::endl;
189 //register command tag in game
190 game->addCommandTag(it->first.substr(0,1));
191 }
192 }
193 return this->loaded;
194}
195
196bool Commands::reload()
197{
198 this->loaded = false;
199 for(CommandMap::iterator it = commandMap.begin(); it != commandMap.end(); ++it)
200 {
201 it->second->accesslevel = 1;
202 it->second->loaded = false;
203 }
204 game->resetCommandTag();
205 //this->loadXml(datadir);
206 this->loadFromDB();
207 return true;
208}
209
210bool Commands::exeCommand(Creature *creature, const std::string &cmd)
211{
212
213 std::string str_command;
214 std::string str_param;
215
216 uint32_t loc = (uint32_t)cmd.find( ' ', 0 );
217 if( loc != std::string::npos && loc >= 0)
218 {
219 str_command = std::string(cmd, 0, loc);
220 str_param = std::string(cmd, (loc+1), cmd.size()-loc-1);
221 }
222 else
223 {
224 str_command = cmd;
225 str_param = std::string("");
226 }
227
228 //find command
229 CommandMap::iterator it = commandMap.find(str_command);
230 if(it == commandMap.end())
231 {
232 return false;
233 }
234 Player *player = dynamic_cast<Player*>(creature);
235 //check access for this command
236 if(creature->access < it->second->accesslevel)
237 {
238 if(creature->access > 0)
239 {
240 if (player)
241 player->sendTextMessage(MSG_SMALLINFO,"You cannot execute this command.");
242 else
243 std::cout << "UWAGA! " << creature->getName() << " nie posiada access do wykonania komendy " << cmd << '!' << std::endl;
244 return true;
245 }
246 else{
247 return false;
248 }
249 }
250 //execute command
251 CommandFunc cfunc = it->second->f;
252 (this->*cfunc)(creature, str_command, str_param);
253
254 if(player && player->access >= 1)
255 {
256 player->sendTextMessage(MSG_RED_TEXT,cmd.c_str());
257 time_t ticks = time(0);
258 tm* now = localtime(&ticks);
259 char buf[32];
260 strftime(buf, sizeof(buf), "%d/%m/%Y %H:%M", now);
261 std::ofstream out("data/logs/commands.log", std::ios::app);
262 out << '[' << buf << "] " << player->getName() << ": " << cmd << std::endl;
263 out.close();
264}
265 return true;
266}
267
268
269bool Commands::placeNpc(Creature* c, const std::string &cmd, const std::string ¶m)
270{
271 Npc *npc = new Npc(param, game);
272 if(!npc->isLoaded())
273 {
274 delete npc;
275 return true;
276 }
277 Position pos;
278 // Set the NPC pos
279 if(c->direction == NORTH)
280 {
281 pos.x = c->pos.x;
282 pos.y = c->pos.y - 1;
283 pos.z = c->pos.z;
284 }
285 // South
286 if(c->direction == SOUTH)
287 {
288 pos.x = c->pos.x;
289 pos.y = c->pos.y + 1;
290 pos.z = c->pos.z;
291 }
292 // East
293 if(c->direction == EAST)
294 {
295 pos.x = c->pos.x + 1;
296 pos.y = c->pos.y;
297 pos.z = c->pos.z;
298 }
299 // West
300 if(c->direction == WEST)
301 {
302 pos.x = c->pos.x - 1;
303 pos.y = c->pos.y;
304 pos.z = c->pos.z;
305 }
306 // Place the npc
307 if(!game->placeCreature(pos, npc))
308 {
309 delete npc;
310 Player *player = dynamic_cast<Player*>(c);
311 if(player)
312 {
313 player->sendMagicEffect(player->pos, NM_ME_PUFF);
314 player->sendCancel("Sorry, not enough room.");
315 }
316 return true;
317 }
318 std::string text = c->getName() + " Postawil NPC: " + param;
319 logAction(dynamic_cast<Player*>(c), 5, "NPC.txt", text);
320 return true;
321}
322
323
324bool Commands::placeMonster(Creature* c, const std::string &cmd, const std::string ¶m)
325{
326 Monster* monster = Monster::createMonster(param, game);
327 if(!monster)
328 {
329 //delete monster;
330 return true;
331 }
332 Position pos;
333
334 // Set the Monster pos
335 if(c->direction == NORTH)
336 {
337 pos.x = c->pos.x;
338 pos.y = c->pos.y - 1;
339 pos.z = c->pos.z;
340 }
341 // South
342 if(c->direction == SOUTH)
343 {
344 pos.x = c->pos.x;
345 pos.y = c->pos.y + 1;
346 pos.z = c->pos.z;
347 }
348 // East
349 if(c->direction == EAST)
350 {
351 pos.x = c->pos.x + 1;
352 pos.y = c->pos.y;
353 pos.z = c->pos.z;
354 }
355 // West
356 if(c->direction == WEST)
357 {
358 pos.x = c->pos.x - 1;
359 pos.y = c->pos.y;
360 pos.z = c->pos.z;
361 }
362
363 // Place the monster
364 if(!game->placeCreature(pos, monster))
365 {
366 delete monster;
367 Player *player = dynamic_cast<Player*>(c);
368 if(player)
369 {
370 player->sendMagicEffect(player->pos, NM_ME_PUFF);
371 player->sendCancel("Sorry, not enough room.");
372 }
373 return true;
374 }
375 else
376 {
377#ifdef FIXY
378 bool canReach;
379 Creature *target = monster->findTarget(0, canReach, c);
380 if(target)
381 monster->selectTarget(target, canReach);
382#endif //FIXY
383 std::string text = c->getName() + " Postawil Monstera: " + param;
384 logAction(dynamic_cast<Player*>(c), 5, "POTWORY.txt", text);
385 return true;
386 }
387}
388
389bool Commands::placeSummon(Creature* c, const std::string &cmd, const std::string ¶m)
390{
391 //Monster* monster = new Monster(param, game);
392 Monster* monster = Monster::createMonster(param, game);
393 //if(!monster->isLoaded()){
394 if(!monster){
395 //delete monster;
396 return true;
397 }
398 Position pos;
399
400 // Set the Monster pos
401 if(c->direction == NORTH) {
402 pos.x = c->pos.x;
403 pos.y = c->pos.y - 1;
404 pos.z = c->pos.z;
405 }
406 // South
407 if(c->direction == SOUTH) {
408 pos.x = c->pos.x;
409 pos.y = c->pos.y + 1;
410 pos.z = c->pos.z;
411 }
412 // East
413 if(c->direction == EAST) {
414 pos.x = c->pos.x + 1;
415 pos.y = c->pos.y;
416 pos.z = c->pos.z;
417 }
418 // West
419 if(c->direction == WEST) {
420 pos.x = c->pos.x - 1;
421 pos.y = c->pos.y;
422 pos.z = c->pos.z;
423 }
424
425 // Place the monster
426 if(!game->placeCreature(pos, monster)) {
427 delete monster;
428 Player *player = dynamic_cast<Player*>(c);
429 if(player) {
430 player->sendMagicEffect(player->pos, NM_ME_PUFF);
431 player->sendCancel("Sorry, not enough room.");
432 }
433 return true;
434 }
435 else{
436 c->addSummon(monster);
437 return true;
438 }
439}
440
441void Commands::logAction(Player *p, int32_t maxaccess, std::string filename, std::string text)
442{
443 if(p && p->access <= maxaccess)
444 {
445 std::stringstream file;
446 time_t now = std::time(NULL);
447 std::string time = ctime(&now);
448 std::string datadir = g_config.DATA_DIR;
449 file << datadir << "logs/" << filename;
450#ifdef USING_VISUAL_2005
451 FILE* f = NULL;
452 fopen_s(&f, file.str().c_str(), "a");
453#else
454 FILE* f = fopen(file.str().c_str(), "a");
455#endif //USING_VISUAL_2005
456 if(f)
457 {
458 fputs(time.c_str(), f);
459 fputs(text.c_str(), f);
460 fputs("\n", f);
461 fclose(f);
462 }
463 }
464}
465
466bool Commands::broadcastMessage(Creature* c, const std::string &cmd, const std::string ¶m){
467 game->creatureBroadcastMessage(c,param);
468 return true;
469}
470
471bool Commands::broadcastColor(Creature* c, const std::string &cmd, const std::string ¶m)
472{
473 int a;
474 int colorInt;
475 Player* player = dynamic_cast<Player*>(c);
476 std::string message = param.c_str();
477 std::stringstream fullMessage;
478 std::string color;
479 MessageClasses mclass;
480
481 for(a=0; a<param.length(); ++a){
482 if(param[a] > 3 && param[a] == ' '){
483 color = param;
484 color.erase(a,1-param.length());
485 message.erase(0,1+a);
486 break;
487 }
488 else
489 message = param.c_str();
490 }
491 toLowerCaseString(color);
492
493
494 if(color == "blue")
495 mclass = MSG_BLUE_TEXT;
496 else if(color == "red"){
497 game->creatureBroadcastMessage(c,message);
498 return false;
499 }
500 else if(color == "green2"){
501 game->creatureBroadcastMessageGreen(c,message);
502 return false;
503 }
504 else if(color == "white3"){
505 game->creatureBroadcastMessageWhite(c,message);
506 return false;
507 }
508 else if(color == "red2")
509 mclass = MSG_RED_TEXT;
510 else if(color == "orange")
511 mclass = MSG_ORANGE;
512 else if(color == "white")
513 mclass = MSG_ADVANCE; //Invasion
514 else if(color == "white2")
515 mclass = MSG_EVENT;
516 else if(color == "green")
517 mclass = MSG_INFO;
518 else if(color == "small")
519 mclass = MSG_SMALLINFO;
520 else if(color == "yellow")
521 mclass = MSG_YELLOW;
522 else if(color == "private")
523 mclass = MSG_PRIVATE;
524 else{
525 player->sendTextMessage(MSG_SMALLINFO, "Define a color, or use #b to speak in red.");
526 return false;
527 }
528 fullMessage << c->getName()<< ": "<< message.c_str()<<std::endl; //Name: Message
529
530 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
531 if(dynamic_cast<Player*>(it->second))
532 (*it).second->sendTextMessage(mclass, fullMessage.str().c_str());
533 }
534 return true;
535}
536
537bool Commands::broadcastMessageGreen(Creature* c, const std::string &cmd, const std::string ¶m){
538 game->creatureBroadcastMessageGreen(c,param);
539 return true;
540}
541bool Commands::broadcastMessageWhite(Creature* c, const std::string &cmd, const std::string ¶m){
542 game->creatureBroadcastMessageWhite(c,param);
543 return true;
544}
545
546bool Commands::teleportMasterPos(Creature* c, const std::string &cmd, const std::string ¶m){
547 game->teleport(c, c->masterPos);
548 return true;
549}
550
551bool Commands::teleportHere(Creature* c, const std::string &cmd, const std::string ¶m){
552 Creature* creature = game->getCreatureByName(param);
553 if(creature && creature->access <= c->access)
554 {
555 game->teleport(creature, c->pos);
556 }
557 return true;
558}
559
560bool Commands::createItems(Creature* c, const std::string &cmd, const std::string ¶m)
561{
562 uint32_t itemid, count;
563 std::istringstream in(param.c_str());
564 in >> itemid >> count;
565
566 if(count == 0 || !count || count > 8214673)
567 count = 1;
568
569 if(count > 100)
570 count = 100;
571
572 if(!itemid || itemid < 100 || (itemid > 5089 && itemid < 20000) || itemid > 200028)
573 itemid = 100;
574
575 Item *newItem = Item::CreateItem(itemid, count);
576 if(!newItem)
577 return true;
578
579 Player *player = dynamic_cast<Player *>(c);
580 if(!player || Item::items[itemid].isSplash() ||
581 Item::items[itemid].isGroundTile() ||
582 Item::items[itemid].isTeleport() ||
583 Item::items[itemid].isMagicField() ||
584 Item::items[itemid].moveable == false ||
585 Item::items[itemid].pickupable == false)
586 {
587 newItem->pos = c->pos;
588 Tile *t = game->map->getTile(c->pos);
589 if(!t)
590 {
591 delete newItem;
592 return true;
593 }
594
595 game->addThing(NULL,c->pos,newItem);
596 }
597 else if(player)
598 player->TLMaddItem(itemid, count);
599 std::string text = c->getName() + " zrobil item: " + param;
600 logAction(dynamic_cast<Player*>(c), 5, "ITEMS.txt", text);
601 return true;
602}
603
604bool Commands::reloadInfo(Creature* c, const std::string &cmd, const std::string ¶m)
605{
606 Player *player = dynamic_cast<Player *>(c);
607
608 if(param == "actions")
609 {
610 actions.reload();
611 player->sendTextMessage(MSG_EVENT, "Actions successfully reloaded.");
612 }
613 else if(param == "commands")
614 {
615 player->sendTextMessage(MSG_EVENT, "Commands successfully reloaded.");
616 this->reload();
617 }
618 else if(param =="config")
619 {
620 if(g_config.OpenFile("config.lua"))
621 player->sendTextMessage(MSG_EVENT, "Config.lua successfully reloaded.");
622 }
623 else if(param == "spells"){
624 spells.reload();
625 player->sendTextMessage(MSG_EVENT, "Spells successfully reloaded.");
626 }
627 else if(param == "monsters")
628 {
629 g_monsters.reload();
630 player->sendTextMessage(MSG_EVENT, "Monsters successfully reloaded.");
631 }
632 else{
633 Player *player = dynamic_cast<Player*>(c);
634 if(player)
635 player->sendCancel("Option not found.");
636 }
637
638 return true;
639}
640
641bool Commands::teleportTo(Creature* c, const std::string &cmd, const std::string ¶m)
642{
643 Creature* creature = game->getCreatureByName(param);
644 if(creature)
645 {
646 if(creature->access > c->access)
647 return false;
648#ifdef TRS_GM_INVISIBLE
649 Position pos = creature->pos;
650 pos.x++;
651 pos.y++;
652 game->teleport(c, pos);
653#else
654 game->teleport(c, creature->pos);
655#endif //TRS_GM_INVISIBLE
656 }
657 else // teleport to position
658 {
659 std::istringstream in(param.c_str());
660 Position pos;
661 in >> pos.x >> pos.y >> pos.z;
662
663 if (in)
664 game->teleport(c, pos);
665 }
666 }
667
668bool Commands::getInfo(Creature* c, const std::string &cmd, const std::string ¶m)
669{
670 Player *player = dynamic_cast<Player*>(c);
671 if(!player)
672 return true;
673
674 Player* paramPlayer = game->getPlayerByName(param);
675 if(paramPlayer)
676 {
677 std::stringstream info;
678 unsigned char ip[4];
679 if(paramPlayer->access >= player->access && player != paramPlayer)
680 {
681 player->sendTextMessage(MSG_BLUE_TEXT,"You can not get info about this player.");
682 return true;
683 }
684 *(uint32_t*)&ip = paramPlayer->lastip;
685 info << "name: " << paramPlayer->getName() << std::endl <<
686 "access: " << paramPlayer->access << std::endl <<
687 "level: " << paramPlayer->getPlayerInfo(PLAYERINFO_LEVEL) << std::endl <<
688 "maglvl: " << paramPlayer->getPlayerInfo(PLAYERINFO_MAGICLEVEL) << std::endl <<
689 "Money: " << paramPlayer->getMoney()/1000000 << "cc" << std::endl <<
690 "speed: " << paramPlayer->speed <<std::endl <<
691 "position " << paramPlayer->pos << std::endl <<
692 "IP: " << (uint32_t)ip[0] << "." << (uint32_t)ip[1] <<
693 "." << (uint32_t)ip[2] << "." << (uint32_t)ip[3];
694 player->sendTextMessage(MSG_BLUE_TEXT,info.str().c_str());
695 }
696 else
697 {
698 player->sendTextMessage(MSG_BLUE_TEXT,"Player not found.");
699 }
700
701 return true;
702}
703
704
705bool Commands::closeServer(Creature* c, const std::string &cmd, const std::string ¶m)
706{
707 game->setGameState(GAME_STATE_CLOSED);
708 //kick players with access = 0
709 std::stringstream FM;
710 FM << "Server temporarly closed!";
711 AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
712 while(it != Player::listPlayer.list.end())
713 {
714 if((*it).second->access == 0)
715 {
716 (*it).second->kickPlayer();
717 it = Player::listPlayer.list.begin();
718 }
719 else
720 {
721 (*it).second->sendTextMessage(MSG_RED_INFO, FM.str().c_str());
722 ++it;
723 }
724 }
725
726 return true;
727}
728
729bool Commands::openServer(Creature* c, const std::string &cmd, const std::string ¶m)
730{
731 game->setGameState(GAME_STATE_NORMAL);
732 std::stringstream FM;
733 FM << "Serwer zostal otwarty!";
734 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it)
735 {
736 if(dynamic_cast<Player*>(it->second))
737 (*it).second->sendTextMessage(MSG_RED_INFO, FM.str().c_str());
738 }
739 return true;
740}
741
742bool Commands::onlineList(Creature* c, const std::string &cmd, const std::string ¶m)
743{
744 Player* player = dynamic_cast<Player*>(c);
745 unsigned long alevelmin = 0;
746 unsigned long alevelmax = 10000;
747 int i,n;
748 if(!player)
749 return false;
750
751 if(param == "gm")
752 alevelmin = 1;
753 else if(param == "normal")
754 alevelmax = 0;
755
756 std::stringstream players;
757 players << "name level mag" << std::endl;
758
759 i = 0;
760 n = 0;
761 AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
762 for(;it != Player::listPlayer.list.end();++it)
763 {
764 if((*it).second->access >= (int)alevelmin && (*it).second->access <= (int)alevelmax){
765 players << (*it).second->getName() << " " <<
766 (*it).second->getPlayerInfo(PLAYERINFO_LEVEL) << " " <<
767 (*it).second->getPlayerInfo(PLAYERINFO_MAGICLEVEL) << std::endl;
768 n++;
769 i++;
770 }
771 if(i == 10){
772 player->sendTextMessage(MSG_BLUE_TEXT,players.str().c_str());
773 players.str("");
774 i = 0;
775 }
776 }
777 if(i != 0)
778 player->sendTextMessage(MSG_BLUE_TEXT,players.str().c_str());
779
780 players.str("");
781 players << "Total: " << n << " player(s)" << std::endl;
782 player->sendTextMessage(MSG_BLUE_TEXT,players.str().c_str());
783 return true;
784}
785
786bool Commands::teleportNTiles(Creature* c, const std::string &cmd, const std::string ¶m)
787{
788
789 int32_t ntiles = atoi(param.c_str());
790 if(ntiles != 0)
791 {
792 Position new_pos, old_pos;
793 new_pos = old_pos = c->pos;
794 switch(c->direction)
795 {
796 case NORTH:
797 new_pos.y = new_pos.y - ntiles;
798 break;
799 case SOUTH:
800 new_pos.y = new_pos.y + ntiles;
801 break;
802 case EAST:
803 new_pos.x = new_pos.x + ntiles;
804 break;
805 case WEST:
806 new_pos.x = new_pos.x - ntiles;
807 break;
808 }
809 game->teleport(c, new_pos);
810 game->updateTile(old_pos);
811 }
812 return true;
813}
814
815bool Commands::removeItemsBlack(Creature* c, const std::string &cmd, const std::string ¶m)
816{
817 Position remove = c->pos;
818 switch(c->direction)
819 {
820 case NORTH:
821 --remove.y;
822 break;
823 case SOUTH:
824 ++remove.y;
825 break;
826 case EAST:
827 ++remove.x;
828 break;
829 case WEST:
830 --remove.x;
831 break;
832 }
833 if(dynamic_cast<Player*>(game->getThing(remove,1,NULL)))
834 {
835 c->sendCancel("Sorry, you cannot delete players :D");
836 game->sendMagicEffect(remove,NM_ME_PUFF);
837 return false;
838 }
839 if(game->removeThing(NULL,remove,game->getThing(remove,1,NULL),1))
840 {
841 game->sendMagicEffect(remove,NM_ME_MAGIC_ENERGIE);
842 return true;
843 }
844 else
845 {
846 c->sendCancel("Sorry, you cannot delete ground item!");
847 game->sendMagicEffect(remove,NM_ME_PUFF);
848 return false;
849 }
850}
851
852bool Commands::kickPlayer(Creature* c, const std::string &cmd, const std::string ¶m)
853{
854 Player* playerKick = game->getPlayerByName(param);
855 if(playerKick)
856 {
857 Player* player = dynamic_cast<Player*>(c);
858 if(player && player->access <= playerKick->access)
859 {
860 player->sendTextMessage(MSG_BLUE_TEXT,"You cannot kick this player.");
861 return true;
862 }
863 playerKick->kickPlayer();
864 return true;
865 }
866 return false;
867}
868
869bool Commands::goUp(Creature* c, const std::string &cmd, const std::string ¶m)
870{
871 Position pos = c->pos;
872 pos.z--;
873 game->teleport(c, pos);
874 return true;
875}
876
877bool Commands::goDown(Creature* c, const std::string &cmd, const std::string ¶m)
878{
879 Position pos = c->pos;
880 pos.z++;
881 game->teleport(c, pos);
882 return true;
883}
884
885bool Commands::showExpForLvl(Creature* c, const std::string &cmd, const std::string ¶m)
886{
887 Player* player = dynamic_cast<Player*>(c);
888 if (player->mmo > 0)
889 {
890 player->sendMagicEffect(player->pos, NM_ME_PUFF);
891 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
892 }
893 if (player && player->mmo == 0 )
894 {
895 char buf[128];
896 sprintf(buf,"%lld",player->getExpForNextLevel());
897
898 std::string msg = std::string("You need ") + std::string(buf) + std::string(" experience points to gain level.");
899 player->sendTextMessage(MSG_BLUE_TEXT, msg.c_str());
900 player->mmo += 5;
901 }
902 return true;
903}
904bool Commands::showManaForLvl(Creature* c, const std::string &cmd, const std::string ¶m)
905{
906 Player* player = dynamic_cast<Player*>(c);
907 if (player)
908 {
909 if (player->mmo > 0)
910 {
911 player->sendMagicEffect(player->pos, NM_ME_PUFF);
912 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
913 return false;
914 }
915 else
916 {
917 char buf[128];
918 sprintf(buf,"%llu",(uint64_t)player->getManaForNextMLevel());
919 std::string msg = std::string("You need to spent ") + std::string(buf) + std::string(" mana to gain magic level.");
920 player->sendTextMessage(MSG_BLUE_TEXT, msg.c_str());
921 player->mmo += 5;
922 return true;
923 }
924 }
925 return false;
926}
927bool Commands::whoIsOnline(Creature* c, const std::string &cmd, const std::string ¶m)
928
929{
930 Player* player = dynamic_cast<Player*>(c);
931 if (player->mmo > 0)
932 {
933 player->sendMagicEffect(player->pos, NM_ME_PUFF);
934 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
935 }
936 if (player->mmo == 0 )
937 {
938
939 int i,n,e;
940 if(!player)
941 return false;
942
943
944 std::stringstream players;
945 players << "Players online: " << std::endl;
946
947 e = 0;
948 AutoList<Player>::listiterator itt = Player::listPlayer.list.begin();
949 for(;itt != Player::listPlayer.list.end();++itt)
950 {
951 if((*itt).second->access < 3)
952 e++;
953 }
954
955 i = 0;
956 n = 0;
957 AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
958 for(;it != Player::listPlayer.list.end();++it)
959 {
960 //Player::listPlayer.list.end()
961 if((*it).second->access < 2)
962 {
963 n++;
964 i++;
965 if (n+1 == e)
966 players << (*it).second->getName() << " [" <<(*it).second->getPlayerInfo(PLAYERINFO_LEVEL) << "] and ";
967 else if (n == e)
968 players << (*it).second->getName() << " [" <<(*it).second->getPlayerInfo(PLAYERINFO_LEVEL) << "].";
969 else
970 players << (*it).second->getName() << " [" <<(*it).second->getPlayerInfo(PLAYERINFO_LEVEL) << "], ";
971
972
973
974 }
975 if(i == 20){
976 player->sendTextMessage(MSG_BLUE_TEXT,players.str().c_str());
977 players.str("");
978 i = 0;
979 }
980 }
981 if(i != 0)
982 player->sendTextMessage(MSG_BLUE_TEXT,players.str().c_str());
983
984 players.str("");
985 players << "Total: " << n << " "<<std::endl;
986 player->sendTextMessage(MSG_BLUE_TEXT,players.str().c_str());
987 player->mmo += 5;
988 return true;
989 }
990 return false;
991}
992
993bool Commands::setWorldType(Creature* c, const std::string &cmd, const std::string ¶m)
994{
995 Player* player = dynamic_cast<Player*>(c);
996
997 if (player && !param.empty())
998 {
999 int type = atoi(param.c_str());
1000
1001 if (type == 0)
1002 {
1003 game->setWorldType(WORLD_TYPE_NO_PVP);
1004 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
1005 if(dynamic_cast<Player*>(it->second)){
1006 Creature *attackedCreature = game->getPlayerByID((*it).second->attackedCreature);
1007 if(dynamic_cast<Player*>(attackedCreature)){
1008 (*it).second->sendCancelAttacking();
1009 (*it).second->setAttackedCreature(NULL);
1010 game->stopEvent((*it).second->eventCheckAttacking);
1011 (*it).second->eventCheckAttacking = 0;
1012 }
1013 }
1014 }
1015 player->sendTextMessage(MSG_BLUE_TEXT, "World type set to no-pvp.");
1016 }
1017 else if (type == 1)
1018 {
1019 game->setWorldType(WORLD_TYPE_PVP);
1020 player->sendTextMessage(MSG_BLUE_TEXT, "World type set to pvp.");
1021 }
1022 else if (type == 2)
1023 {
1024 game->setWorldType(WORLD_TYPE_PVP_ENFORCED);
1025 player->sendTextMessage(MSG_BLUE_TEXT, "World type set to pvp-enforced.");
1026 }
1027 }
1028 return true;
1029}
1030
1031bool Commands::teleportPlayerTo(Creature* c, const std::string &cmd, const std::string ¶m)
1032{
1033 Position pos;
1034 std::string name;
1035 std::istringstream in(param.c_str());
1036
1037 std::getline(in, name, ',');
1038 in >> pos.x >> pos.y >> pos.z;
1039
1040 Creature* creature = game->getCreatureByName(name);
1041 Player* player = dynamic_cast<Player*>(creature);
1042
1043 if (player)
1044 game->teleport(player, pos);
1045
1046 return true;
1047}
1048
1049bool Commands::showPos(Creature* c, const std::string &cmd, const std::string ¶m)
1050{
1051 Player* player = dynamic_cast<Player*>(c);
1052 if (player)
1053 {
1054 if(player->mmo > 0)
1055 {
1056 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1057 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1058 }
1059 else
1060 {
1061 std::stringstream msg;
1062 msg << "Your position is: " << player->pos.x << ' ' << player->pos.y << ' ' << player->pos.z << std::ends;
1063 player->sendTextMessage(MSG_BLUE_TEXT, msg.str().c_str());
1064 player->mmo += 5;
1065 return true;
1066 }
1067
1068 }
1069 return false;
1070}
1071bool Commands::setMaxPlayers(Creature* c, const std::string &cmd, const std::string ¶m)
1072{
1073 if (!param.empty())
1074 {
1075 int32_t newmax = atoi(param.c_str());
1076 if (newmax > 0)
1077 {
1078 game->setMaxPlayers(newmax);
1079
1080 Player* player = dynamic_cast<Player*>(c);
1081 if (player)
1082 player->sendTextMessage(MSG_BLUE_TEXT, (std::string("Max number of players is now ")+param).c_str());
1083 }
1084 }
1085 return true;
1086}
1087
1088
1089#ifdef TLM_HOUSE_SYSTEM
1090bool Commands::reloadRights(Creature* c, const std::string &cmd, const std::string ¶m)
1091{
1092 Player* player = dynamic_cast<Player*>(c);
1093 if (player->mmo > 0) {
1094 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1095 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1096 }
1097 if (player->mmo == 0 )
1098 {
1099
1100 if (player)
1101 {
1102 player->houseRightsChanged = true;
1103 player->sendTextMessage(MSG_BLUE_TEXT, "House rights reloaded.");
1104 }
1105
1106 player->mmo += 5;
1107 return true;
1108}
1109 return false;
1110}
1111
1112bool Commands::setHouseOwner(Creature* c, const std::string &cmd, const std::string ¶m)
1113{
1114 Tile* tile = game->getTile(c->pos);
1115 House* house = tile? tile->getHouse() : NULL;
1116
1117 if (house)
1118 {
1119 Creature* creature = game->getCreatureByName(house->getOwner());
1120 Player* prevOwner = creature? dynamic_cast<Player*>(creature) : NULL;
1121
1122 house->setOwner(param);
1123
1124 creature = game->getCreatureByName(param);
1125 Player* newOwner = creature? dynamic_cast<Player*>(creature) : NULL;
1126
1127 if (prevOwner)
1128 prevOwner->houseRightsChanged = true;
1129 if (newOwner)
1130 newOwner->houseRightsChanged = true;
1131 }
1132 return true;
1133}
1134#endif //TLM_HOUSE_SYSTEM
1135
1136
1137#ifdef TRS_GM_INVISIBLE
1138bool Commands::gmInvisible(Creature* c, const std::string &cmd, const std::string ¶m)
1139{
1140 Player *player = dynamic_cast<Player*>(c);
1141
1142 if (!player->gmInvisible)
1143 {
1144 player->oldlookhead = player->lookhead;
1145 player->oldlookbody = player->lookbody;
1146 player->oldlooklegs = player->looklegs;
1147 player->oldlookfeet = player->lookfeet;
1148 player->oldlooktype = player->looktype;
1149 player->oldlookcorpse = player->lookcorpse;
1150 player->oldlookmaster = player->lookmaster;
1151 player->gmInvisible = true;
1152
1153 Tile* tile = game->getTile(player->pos.x,player->pos.y,player->pos.z);
1154 SpectatorVec list;
1155 game->getSpectators(Range(player->pos, true), list);
1156 int32_t osp = tile->getThingStackPos(player);
1157
1158 for(SpectatorVec::iterator it = list.begin(); it != list.end(); ++it)
1159 {
1160 if((*it) != player && (*it)->access == 0)
1161 (*it)->onCreatureDisappear(player, osp, true);
1162 }
1163
1164 player->sendTextMessage(MSG_INFO, "You are invisible.");
1165 game->creatureBroadcastTileUpdated(player->pos);
1166 }
1167 else
1168 {
1169 player->gmInvisible = false;
1170 Tile* tilee = game->getTile(player->pos.x,player->pos.y,player->pos.z);
1171
1172 int32_t osp = tilee->getThingStackPos(player);
1173 SpectatorVec list;
1174 game->getSpectators(Range(player->pos, true), list);
1175
1176 for(SpectatorVec::iterator it = list.begin(); it != list.end(); ++it)
1177 game->creatureBroadcastTileUpdated(player->pos);
1178
1179 game->creatureChangeOutfit(player);
1180 player->sendTextMessage(MSG_INFO, "You are visible again.");
1181 }
1182
1183 return true;
1184}
1185#endif //TRS_GM_INVISIBLE
1186
1187
1188#ifdef HUCZU_SKULLS
1189bool Commands::PokazFragi(Creature* c, const std::string &cmd, const std::string ¶m)
1190{
1191 Player* player = dynamic_cast<Player*>(c);
1192 if (player)
1193 {
1194 if(player->mmo > 0)
1195 {
1196 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1197 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1198 }
1199 else
1200 {
1201 std::ostringstream info;
1202 info << "You have " << player->skullKills
1203 << " unjustified kills. You will lose a frag in " << tickstr(player->absolveTicks) << ".";
1204 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());
1205 player->mmo += 5;
1206 return true;
1207 }
1208 }
1209 return false;
1210}
1211
1212bool Commands::PokazRs(Creature* c, const std::string &cmd, const std::string ¶m)
1213{
1214 Player* player = dynamic_cast<Player*>(c);
1215 if(player)
1216 {
1217 if(player->mmo > 0)
1218 {
1219 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1220 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1221 }
1222 else
1223 {
1224 if (player->skullType == SKULL_RED)
1225 {
1226 std::ostringstream info;
1227 info << "Redskull will disappear in " << tickstr(player->skullTicks) << ".";
1228 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());
1229 }
1230 else
1231 {
1232 std::ostringstream info;
1233 info << "You don't have Red Skull.";
1234 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());
1235 }
1236 player->mmo += 5;
1237 return true;
1238 }
1239 }
1240 return false;
1241}
1242bool Commands::PokazPz(Creature* c, const std::string &cmd, const std::string ¶m)
1243{
1244 Player* player = dynamic_cast<Player*>(c);
1245 if(player)
1246 {
1247 if(player->mmo > 0)
1248 {
1249 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1250 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1251 }
1252 else
1253 {
1254 if (player->inFightTicks != 0)
1255 {
1256 std::ostringstream info;
1257 info << "PZ Locked will disappear in " << tickstr(player->inFightTicks) << ".";
1258 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());
1259 }
1260 else
1261 {
1262 std::ostringstream info;
1263 info << "You don't have PZ Locked!";
1264 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());
1265 }
1266 player->mmo += 5;
1267 return true;
1268 }
1269 }
1270 return false;
1271}
1272#endif //HUCZU_SKULLS
1273
1274
1275bool Commands::forceServerSave(Creature* c, const std::string &cmd, const std::string ¶m)
1276{
1277 Player* player = dynamic_cast<Player*>(c);
1278 if (player)
1279 {
1280 game->serverSave();
1281 player->sendTextMessage(MSG_BLUE_TEXT, "Server save completed.");
1282 }
1283 return true;
1284}
1285
1286bool Commands::shutdown(Creature* c, const std::string &cmd, const std::string ¶m)
1287{
1288 Player* player = dynamic_cast<Player*>(c);
1289 if (player && !param.empty())
1290 game->sheduleShutdown(atoi(param.c_str()));
1291 return true;
1292}
1293
1294bool Commands::cleanMap(Creature* c, const std::string &cmd, const std::string ¶m)
1295{
1296 std::ostringstream info;
1297 Player* player = dynamic_cast<Player*>(c);
1298
1299 if (player)
1300 {
1301 std::cout << ":: clean... ";
1302
1303 timer();
1304 int32_t count = game->cleanMap();
1305 double sec = timer();
1306
1307 info << "Clean completed. Zebrano " << count << (count==1? " item." : " items.") << std::ends;
1308 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());
1309
1310 std::cout << "[" << sec << " s]\n";
1311 }
1312 return true;
1313}
1314
1315/*#ifdef YUR_PREMIUM_PROMOTION
1316bool Commands::premium(Creature* c, const std::string &cmd, const std::string ¶m)
1317{
1318 Player* player = dynamic_cast<Player*>(c);
1319 std::string tickTack = param.c_str();
1320 std::string pacct;
1321
1322 for(int32_t a = 0; a<param.length(); ++a)
1323 {
1324 if(!isdigit(param[a]))
1325 {
1326 pacct = param;
1327 pacct.erase(a,1-param.length());
1328 tickTack.erase(0,1+a);
1329 break;
1330 }
1331 else
1332 pacct = param.c_str();
1333 }
1334 uint32_t newPacc = atoi(pacct.c_str());
1335 if(newPacc <= 0 || newPacc >= 500)
1336 return false;
1337
1338 if(Player* toChange = game->getPlayerByName(tickTack))
1339 {
1340 if(toChange->premiumTicks >= 1800000001)
1341 return false;
1342
1343 toChange->premiumTicks += 60*60*newPacc;
1344 return true;
1345 }
1346 else
1347 return false;
1348
1349 return false;
1350}
1351
1352bool Commands::showPremmy(Creature* c, const std::string &cmd, const std::string ¶m)
1353{
1354 Player* player = dynamic_cast<Player*>(c);
1355 if (player)
1356 {
1357 if(player->mmo > 0)
1358 {
1359 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1360 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1361 }
1362 else
1363 {
1364 std::ostringstream info;
1365 if (g_config.FREE_PREMMY)
1366 info << "You have unlimited premium account." << std::ends;
1367 else
1368 info << "You have " << paccstr(player->premiumTicks) << " of premium time left." << std::ends;
1369 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());
1370 player->mmo += 5;
1371 return true;
1372 }
1373 }
1374 return false;
1375}
1376
1377bool Commands::promote(Creature* c, const std::string &cmd, const std::string ¶m)
1378{
1379 Creature* creature = game->getCreatureByName(param);
1380 Player* target = dynamic_cast<Player*>(creature);
1381
1382 if (target)
1383 target->promote();
1384
1385 return true;
1386}
1387#endif //YUR_PREMIUM_PROMOTION*/
1388
1389bool Commands::mcCheckall(Creature* creature, const std::string& cmd, const std::string& param)
1390{
1391 Player *player = dynamic_cast<Player*>(creature);
1392 std::stringstream info;
1393 unsigned char ip[4];
1394
1395 if(player){
1396 info << "The following players are multiclienting: \n";
1397 info << "Name IP" << "\n";
1398 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
1399 Player* lol = (*it).second;
1400 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
1401 if((*it).second != lol && (*it).second->lastip == lol->lastip){
1402 *(unsigned long*)&ip = (*it).second->lastip;
1403 info << (*it).second->getName() << " " << (unsigned int)ip[0] << "." << (unsigned int)ip[1] << "." << (unsigned int)ip[2] << "." << (unsigned int)ip[3] << "\n";
1404 }
1405 }
1406 }
1407 player->sendTextMessage(MSG_ADVANCE, info.str().c_str());
1408 }
1409 else{
1410 return false;
1411 }
1412
1413 return true;
1414}
1415
1416bool Commands::TPthing(Creature* c, const std::string &cmd, const std::string ¶m)
1417{
1418Player *player = dynamic_cast<Player*>(c);
1419
1420if(!player->teleportid)
1421{
1422 player->teleportid = true;
1423 player->sendTextMessage(MSG_SMALLINFO,"Teleport activated.",player->pos,12);
1424}
1425else
1426{
1427 player->teleportid = false;
1428 player->sendTextMessage(MSG_SMALLINFO,"Teleport deactivated.",player->pos,12);
1429}
1430 return true;
1431}
1432#ifdef _BDD_REPUTACJA_
1433bool Commands::nadawanieReputacji(Creature* c, const std::string &cmd, const std::string ¶m)
1434{
1435 std::istringstream azx(param.c_str());
1436 int liczba;
1437 azx >> liczba;
1438 std::string reszta;
1439 std::getline(azx, reszta);
1440
1441 std::string tmp1 = reszta;
1442 std::string tmp2;
1443 std::string powod;
1444 std::string::size_type pos1;
1445 std::string::size_type pos2;
1446 pos1 = tmp1.find(",");
1447 tmp1.erase(0, pos1+1);
1448 tmp2 = tmp1;
1449 pos2 = tmp2.find(",");
1450 tmp2.erase(0, pos2+1);
1451 powod = tmp2;
1452 std::string name = reszta.substr(pos1+1, pos1+pos2).c_str();
1453
1454 Creature* creature = game->getCreatureByName(name);
1455 Player* cel = creature? dynamic_cast<Player*>(creature) : NULL;
1456 Player* player = dynamic_cast<Player*>(c);
1457
1458int pomoc1;
1459int pomoc2;
1460int pomoc3;
1461int pomoc4;
1462std::string pomocP;
1463
1464if(!cel){pomoc1=1;}else{pomoc1=0;}
1465if(liczba==0){pomoc2=1;}else{pomoc2=0;}
1466if((powod=="")||(powod==" ")){pomoc3=1;}else{pomoc3=0;}
1467
1468if((pomoc1==1)&&(pomoc2==1)&&(pomoc3==1)){
1469pomocP = "Gracz wylogowany, liczba PR równa zero, brak podania powodu";}
1470else if((pomoc1==1)&&(pomoc2==1)&&(pomoc3==0)){
1471pomocP = "Gracz wylogowany, liczba PR równa zero";}
1472else if((pomoc1==1)&&(pomoc2==0)&&(pomoc3==1)){
1473pomocP = "Gracz wylogowany, brak podania powodu";}
1474else if((pomoc1==0)&&(pomoc2==1)&&(pomoc3==1)){
1475pomocP = "Liczba PR równa zero, brak podania powodu";}
1476else if((pomoc1==1)&&(pomoc2==0)&&(pomoc3==0)){
1477pomocP = "Gracz wylogowany";}
1478else if((pomoc1==0)&&(pomoc2==1)&&(pomoc3==0)){
1479pomocP = "Liczba PR równa zero";}
1480else if((pomoc1==0)&&(pomoc2==0)&&(pomoc3==1)){
1481pomocP = "Brak podania powodu";}
1482
1483int opcja;
1484if((cel)&&(pomoc1==0)&&(pomoc2==0)&&(pomoc3==0)){
1485 if(cel->getSex() == PLAYERSEX_FEMALE){
1486 if(liczba>0){opcja=2;}
1487 else if(liczba<0){opcja=3;}
1488 else{opcja=1;}
1489 }
1490 else {
1491 if(liczba>0){opcja=4;}
1492 else if(liczba<0){opcja=5;}
1493 else{opcja=1;}
1494 }
1495 }
1496else{opcja=1;}
1497
1498if(cel){
1499int liczbapoprzednia = cel->reput;
1500cel->reput = (liczbapoprzednia + liczba);}
1501else{}
1502
1503 std::stringstream wiadomosc1;
1504 std::stringstream wiadomosc2;
1505 switch(opcja){
1506 case 1:
1507 wiadomosc1 << "Operacja nieudana: " << pomocP << ".\nAby poprawnie uzyc komendy nadawania Punktów Reputacji, wpisz dane wedlug szablonu:\n/reputacja Liczba,Nick,Powód\nLiczba - ilosc dodawanych, lub odejmowanych Punktów rózna od zera\nNick - nazwa postaci\nPowód - powód otrzymania Reputacji\nPrzyklad dodawania PR: /reputacja 1," << player->getName() << ",Help remove the bug.\nPrzyklad odejmowania PR: /reputacja -1," << player->getName() << ",Zasmiecanie Depo.";
1508 break;
1509 case 2:
1510 wiadomosc2 << cel->getName() << " received " << liczba << ((((liczba>20)||(liczba<5))&&((liczba%10==2)||(liczba%10==3)||(liczba%10==4)))? " Points" : (liczba==1? " Point": " Points")) << " Reputation.\nReason: " << powod << "\nTotal has " << (cel->reput > 0 ? "+" : "") << cel->reput << (cel->reput>=0? ((((cel->reput>20)||(cel->reput<5))&&((cel->reput%10==2)||(cel->reput%10==3)||(cel->reput%10==4)))? " Points" : (cel->reput==1? " Point": " Points")) : ((((cel->reput<-20)||(cel->reput>-5))&&((cel->reput%10==-2)||(cel->reput%10==-3)||(cel->reput%10==-4)))? " Points" : (cel->reput==-1? " Point": " Points")) ) << " Reputation.";
1511 break;
1512 case 3:
1513 wiadomosc2 << cel->getName() << " received " << liczba*-1 << ((((liczba<-20)||(liczba>-5))&&((liczba%10==-2)||(liczba%10==-3)||(liczba%10==-4)))? " Points" : (liczba==-1? " Point": " Points")) << " Reputation.\nReason: " << powod << "\nTotal has " << (cel->reput > 0 ? "+" : "") << cel->reput << (cel->reput>=0? ((((cel->reput>20)||(cel->reput<5))&&((cel->reput%10==2)||(cel->reput%10==3)||(cel->reput%10==4)))? " Points" : (cel->reput==1? " Point": " Points")) : ((((cel->reput<-20)||(cel->reput>-5))&&((cel->reput%10==-2)||(cel->reput%10==-3)||(cel->reput%10==-4)))? " Points" : (cel->reput==-1? " Point": " Points")) ) << " Reputation.";
1514 break;
1515 case 4:
1516 wiadomosc2 << cel->getName() << " received " << liczba << ((((liczba>20)||(liczba<5))&&((liczba%10==2)||(liczba%10==3)||(liczba%10==4)))? " Points" : (liczba==1? " Point": " Points")) << " Reputation.\nReason: " << powod << "\nTotal has " << (cel->reput > 0 ? "+" : "") << cel->reput << (cel->reput>=0? ((((cel->reput>20)||(cel->reput<5))&&((cel->reput%10==2)||(cel->reput%10==3)||(cel->reput%10==4)))? " Points" : (cel->reput==1? " Point": " Points")) : ((((cel->reput<-20)||(cel->reput>-5))&&((cel->reput%10==-2)||(cel->reput%10==-3)||(cel->reput%10==-4)))? " Points" : (cel->reput==-1? " Point": " Points")) ) << " Reputation.";
1517 break;
1518 case 5:
1519 wiadomosc2 << cel->getName() << " received " << liczba*-1 << ((((liczba<-20)||(liczba>-5))&&((liczba%10==-2)||(liczba%10==-3)||(liczba%10==-4)))? " Points" : (liczba==-1? " Point": " Points")) << " Reputation.\nReason: " << powod << "\nTotal has " << (cel->reput > 0 ? "+" : "") << cel->reput << (cel->reput>=0? ((((cel->reput>20)||(cel->reput<5))&&((cel->reput%10==2)||(cel->reput%10==3)||(cel->reput%10==4)))? " Points" : (cel->reput==1? " Point": " Points")) : ((((cel->reput<-20)||(cel->reput>-5))&&((cel->reput%10==-2)||(cel->reput%10==-3)||(cel->reput%10==-4)))? " Points" : (cel->reput==-1? " Point": " Points")) ) << " Reputation.";
1520 break;
1521 }
1522
1523if(opcja>1){
1524//----------------- BDD Monitoring Pro System -----------------------------------
1525 Player *player = dynamic_cast<Player*>(c);
1526 char buf[64];
1527 time_t ticks = time(0);
1528#ifdef USING_VISUAL_2005
1529 tm now;
1530 localtime_s(&now, &ticks);
1531 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", &now);
1532#else
1533 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", localtime(&ticks));
1534#endif //USING_VISUAL_2005
1535 std::ofstream out("data/logs/reputacja.log", std::ios::app);
1536 out << "[" << buf << "] " << player->getName() << ": /reputacja " << param << " <|> Stan " << cel->getName() << " to " << (cel->reput>0?"+":"") << cel->reput << " Punktów Reputacji." << std::endl;
1537 out.close();
1538//----------------- End BDD Monitoring Pro System -----------------------------------
1539for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
1540 if(dynamic_cast<Player*>(it->second)){
1541 (*it).second->sendTextMessage(MSG_ADVANCE, wiadomosc2.str().c_str());
1542 (*it).second->sendMagicEffect(cel->pos, NM_ME_YELLOW_RINGS);}}
1543 }
1544else {
1545 player->sendTextMessage(MSG_BLUE_TEXT, wiadomosc1.str().c_str());
1546 }
1547 return true;
1548}
1549
1550
1551bool Commands::changeRepforItem(Creature* c, const std::string &cmd, const std::string ¶m)
1552{
1553 Player* player = dynamic_cast<Player*>(c);
1554 if(!player)
1555 return false;
1556 if (player->mmo > 0)
1557 {
1558 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1559 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1560 }
1561 if(player->mmo == 0)
1562 {
1563 if(player->reput >= 30)
1564 {
1565 player->TLMaddItem(4864, 1);
1566 std::stringstream ss;
1567 ss << "You have changed 30 reputation points for premium container!";
1568 player->sendTextMessage(MSG_INFO, ss.str().c_str());
1569 player->sendMagicEffect(player->pos, NM_ME_YELLOW_RINGS);
1570 player->reput -= 30;
1571
1572 }
1573 else
1574 {
1575 player->sendTextMessage(MSG_ADVANCE,"You dont have enought reputation points.");
1576 }
1577 player->mmo += 5;
1578 }
1579 return true;
1580
1581}
1582#endif //_BDD_REPUTACJA_
1583
1584bool Commands::BroadcastGuild(Creature* c, const std::string &cmd, const std::string ¶m)
1585{
1586 Player *player = dynamic_cast<Player*>(c);
1587 if (player->mmo > 0)
1588 {
1589 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1590 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1591 }
1592 if (player->mmo == 0 )
1593 {
1594 if(player->guildStatus == GUILD_LEADER || player->guildStatus == GUILD_VICE){
1595 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
1596 if(dynamic_cast<Player*>(it->second)){
1597 if((*it).second->guildId == player->guildId){
1598 std::stringstream bg;
1599 std::string message = param.c_str();
1600 bg << "[Guild-Info] " << player->getName()<< ": " << message.c_str() << std::endl;
1601 (*it).second->sendTextMessage(MSG_INFO, bg.str().c_str());}
1602 }
1603 }
1604 }else{
1605 player->sendCancel("You must be a leader or a vice leader to use this command.");
1606 }
1607 player->mmo += 5;
1608 return true;
1609}
1610 return false;
1611}
1612
1613bool Commands::showUptime(Creature* c, const std::string &cmd, const std::string ¶m)
1614{
1615 Player* player = dynamic_cast<Player*>(c);
1616 if (player->mmo > 0)
1617 {
1618 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1619 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1620 }
1621 if (player->mmo == 0 )
1622 {
1623 if (player)
1624 {
1625 uint64_t uptime = (OTSYS_TIME() - Status::instance()->start)/1000;
1626 int32_t h = (int32_t)floor(uptime / 3600.0);
1627 int32_t m = (int32_t)floor((uptime - h*3600) / 60.0);
1628 int32_t s = (int32_t)(uptime - h*3600 - m*60);
1629
1630 std::stringstream msg;
1631 msg << "Uptime: " << h << (h != 1? " hours " : " hour ") << m << (m != 1? " minutes. " : " minute. ") << std::ends;
1632
1633 player->sendTextMessage(MSG_BLUE_TEXT, msg.str().c_str());
1634 }
1635 player->mmo += 5;
1636 return true;
1637}
1638 return false;
1639}
1640bool Commands::allowPrivateChannel(Creature* c, const std::string &cmd, const std::string ¶m)
1641{
1642 Player* player = dynamic_cast<Player*>(c);
1643
1644 if(player){
1645 if(param == "off")
1646 {
1647 player->aceitarprivate = false;
1648 player->sendTextMessage(MSG_BLUE_TEXT,"Private Chat: OFF");
1649 }
1650 else if(param == "on"){
1651 player->aceitarprivate = true;
1652 player->sendTextMessage(MSG_BLUE_TEXT,"Private Chat: ON");
1653 }
1654 else{
1655 player->sendTextMessage(MSG_BLUE_TEXT,"Information:\n- /priv on\n- /priv off");
1656 }
1657 }
1658 return true;
1659}
1660
1661#ifdef __MIZIAK_BLESSING__
1662bool Commands::setBless(Creature* c, const std::string &cmd, const std::string ¶m)
1663{
1664 int bless;
1665 std::string name;
1666 std::istringstream in(param.c_str());
1667
1668 std::getline(in, name, ',');
1669 in >> bless;
1670
1671 Creature* creature = game->getCreatureByName(name);
1672 Player* player = dynamic_cast<Player*>(creature);
1673
1674 if (player)
1675 {
1676 player->blessing = bless;
1677 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it){
1678 (*it).second->sendMagicEffect(player->pos, NM_ME_SOUND_YELLOW);
1679 }
1680 }
1681
1682 return true;
1683}
1684
1685bool Commands::getBless(Creature* c, const std::string &cmd, const std::string ¶m)
1686{
1687 Player* player = dynamic_cast<Player*>(c);
1688 if (player->mmo > 0)
1689 {
1690 player->sendMagicEffect(player->pos, NM_ME_PUFF);
1691 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
1692 }
1693 if (player->mmo == 0 )
1694 {
1695 if(player)
1696 {
1697 std::stringstream bless;
1698 switch(player->blessing)
1699 {
1700 case 0:
1701 bless << "Currently you dont have any blessing.";
1702 break;
1703 case 1:
1704 bless << "Currently you have one blessing.";
1705 break;
1706 case 2:
1707 bless << "Currently you have two blessing.";
1708 break;
1709 case 3:
1710 bless << "Currently you have three blessing.";
1711 break;
1712 case 4:
1713 bless << "Currently you have all blessings.";
1714 break;
1715 }
1716 player->sendTextMessage(MSG_BLUE_TEXT, bless.str().c_str());
1717 }
1718 player->mmo += 5;
1719 return true;
1720}
1721 return false;
1722}
1723#endif
1724
1725#ifdef __MIZIAK_ADDS__
1726bool Commands::privMsg(Creature* c, const std::string &cmd, const std::string ¶m)
1727{
1728 std::string tmp = param;
1729 std::string::size_type pos = tmp.find(',', 0);
1730
1731 std::string name = tmp.substr(0, pos).c_str();
1732 tmp.erase(0, pos+1);
1733 std::string text = tmp.c_str();
1734
1735 Creature* creature = game->getCreatureByName(name);
1736 Player* player = dynamic_cast<Player*>(creature);
1737
1738 if(player)
1739 player->onCreatureSay(c, SPEAK_PRIVATE, text);
1740
1741 return true;
1742}
1743#endif
1744
1745bool Commands::outfitChange(Creature* c, const std::string &cmd, const std::string ¶m)
1746{
1747 std::string newLook;
1748 std::string playerName = param.c_str();
1749 int a;
1750
1751 for(a=0; a<param.length(); ++a){
1752 if(!isdigit(param[a])){
1753 newLook = param;
1754 newLook.erase(a,1-param.length());
1755 playerName.erase(0,1+a);
1756 break;
1757 }else{
1758 newLook = param.c_str();
1759 }
1760 }
1761
1762 unsigned long look = atoi(newLook.c_str());
1763
1764 if(Player* outfitChanged = game->getPlayerByName(playerName)){
1765 outfitChanged->looktype = look;
1766 outfitChanged->lookmaster = look;
1767 game->creatureChangeOutfit(outfitChanged);
1768 return true;
1769 }else {
1770 return false;
1771 }
1772 return false;
1773 }
1774
1775bool Commands::guildJoin(Creature* c, const std::string &cmd, const std::string ¶m)
1776{
1777 Player* player = dynamic_cast<Player*>(c);
1778 if(!player)
1779 return false;
1780
1781 std::string param_ = param;
1782 trimString(param_);
1783 if(!player->getGuildId())
1784 {
1785 uint32_t guildId;
1786 if(Guild::getInstance()->getGuildId(guildId, param_))
1787 {
1788 if(player->isGuildInvited(guildId))
1789 {
1790 Guild::getInstance()->joinGuild(player, guildId);
1791 player->sendTextMessage(MSG_INFO, "You have joined to the guild.");
1792
1793 char buffer[80];
1794 sprintf(buffer, "%s dolaczyl do gildii.", player->getName().c_str());
1795 if(ChatChannel* guildChannel = g_chat.getChannel(player, 0x00))
1796 guildChannel->talk(player, SPEAK_CHANNEL_R1, buffer, 0x00);
1797 }
1798 else
1799 player->sendTextMessage(MSG_BLUE_TEXT, "You aren't invited to this guild.");
1800 }
1801 else
1802 player->sendTextMessage(MSG_BLUE_TEXT, "There is no guild with that name.");
1803 }
1804 else
1805 player->sendTextMessage(MSG_BLUE_TEXT, "You are already in that guild.");
1806
1807 return true;
1808}
1809
1810bool Commands::guildCreate(Creature* c, const std::string &cmd, const std::string ¶m)
1811{
1812 Player* player = dynamic_cast<Player*>(c);
1813 if(!player)
1814 return false;
1815
1816 if(player->getGuildId())
1817 {
1818 player->sendCancel("You are already in that guild.");
1819 return true;
1820 }
1821
1822 std::string param_ = param;
1823 trimString(param_);
1824 if(!isValidName(param_))
1825 {
1826 player->sendTextMessage(MSG_BLUE_TEXT, "Guild name contain invalid symbols, try another one.");
1827 return true;
1828 }
1829
1830 const uint32_t minLength = 3;
1831 const uint32_t maxLength = 30;
1832 if(param_.length() < minLength)
1833 {
1834 player->sendTextMessage(MSG_BLUE_TEXT, "Guild name is too short, choose another name.");
1835 return true;
1836 }
1837
1838 if(param_.length() > maxLength)
1839 {
1840 player->sendTextMessage(MSG_BLUE_TEXT, "Guild name is too long, choose another name.");
1841 return true;
1842 }
1843
1844 uint32_t guildId;
1845 if(Guild::getInstance()->getGuildId(guildId, param_))
1846 {
1847 player->sendTextMessage(MSG_BLUE_TEXT, "There is already a guild with that name.");
1848 return true;
1849 }
1850
1851 const uint32_t levelToFormGuild = g_config.GUILD_FORM_LEVEL;
1852 if(player->getLevel() < levelToFormGuild || player->access > 1)
1853 {
1854 char buffer[70 + levelToFormGuild];
1855 sprintf(buffer, "You need %d level create a guild.", levelToFormGuild);
1856 player->sendTextMessage(MSG_BLUE_TEXT, buffer);
1857 return true;
1858 }
1859
1860 player->setGuildName(param_);
1861 Guild::getInstance()->createGuild(player);
1862
1863 char buffer[50 + maxLength];
1864 sprintf(buffer, "You have successfully created a guild \"%s\"!", param_.c_str());
1865 player->sendTextMessage(MSG_INFO, buffer);
1866 return true;
1867}
1868
1869bool Commands::cleanHouses(Creature* c, const std::string& cmd, const std::string& param)
1870{
1871 Player* player = dynamic_cast<Player*>(c);
1872 std::stringstream info;
1873 uint32_t days = atoi(param.c_str());
1874 int32_t count = game->checkHouseOwners(days);
1875 if(player)
1876 {
1877 info << "Clean domkow zakonczony. Oczyszczono " << count << " domkow.";
1878 player->sendTextMessage(MSG_RED_TEXT, info.str().c_str());
1879 }
1880}
1881
1882bool Commands::teleporter(Creature* c, const std::string &cmd, const std::string ¶m)
1883{
1884 Player *player = dynamic_cast<Player*>(c);
1885 std::stringstream info;
1886 bool found = false;
1887 if(player)
1888 {
1889 for(Town::TownMap::iterator sit = Town::town.begin(); sit != Town::town.end(); ++sit)
1890 {
1891 if(sit->second.name == param)
1892 {
1893 game->teleport(player, sit->second.pos);
1894 found = true;
1895 info << "Welcome to " << sit->second.name << ".";
1896 break;
1897 }
1898 }
1899 if(!found)
1900 info << "Not found.";
1901
1902 player->sendTextMessage(MSG_RED_TEXT, info.str().c_str());
1903 }
1904 return true;
1905}
1906
1907#ifdef WIZ_REWARD_SYSTEM
1908bool Commands::rewardSystem(Creature* c, const std::string &cmd, const std::string ¶m)
1909{
1910 Player* player = dynamic_cast<Player*>(c);
1911 std::string name;
1912
1913 char buf[350];
1914 short unsigned int itemid = 2148;
1915 std::string tmp = param;
1916 std::string::size_type pos;
1917 pos = tmp.find(",");
1918 std::string money = tmp.substr(0, pos).c_str();
1919 tmp.erase(0, pos+1);
1920 name = tmp;
1921 Player* reward = game->getPlayerByName(name);
1922
1923 if(player)
1924 {
1925 if(param == "")
1926 player->sendTextMessage(MSG_BLUE_TEXT, "Reward System Config:\n!reward ilosc_pieniedzy(crystal coins),player name\nE.g:\n/reward 100,Roar");
1927
1928 for(int i = 0; i < money.length(); i++)
1929 {
1930 if(!isdigit(money[i]))
1931 player->sendCancel("Enter the amount of money you offer for the players head.");
1932 }
1933
1934 if((atoi(money.c_str()) > player->getMoney()) || atoi(money.c_str()) <= 1000000){
1935 player->sendCancel("You dont have enought money.");
1936 return true;}
1937
1938 if(reward)
1939 {
1940 if(reward->isHunted)
1941 {
1942 player->sendCancel("This player has already hunted.");
1943 return true;
1944 }
1945
1946 if(player->access < reward->access)
1947 {
1948 player->sendCancel("You can not set reward for this player.");
1949 return true;
1950 }
1951
1952 //--Przelicznik//
1953 int itemid;
1954 unsigned int count;
1955 if(atoi(money.c_str()) <= 100)
1956 itemid = 2148;
1957 else if(atoi(money.c_str()) > 100 && atoi(money.c_str()) <= 10000){
1958 itemid = 2152;
1959 count = atoi(money.c_str())/100;}
1960 else if(atoi(money.c_str()) > 10000 && atoi(money.c_str()) <= 1000000){
1961 itemid = 2160;
1962 count = atoi(money.c_str())/10000;}
1963 else if(atoi(money.c_str()) > 1000000 && atoi(money.c_str()) <= 100000000){
1964 itemid = 2157;
1965 count = atoi(money.c_str())/1000000;}
1966 else if(atoi(money.c_str()) > 100000000){
1967 player->sendCancel("Too much.");
1968 return true;}
1969
1970 //tutja wrzucanie informacji o zleceniu
1971 // player_id, killer_id, date, price
1972
1973 /* INSERT DATA BEGIN */
1974 Database* db = Database::getInstance();
1975 DBQuery query;
1976 query << "INSERT INTO `bounty_hunters` (`id`, `player_id`, `killer_id`, `date`, `price`) VALUES (NULL, " << reward->getGUID() << ", 0, 0, " << money << ");";
1977 db->executeQuery(query.str());
1978 /* INSERT DATA END */
1979
1980 // wyslij mi to ten plik to u siebie zrobie bo tu zamula i chujowy edytor xd
1981 sprintf(buf, "Oferujesz %s gp za zabicie gracza %s .", money.c_str(), reward->getName().c_str());
1982 player->sendTextMessage(MSG_INFO, buf);
1983 //sprintf(buf, "[Bounty System] a bounty of %s gold for player->getName().c_str(), head has been submitted by Player %s. \nThe first one to kill player->getName().c_str(), will get the gold!." money.c_str());
1984 reward->sendTextMessage(MSG_ADVANCE, buf);
1985 reward->isHunted = true;
1986
1987
1988
1989 reward->price = atoi(money.c_str());
1990 player->removeItemSmart(itemid, count, true);
1991 }
1992 else{
1993 player->sendCancel("A player with this name is not online.");
1994 return false;
1995 }
1996 }
1997return true;
1998}
1999
2000bool Commands::checkRewards(Creature* c, const std::string &cmd, const std::string ¶m)
2001{
2002Player* player = dynamic_cast<Player*>(c);
2003std::stringstream players;
2004players << "Name & Reward:\n";
2005int i = 0;
2006int count = 0;
2007AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
2008for(;it != Player::listPlayer.list.end();++it)
2009{
2010if((*it).second->isHunted == true){
2011players << (*it).second->getName() << " [" << (*it).second->price << "cc],\n";
2012count++;
2013i++;
2014}
2015}
2016players << "Total: " << count << "." << std::endl;
2017player->sendTextMessage(MSG_INFO,players.str().c_str());
2018return true;
2019}
2020#endif
2021
2022#ifdef AFK_SYSTEM
2023
2024bool Commands::paccOff(Creature* c, const std::string &cmd, const std::string ¶m)
2025{
2026 std::stringstream info;
2027 Player* player = dynamic_cast<Player*>(c);
2028
2029 if (player->mmo > 0)
2030 {
2031 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2032 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");}
2033 else
2034 {
2035 if(player->paccoff == 1 || player->paccoff == 2)
2036 {
2037 player->paccoff = 0;
2038 info << "PACC SYSTEM: You have " << paccstr(player->premiumTicks) << " of premium, time stopped." << std::ends;
2039 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());}
2040
2041 else if(player->paccoff == 0)
2042 {
2043 player->paccoff = 1;
2044 info << "PACC SYSTEM: You have " << paccstr(player->premiumTicks) << " of premium, time started." << std::ends;
2045 player->sendTextMessage(MSG_BLUE_TEXT, info.str().c_str());}
2046 }
2047 player->mmo += 5;
2048 return true;
2049}
2050
2051#endif
2052
2053bool Commands::goOutfit(Creature* c, const std::string &cmd, const std::string ¶m)
2054{
2055 Player *player = dynamic_cast<Player*>(c);
2056 if (player->mmo > 0)
2057 {
2058 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2059 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");}
2060 else{
2061
2062
2063 if(player){
2064 if(player->guildStatus >= GUILD_VICE){
2065 for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++ it){
2066 Player *gildia = dynamic_cast<Player*>((*it).second);
2067 if(gildia->guildId == player->guildId && gildia != player){
2068 std::stringstream info; //eMKa
2069 info << player->getName() << " zmienil outfit gildi.";
2070 gildia->lookhead = player->lookhead;
2071 gildia->lookbody = player->lookbody; //eMKa
2072 gildia->looklegs = player->looklegs;
2073 gildia->lookfeet = player->lookfeet;
2074 game->creatureChangeOutfit(gildia);
2075 gildia->sendTextMessage(MSG_INFO, info.str().c_str());
2076 }
2077 }
2078 }
2079 else{
2080 player->sendCancel("You must be a leader or a vice leader to use this command.");
2081 player->mmo += 5;
2082 }
2083 }
2084 return true;
2085}
2086}
2087
2088bool Commands::gadkaBDD(Creature* c, const std::string &cmd, const std::string ¶m)
2089{
2090 std::string tmp = param;
2091 std::string::size_type pos;
2092 std::string message;
2093
2094 pos = tmp.find(",");
2095 std::string name = tmp.substr(0, pos).c_str();
2096 tmp.erase(0, pos+1);
2097
2098 message = tmp;
2099
2100 Creature* creature = game->getCreatureByName(name);
2101 Player* target = creature? dynamic_cast<Player*>(creature) : NULL;
2102 Player* player = dynamic_cast<Player*>(c);
2103
2104 if(target){
2105 target->sendTextMessage(MSG_RED_TEXT, message.c_str());
2106 }else{
2107 player->sendTextMessage(MSG_SMALLINFO, "Gracz nie jest wlogowany.");
2108 }
2109 return true;
2110}
2111bool Commands::ppremmy(Creature* c, const std::string &cmd, const std::string ¶m)
2112{
2113 int a;
2114 Player* player = dynamic_cast<Player*>(c);
2115
2116if (player->mmo > 0)
2117{
2118 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2119 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");
2120}
2121 std::string tickTack = param.c_str();
2122 std::string pacct;
2123
2124 for(a=0; a<param.length(); ++a)
2125{
2126 if(!isdigit(param[a])){
2127 pacct = param;
2128 pacct.erase(a,1-param.length());
2129 tickTack.erase(0,1+a);
2130 break;
2131 }
2132 else
2133 pacct = param.c_str();
2134}
2135 unsigned long newPacc = atoi(pacct.c_str());
2136 if(Player* toChange = game->getPlayerByName(tickTack))
2137 {
2138 if(toChange->premiumTicks >= 1800000001){
2139 return false;
2140 }
2141 if(g_config.FREE_PREMMY){
2142 player->sendTextMessage(MSG_BLUE_TEXT,"Aktualnie Pacc jest darmowy nie mozesz dokonac przelewu.");
2143 return false;
2144 }
2145if(player->premiumTicks <= 60*60*newPacc){
2146player->sendTextMessage(MSG_BLUE_TEXT,"Masz za malo godzin premium konta aby dokonac przelewu.");
2147return false;
2148}
2149if(newPacc < 50) {
2150 player->sendTextMessage(MSG_BLUE_TEXT,"Nie mozesz przelac mniej niz 50 godzin pacc.");
2151 return false;
2152}
2153std::ostringstream info;
2154info << "You received " << newPacc << " hours of premium account, from " << player->getName() << "." << std::ends;
2155player->sendTextMessage(MSG_BLUE_TEXT,"Transaction was successful!");
2156player->premiumTicks -= 60*60*newPacc;
2157toChange->sendTextMessage(MSG_PRIVATE, info.str().c_str());
2158toChange->premiumTicks += 60*60*newPacc;
2159return true;
2160}
2161else{
2162player->sendTextMessage(MSG_BLUE_TEXT,"Wpisz ilosc godzin oraz nick gracza.");
2163 player->mmo += 5;
2164 }
2165 return true;
2166}
2167/*
2168bool Commands::changeOufitPacc(Creature* c, const std::string &cmd, const std::string ¶m)
2169{
2170 Player* player = dynamic_cast<Player*>(c);
2171 Position pos;
2172 std::stringstream info;
2173 std::string temp = param;
2174
2175 if(!player)
2176 return false;
2177 if(!player->isPremium())
2178 {
2179 player->sendCancel("You must have PACC to use this command!");
2180 return false;
2181 }
2182 if (player->mmo > 0)
2183 {
2184 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2185 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");}
2186 else
2187 {
2188 if(player)
2189 {
2190 toLowerCaseString(temp);
2191 if(temp == "orc warlord")
2192 player->looktype = 2;
2193 else if(temp == "war wolf")
2194 player->looktype = 3;
2195 else if(temp == "orc ridder")
2196 player->looktype = 4;
2197 else if(temp == "orc")
2198 player->looktype = 5;
2199 else if(temp == "orc shaman")
2200 player->looktype = 6;
2201 else if(temp == "orc warrior")
2202 player->looktype = 7;
2203 else if(temp == "orc berserker")
2204 player->looktype = 8;
2205 else if(temp == "necromancer")
2206 player->looktype = 9;
2207 else if(temp == "black sheep")
2208 player->looktype = 13;
2209 else if(temp == "sheep")
2210 player->looktype = 14;
2211 else if(temp == "troll")
2212 player->looktype = 15;
2213 else if(temp == "bear")
2214 player->looktype = 16;
2215 else if(temp == "beholder")
2216 player->looktype = 17;
2217 else if(temp == "ghoul")
2218 player->looktype = 18;
2219 else if(temp == "slime")
2220 player->looktype = 19;
2221 else if(temp == "rat")
2222 player->looktype = 21;
2223 else if(temp == "cyclops")
2224 player->looktype = 22;
2225 else if(temp == "minotaur mage")
2226 player->looktype = 23;
2227 else if(temp == "minotaur archer")
2228 player->looktype = 24;
2229 else if(temp == "minotaur")
2230 player->looktype = 25;
2231 else if(temp == "rotworm")
2232 player->looktype = 26;
2233 else if(temp == "wolf")
2234 player->looktype = 27;
2235 else if(temp == "snake")
2236 player->looktype = 28;
2237 else if(temp == "minotaur guard")
2238 player->looktype = 29;
2239 else if(temp == "spider")
2240 player->looktype = 30;
2241 else if(temp == "deer")
2242 player->looktype = 31;
2243 else if(temp == "dog")
2244 player->looktype = 32;
2245 else if(temp == "skeleton")
2246 player->looktype = 33;
2247 else if(temp == "dragon")
2248 player->looktype = 34;
2249 else if(temp == "demon")
2250 player->looktype = 35;
2251 else if(temp == "poison spider")
2252 player->looktype = 36;
2253 else if(temp == "demon skeleton")
2254 player->looktype = 37;
2255 else if(temp == "giant spider")
2256 player->looktype = 38;
2257 else if(temp == "dragon lord")
2258 player->looktype = 39;
2259 else if(temp == "fire devil")
2260 player->looktype = 40;
2261 else if(temp == "lion")
2262 player->looktype = 41;
2263 else if(temp == "polar bear")
2264 player->looktype = 42;
2265 else if(temp == "scorpion")
2266 player->looktype = 43;
2267 else if(temp == "wasp")
2268 player->looktype = 44;
2269 else if(temp == "bug")
2270 player->looktype = 45;
2271 else if(temp == "ghost")
2272 player->looktype = 48;
2273 else if(temp == "fire elemental")
2274 player->looktype = 49;
2275 else if(temp == "orc spearman")
2276 player->looktype = 50;
2277 else if(temp == "Djinn")
2278 player->looktype = 51;
2279 else if(temp == "winter wolf")
2280 player->looktype = 52;
2281 else if(temp == "frost troll")
2282 player->looktype = 53;
2283 else if(temp == "witch")
2284 player->looktype = 54;
2285 else if(temp == "behemoth")
2286 player->looktype = 55;
2287 else if(temp == "cave rat")
2288 player->looktype = 56;
2289 else if(temp == "monk")
2290 player->looktype = 57;
2291 else if(temp == "priestess")
2292 player->looktype = 58;
2293 else if(temp == "orc leader")
2294 player->looktype = 59;
2295 else if(temp == "pig")
2296 player->looktype = 60;
2297 else if(temp == "goblin")
2298 player->looktype = 61;
2299 else if(temp == "elf")
2300 player->looktype = 62;
2301 else if(temp == "elf arcanist")
2302 player->looktype = 63;
2303 else if(temp == "elf scout")
2304 player->looktype = 64;
2305 else if(temp == "mummy")
2306 player->looktype = 65;
2307 else if(temp == "dwarf geomancer")
2308 player->looktype = 66;
2309 else if(temp == "stone golem")
2310 player->looktype = 67;
2311 else if(temp == "vampire")
2312 player->looktype = 68;
2313 else if(temp == "dwarf")
2314 player->looktype = 69;
2315 else if(temp == "dwarf guard")
2316 player->looktype = 70;
2317 else if(temp == "dwarf soldier")
2318 player->looktype = 71;
2319 else if(temp == "rabbit")
2320 player->looktype = 74;
2321 else if(temp == "swamp troll")
2322 player->looktype = 76;
2323 else if(temp == "butterfly")
2324 player->looktype = 213;
2325 else if(temp == "parrot")
2326 player->looktype = 217;
2327 else
2328 {
2329 info << "!outfits:" <<
2330 "\n- orc warlord" <<
2331 "\n- war wolf" <<
2332 "\n- orc ridder" <<
2333 "\n- orc";
2334 player->sendTextMessage(MSG_BLUE_TEXT,info.str().c_str());
2335 return false;
2336 }
2337
2338 game->creatureChangeOutfit(player);
2339 info << "You have changed the outfit to " << temp << "!";
2340 player->sendMagicEffect(player->pos,NM_ME_ENERGY_AREA);
2341 player->sendTextMessage(MSG_INFO,info.str().c_str());
2342 }
2343 }
2344 player->mmo += 5;
2345 return true;
2346}*/
2347
2348bool Commands::changeOufitPacc(Creature* c, const std::string &cmd, const std::string ¶m)
2349{
2350 Player* player = dynamic_cast<Player*>(c);
2351 Position pos;
2352 std::stringstream info;
2353 std::string temp = param;
2354
2355 if(!player)
2356 return false;
2357 if(!player->isPremium())
2358 {
2359 player->sendCancel("You must have PACC to use this command!");
2360 return false;
2361 }
2362 if (player->mmo > 0)
2363 {
2364 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2365 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");}
2366 else
2367 {
2368 if(player)
2369 {
2370 toLowerCaseString(temp);
2371 if(temp == "elf")
2372 player->sex = PLAYERSEX_NIMFA;
2373 else if(temp == "dwarf")
2374 player->sex = PLAYERSEX_DWARF;
2375 else
2376 {
2377 info << "!outfits:" <<
2378 "\n- dwarf" <<
2379 "\n- elf";
2380 player->sendTextMessage(MSG_INFO,info.str().c_str());
2381 return false;
2382 }
2383
2384 game->creatureChangeOutfit(player);
2385 info << "You have changed the outfit to " << temp << "!";
2386 player->sendMagicEffect(player->pos,NM_ME_ENERGY_AREA);
2387 player->sendTextMessage(MSG_INFO,info.str().c_str());
2388 }
2389 }
2390 player->mmo += 5;
2391 return true;
2392}
2393
2394#ifdef BLACK_HOUSE_TRADE
2395bool Commands::sellHouse(Creature* c, const std::string &cmd, const std::string ¶m)
2396{
2397 Player* player = dynamic_cast<Player*>(c);
2398 if(!player)
2399 return false;
2400 std::string playername = param;
2401
2402 Player* playertrade = game->getPlayerByName(playername);
2403 if (player->mmo > 0)
2404 {
2405 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2406 player->sendTextMessage(MSG_SMALLINFO, "Wait 60 seconds untill next use.");
2407 return false;
2408 }
2409 if(param == "")
2410 {
2411 player->sendTextMessage(MSG_INFO,"To use a command you have to be at your home. Use command : !sellhouse Player");
2412 return false;
2413 }
2414 else if(!playertrade)
2415 {
2416 player->sendTextMessage(MSG_INFO,"Player with this name is not existing!");
2417 return false;
2418 }
2419 else if(player==playertrade)
2420 {
2421 player->sendTextMessage(MSG_INFO,"You cant sell our house to yourself.");
2422 return false;
2423 }
2424 int posx = std::abs(playertrade->pos.x - player->pos.x);
2425 int posy = std::abs(playertrade->pos.y - player->pos.y);
2426 if(posx > 3 || posy > 3 || (playertrade->pos.z != player->pos.z))
2427 {
2428 player->sendTextMessage(MSG_INFO,"Player you want to sell your house is too far away!");
2429 return false;
2430 }
2431 Tile * krata = game->getTile(player->pos);
2432 House* dom = krata? krata->getHouse() : 0;
2433 if(!dom || dom && dom->getOwner() != player->name)
2434 {
2435 player->sendTextMessage(MSG_INFO,"You have to stand at home to sell it!");
2436 return false;
2437 }
2438 if (player->mmo == 0)
2439 {
2440 if(player->blackItem)
2441 delete player->blackItem;
2442 player->blackItem = Item::CreateItem(1969,1);
2443 std::stringstream doc;
2444 doc << "Document of house sold " << dom->getName();
2445 player->blackItem->setSpecialDescription(doc.str());
2446 game->playerRequestTrade(player, player->pos, 1, 1969, playertrade->getID(), player->blackItem);
2447 player->mmo += 60;
2448 return true;
2449 }
2450}
2451#endif
2452
2453bool Commands::addSkill(Creature* c, const std::string &cmd, const std::string ¶m)
2454{
2455 Player *gm = dynamic_cast<Player*>(c);
2456 std::string tmp = param;
2457 std::stringstream txt;
2458 std::string::size_type pos;
2459 pos = tmp.find(" ");
2460 std::string skill = tmp.substr(0, pos).c_str();
2461 tmp.erase(0, pos+1);
2462 pos = tmp.find(" ");
2463 int trys = atoi(tmp.substr(0, pos).c_str());
2464 tmp.erase(0, pos+1);
2465 std::string name = tmp.c_str();
2466 Player *dude = game->getPlayerByName(name);
2467
2468 if(dude)
2469 {
2470
2471 if(skill == "fist")
2472
2473 dude->addSkillTryInternal(trys,0);
2474
2475 else if(skill == "club")
2476
2477 dude->addSkillTryInternal(trys,1);
2478
2479 else if(skill == "sword")
2480
2481 dude->addSkillTryInternal(trys,2);
2482
2483 else if(skill == "axe")
2484
2485 dude->addSkillTryInternal(trys,3);
2486
2487 else if(skill == "dist")
2488
2489 dude->addSkillTryInternal(trys,4);
2490
2491 else if(skill == "shield")
2492
2493 dude->addSkillTryInternal(trys,5);
2494
2495 else if(skill == "fishing")
2496
2497 dude->addSkillTryInternal(trys,6);
2498
2499 else if(skill == "magic")
2500
2501 dude->addManaSpent(trys);
2502
2503 else if(skill == "level")
2504
2505 dude->level += trys;
2506
2507 else if(skill == "exp")
2508
2509 dude->addExp(trys);
2510
2511 else if(skill == "hp")
2512
2513 dude->health += trys;
2514
2515 else if(skill == "mp")
2516
2517 dude->mana += trys;
2518 else
2519 gm->sendTextMessage(MSG_RED_INFO, "Invalid skill name");
2520 }
2521
2522 else
2523 gm->sendTextMessage(MSG_RED_INFO, "Player not online.");
2524
2525 return true;
2526}
2527
2528bool Commands::SpellsCommand(Creature* c, const std::string &cmd, const std::string ¶m)
2529{
2530 Player *player = dynamic_cast<Player*>(c);
2531 if(!player)
2532 return false;
2533 const int size = spells.getVocSpells(player->getVocation())->size();
2534 unsigned int manas[size];
2535 int counter = 0;
2536 std::string spell[size];
2537 std::map<std::string, Spell*>::const_iterator citer = spells.getVocSpells(player->getVocation())->begin();
2538 while(citer != spells.getVocSpells(player->getVocation())->end())
2539 {
2540 std::stringstream tmp;
2541 InstantSpell* s = dynamic_cast<InstantSpell*>(citer->second);
2542 if(s)
2543 {
2544 tmp << s->getWords() << ": MagLevel: "<< citer->second->getMagLv() <<", Mana: "<< (manas[counter] = citer->second->getMana()) <<'\n';
2545 spell[counter] = tmp.str();
2546 }
2547 ++counter;
2548 ++citer;
2549 }
2550 //sortowanie
2551 int tmp_size = size;
2552 while(tmp_size)
2553 {
2554 for(int i = 0; i < size-1; i++)
2555 {
2556 if(manas[i] > manas[i+1]) {
2557 std::swap(manas[i],manas[i+1]);
2558 std::swap(spell[i],spell[i+1]);
2559 }
2560 }
2561 tmp_size--;
2562 }
2563 std::stringstream sss;
2564 for(int i = 0; i < sizeof(spell)/sizeof(*spell); i++) {
2565 sss << spell[i];
2566}
2567}
2568
2569bool Commands::changeGmNick(Creature* c, const std::string &cmd, const std::string ¶m)
2570{
2571 Player* player = dynamic_cast<Player*>(c);
2572 if(!player)
2573 return false;
2574 player->gmName = param;
2575 return true;
2576}
2577
2578#define STORAGE_TASK_POINTS 50377
2579#define STORAGE_MAX_TASK_POINTS 50378
2580#define STORAGE_ALL_TASK_POINTS 50379
2581#define STORAGE_TASK_OUTFIT 50382
2582#define STORAGE_TASK_ITEM 50383
2583#define TASK_OUTFIT 160 //dwarf
2584
2585bool Commands::TaskSystem(Creature* c, const std::string& cmd, const std::string& param)
2586{
2587 Player *player = dynamic_cast<Player*>(c);
2588 if(!player)
2589 return false;
2590 if(param == "points") {
2591 std::stringstream ss;
2592 int32_t count, allpoints;
2593 player->getStorageValue(STORAGE_TASK_POINTS, count);
2594 player->getStorageValue(STORAGE_ALL_TASK_POINTS, allpoints);
2595 ss << "Task points: " << count << ", points spended: " << allpoints << ".";
2596 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2597 return true;
2598 }
2599 else if(param == "maxpoints") {
2600 int32_t points, maxpoints;
2601 player->getStorageValue(STORAGE_TASK_POINTS, points);
2602 player->getStorageValue(STORAGE_MAX_TASK_POINTS, maxpoints);
2603 if(points < maxpoints) {
2604 std::stringstream ss;
2605 ss << "The current maximum number of points: " << maxpoints << ". You can't increase the amount of this because you have not enought points.";
2606 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2607 }
2608 else {
2609 std::stringstream ss;
2610 int32_t allpoints;
2611 player->getStorageValue(STORAGE_ALL_TASK_POINTS, allpoints);
2612 ss << "You have increased your maximum amount of points! Preexisting max. number of points: " << maxpoints <<", actually: " << maxpoints+500 << ".";
2613 player->addStorageValue(STORAGE_MAX_TASK_POINTS, maxpoints+500);
2614 player->addStorageValue(STORAGE_TASK_POINTS, 0);
2615 player->addStorageValue(STORAGE_ALL_TASK_POINTS, allpoints + points);
2616 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2617 }
2618 return true;
2619 }
2620 else if(param == "cc") {
2621 int32_t points;
2622 player->getStorageValue(STORAGE_TASK_POINTS, points);
2623 if(points >= 2000) {
2624 int32_t allpoints;
2625 player->getStorageValue(STORAGE_ALL_TASK_POINTS, allpoints);
2626 std::stringstream ss;
2627 ss << "You have changed a 2000 points for 50 crystal coins.";
2628 player->addStorageValue(STORAGE_ALL_TASK_POINTS, allpoints + 2000);
2629 player->addStorageValue(STORAGE_TASK_POINTS, points - 2000);
2630 player->TLMaddItem(2160, 50);
2631 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2632 }
2633 else {
2634 player->sendTextMessage(MSG_INFO, "You don't have a such of points to change them for a 50 crystal coins.\nRequired number of points : 2000");
2635
2636 }
2637 return true;
2638 }
2639 else if(param == "level") {
2640 int32_t points, reqpoints = player->getLevel()*15;
2641 player->getStorageValue(STORAGE_TASK_POINTS, points);
2642 if(points < reqpoints) {
2643 std::stringstream ss;
2644 ss << "You haven't required number of points to change it for 3 levels.\nRequired number of points: " << reqpoints << ".";
2645 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2646 }
2647 else {
2648 int64_t addPoints = (player->getExperience() - player->getExpForLv(player->getLevel())) + (player->getExpForLv(player->getLevel()+3) - player->getExpForLv(player->getLevel()));
2649 std::stringstream ss;
2650 int32_t allpoints;
2651 player->getStorageValue(STORAGE_ALL_TASK_POINTS, allpoints);
2652 ss << "You have changed " << reqpoints << " points for 3 levels (" << addPoints << " exp)!";
2653 player->addExp(addPoints);
2654 player->addStorageValue(STORAGE_ALL_TASK_POINTS, allpoints + reqpoints);
2655 player->addStorageValue(STORAGE_TASK_POINTS, points - reqpoints);
2656 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2657 }
2658 return true;
2659 }
2660 else if(param == "outfit") {
2661 int32_t points, outf;
2662 player->getStorageValue(STORAGE_TASK_POINTS, points);
2663 player->getStorageValue(STORAGE_TASK_OUTFIT, outf);
2664 if(outf == 1) {
2665 player->looktype = TASK_OUTFIT;
2666 game->creatureChangeOutfit(player);
2667 player->sendMagicEffect(player->pos,NM_ME_ENERGY_AREA);
2668 player->sendTextMessage(MSG_INFO, "You have changed your outfit to dwarf!");
2669 }
2670 else if(points < 10000) {
2671 player->sendTextMessage(MSG_INFO, "You haven't required ammount of points to buy a yeti outfit.\nRequired ammount of points is: 10000.");
2672 }
2673 else if(points >= 10000) {
2674 int32_t allpoints;
2675 player->getStorageValue(STORAGE_ALL_TASK_POINTS, allpoints);
2676 player->sendTextMessage(MSG_INFO, "You have bought a yeti outfit for 10000 points. From now, you can use a command \"!task outfit\" and change your outfit for free!");
2677 player->addStorageValue(STORAGE_TASK_OUTFIT, 1);
2678 player->addStorageValue(STORAGE_ALL_TASK_POINTS, points + 10000);
2679 player->addStorageValue(STORAGE_TASK_POINTS, points - 10000);
2680 player->looktype = TASK_OUTFIT;
2681 game->creatureChangeOutfit(player);
2682 player->sendMagicEffect(player->pos,NM_ME_ENERGY_AREA);
2683 }
2684 return true;
2685 }
2686 else if(param == "item") {
2687 int32_t points, item;
2688 player->getStorageValue(STORAGE_TASK_POINTS, points);
2689 player->getStorageValue(STORAGE_TASK_ITEM, item);
2690 if(item == 1) {
2691 player->sendTextMessage(MSG_INFO, "You have changed your points for random item!");
2692 return true;
2693 }
2694 else if(points < 30000) {
2695 player->sendTextMessage(MSG_INFO, "You don't have a required ammount of points for changing it for random item.\nRequired ammount :30000.");
2696 }
2697 else if(points >= 20000) {
2698 int32_t allpoints;
2699 player->getStorageValue(STORAGE_ALL_TASK_POINTS, allpoints);
2700 int32_t items[] = {2662, 2415, 2352, 2362, 2322, 2496, 2015, 2195, 2197, 2472, 2415, 2352, 2362, 2322, 2496, 2015, 2195, 2197};
2701 int32_t itemid = items[random_range(0,20)];
2702 player->TLMaddItem(itemid, 1);
2703 std::stringstream ss;
2704 ss << "Wymieniles 20000 punktow za " << Item::items[itemid].name.c_str() << "!";
2705 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2706 player->addStorageValue(STORAGE_TASK_ITEM, 1);
2707 player->addStorageValue(STORAGE_ALL_TASK_POINTS, points + 20000);
2708 player->addStorageValue(STORAGE_TASK_POINTS, points - 20000);
2709 }
2710 return true;
2711 }
2712 else {
2713 player->sendTextMessage(MSG_INFO, "Mozliwe parametry komendy:\n!task points - show how much points you already have,\n!task maxpoints - increase maximum amount of points by 500 (price 100% points),"
2714 "\n!task cc - changing points for 50cc (price is 2000 points),\n!task outfit - buys a outfit (price: 10000 points, next uses for free),\n!task item - (20000 points!) changing the points for random item.");
2715 }
2716 return true;
2717}
2718
2719bool Commands::ChangePacc(Creature* c, const std::string &cmd, const std::string ¶m)
2720{
2721 Player *player = dynamic_cast<Player *>(c);
2722 if(!player)
2723 return false;
2724 uint32_t pacc = 0, pacc2 = 1;
2725 std::istringstream in(param.c_str());
2726 in >> pacc;
2727
2728 if(pacc < 1)
2729 {
2730 player->sendTextMessage(MSG_INFO, "You cannot exchange count of pacc lower than 1 to pacc rune.");
2731 return true;
2732 }
2733
2734 pacc2 *= pacc*60*60;
2735 if(player->premiumTicks < pacc2 || pacc2 < 50 || !player->isPremium())
2736 {
2737 player->sendTextMessage(MSG_INFO, "You don't have enought premium time, minimum (50h).");
2738 return true;
2739 }
2740 Item *newItem = Item::CreateItem(2281, 1);
2741 if(!newItem)
2742 return true;
2743 newItem->setActionId(100+pacc);
2744 player->premiumTicks -= pacc2;
2745 std::stringstream ss;
2746 ss << "You have changed " << pacc << " premium hours to premium rune!";
2747 player->sendTextMessage(MSG_INFO, ss.str().c_str());
2748
2749 if(player)
2750 player->TLMaddItem(newItem);
2751 else
2752 delete newItem;
2753 return true;
2754}
2755
2756bool Commands::GiveMute(Creature* c, const std::string &cmd, const std::string ¶m)
2757{
2758 Player *player = dynamic_cast<Player *>(c);
2759 if(!player)
2760 return false;
2761
2762 std::string tmp = param;
2763
2764 std::string::size_type pos = tmp.find(",");
2765 std::string name = tmp.substr(0, pos).c_str();
2766 tmp.erase(0, pos+1);
2767 int32_t ticks = atoi(tmp.c_str());
2768
2769 Player* target = game->getPlayerByName(name);
2770 if(target)
2771 {
2772 target->muteTicks += ticks;
2773 target->isMuted = true;
2774 char buf[128];
2775 sprintf(buf, "You have recived %i %s of muted!", ticks, (ticks != 1? "seconds" : "second"));
2776 target->sendTextMessage(MSG_INFO, buf);
2777
2778 }
2779 else if(player->isMuted)
2780 {
2781 std::stringstream strs;
2782 strs << "You are still muted for " << player->muteTicks << " seconds.";
2783 player->sendCancel(strs.str().c_str());
2784 return false;
2785 }
2786 else
2787 {
2788 player->sendTextMessage(MSG_SMALLINFO, "This player is not online.");
2789 }
2790
2791 return true;
2792}
2793
2794#ifdef BLACK_OFIARA
2795bool Commands::JakaJestOfiara(Creature* c, const std::string &cmd, const std::string ¶m)
2796{
2797 Player* player = dynamic_cast<Player*>(c);
2798 if(!player)
2799 return false;
2800 char buf[256];
2801 sprintf(buf, "Wyglada na to, ze mnoznik doswiadczenia dla Ciebie to: %0.2f (w tym %0.2f z poprzednich ofiar).\nJutrzejszy mnoznik bedzie wynosil dla Ciebie %0.2fx.\nDzisiejsza ofiara to: %s. Wystawiono juz dzisiaj %i ofiar.", (*game->stages)[player->getLevel()], game->ofiary->getCurrentExp(),(*game->stages)[player->getLevel()]-game->ofiary->getCurrentExp()+game->ofiary->getNextExp(), game->ofiary->getItemName().c_str(), game->ofiary->getCount());
2802 player->sendTextMessage(MSG_BLUE_TEXT,buf);
2803 return true;
2804}
2805#endif //BLACK_OFIARA
2806
2807#ifdef BLACK_BOSS_CHECKBOT
2808bool Commands::checkBot(Creature* c, const std::string &cmd, const std::string ¶m)
2809{
2810 Player* target = game->getPlayerByName(param);
2811 if(!target)
2812 {
2813 Player* player = dynamic_cast<Player*>(c);
2814 if(player)
2815 player->sendTextMessage(MSG_INFO, "Player doesn't exists.");
2816 return false;
2817 }
2818 int16_t one = random_range(70,90);
2819 target->addCheckBot(Dzialanie(one, one-random_range(10,50), (bool)random_range(0,1)));
2820 game->checkBot(target, 180);
2821 Player* player = dynamic_cast<Player*>(c);
2822 if(player)
2823 player->sendTextMessage(MSG_INFO, "Zgloszenie do gracza zostalo wyslane.");
2824 return true;
2825}
2826
2827bool Commands::checkAnswer(Creature* c, const std::string &cmd, const std::string ¶m)
2828{
2829 Player* player = dynamic_cast<Player*>(c);
2830
2831 if(!player)
2832 return false;
2833
2834 if(!player->activeCheck)
2835 return false;
2836
2837 if (player->mmo > 0)
2838 {
2839 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2840 player->sendTextMessage(MSG_SMALLINFO, "Wait 30 seconds untill next use.");
2841 return false;
2842 }
2843
2844 //log
2845 unsigned char playerip[4];
2846 *(unsigned long*)&playerip = player->lastip;
2847 char buf[64];
2848 time_t ticks = time(0);
2849 strftime(buf, sizeof(buf), "%Y-%m-%d, %H:%M", localtime(&ticks));
2850 std::string file = "/home/all/data/logs/autocheck/" + player->getName() + ".log";
2851 std::ofstream outfile;
2852 outfile.open(file.c_str(), std::ios_base::out | std::ios_base::app);
2853 outfile << "[" << buf << "] " << player->getName() << " [POS: " << player->pos.x << " " << player->pos.y << " " << player->pos.z << " ,IP: " << (unsigned int)playerip[0] << "." << (unsigned int)playerip[1] << "." << (unsigned int)playerip[2] << "." << (unsigned int)playerip[3] << "] " << player->dzialanie.wynik << std::endl;
2854 outfile.close();
2855 //
2856
2857 int16_t answer = atoi(param.c_str());
2858 if(answer != player->dzialanie.wynik) {
2859 player->sendTextMessage(MSG_RED_INFO,"Wrong answer!");
2860 player->sendTextMessage(MSG_INFO,"Bledna odpowiedz!!");
2861 player->mmo += 30;
2862 return false;
2863 }
2864
2865 player->activeCheck = false;
2866 player->sendTextMessage(MSG_RED_INFO, "(BOT CHECKER): Good answer!");
2867 player->sendTextMessage(MSG_INFO, "(BOT CHECKER): Dobra odpowiedz!");
2868 return true;
2869}
2870#endif //BLACK_BOSS_CHECKBOT
2871
2872bool Commands::antyKick(Creature* c, const std::string &cmd, const std::string ¶m)
2873{
2874 std::stringstream info;
2875 Player* player = dynamic_cast<Player*>(c);
2876 if(!player)
2877 return false;
2878
2879 if (player->mmo > 0)
2880 {
2881 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2882 player->sendTextMessage(MSG_SMALLINFO, "Wait 5 seconds untill next use.");}
2883 else{
2884
2885
2886 if(player->antyafk == 1)
2887 {
2888 player->antyafk = 0;
2889 info << "AFK SYSTEM: Stopped!" << std::ends;
2890 player->sendTextMessage(MSG_INFO, info.str().c_str());}
2891
2892 else if(player->antyafk == 0)
2893 {
2894 player->antyafk = 1;
2895 info << "AFK SYSTEM: Started!" << std::ends;
2896 player->sendTextMessage(MSG_INFO, info.str().c_str());
2897 }
2898 }
2899 player->mmo += 5;
2900 return true;
2901}
2902
2903bool Commands::bugReport(Creature* c, const std::string &cmd, const std::string ¶m)
2904{
2905 Player* player = dynamic_cast<Player*>(c);
2906 if(!player)
2907 return false;
2908 const uint32_t minLength = 10;
2909 std::string param_ = param;
2910
2911
2912 if (player->mmo > 0)
2913 {
2914 player->sendMagicEffect(player->pos, NM_ME_PUFF);
2915 player->sendTextMessage(MSG_SMALLINFO, "Wait 60 seconds untill next use.");
2916 return false;
2917 }
2918 if(param == "")
2919 {
2920 player->sendTextMessage(MSG_BLUE_TEXT,"You cant send an empty message.");
2921 return false;
2922 }
2923 if(param_.length() < minLength)
2924 {
2925 player->sendTextMessage(MSG_BLUE_TEXT, "Your bug report message is too short.");
2926 return false;
2927 }
2928 if (player->mmo == 0 )
2929 {
2930 unsigned char playerip[4];
2931 *(unsigned long*)&playerip = player->lastip;
2932 char buf[64];
2933 time_t ticks = time(0);
2934 strftime(buf, sizeof(buf), "%Y-%m-%d, %H:%M", localtime(&ticks));
2935 std::string file = "/home/all/data/logs/bugs/" + player->getName() + ".log";
2936 std::ofstream outfile;
2937 outfile.open(file.c_str(), std::ios_base::out | std::ios_base::app);
2938 outfile << "[" << buf << "] " << player->getName() << " [POS: " << player->pos.x << " " << player->pos.y << " " << player->pos.z << " ,IP: " << (unsigned int)playerip[0] << "." << (unsigned int)playerip[1] << "." << (unsigned int)playerip[2] << "." << (unsigned int)playerip[3] << "] " << param << std::endl;
2939 outfile.close();
2940 player->sendTextMessage(MSG_INFO, "Your report has been sent.\nWe will try to solve the problem within 24 hours.");
2941 }
2942 player->mmo += 60;
2943 return true;
2944}
2945
2946bool Commands::male(Creature* c, const std::string &cmd, const std::string ¶m)
2947{
2948 Creature* creature = game->getCreatureByName(param);
2949 if(!creature)
2950 return false;
2951 Player* target = dynamic_cast<Player*>(creature);
2952
2953 if (target->sex != PLAYERSEX_MALE)
2954 {
2955 target->sex = PLAYERSEX_MALE;
2956 target->sendMagicEffect(target->pos, NM_ME_MAGIC_ENERGIE);
2957 target->sendTextMessage(MSG_INFO, "Congratulations, change of sex ended successfully. You are a man from now on.");
2958 }
2959 else
2960 {
2961 target->sendMagicEffect(target->pos, NM_ME_PUFF);
2962 target->sendTextMessage(MSG_INFO, "You are already a man! You can not change sex on the same.");
2963 }
2964
2965 return true;
2966}
2967
2968bool Commands::female(Creature* c, const std::string &cmd, const std::string ¶m)
2969{
2970 Creature* creature = game->getCreatureByName(param);
2971 if(!creature)
2972 return false;
2973 Player* target = dynamic_cast<Player*>(creature);
2974
2975 if (target->sex != PLAYERSEX_FEMALE)
2976 {
2977 target->sex = PLAYERSEX_FEMALE;
2978 target->sendMagicEffect(target->pos, NM_ME_MAGIC_ENERGIE);
2979 target->sendTextMessage(MSG_INFO, "Congratulations, change of sex ended successfully. You are a girl from now on.");
2980 }
2981 else
2982 {
2983 target->sendMagicEffect(target->pos, NM_ME_PUFF);
2984 target->sendTextMessage(MSG_INFO, "You are already a girl! You can not change sex on the same.");
2985 }
2986 return true;
2987}
2988
2989bool Commands::dwarf(Creature* c, const std::string &cmd, const std::string ¶m)
2990{
2991 Player* player = dynamic_cast<Player*>(c);
2992 Creature* creature = game->getCreatureByName(param);
2993 if(!creature)
2994 return true;
2995 Player* target = dynamic_cast<Player*>(creature);
2996
2997 if (target->sex != PLAYERSEX_DWARF)
2998 {
2999 target->sex = PLAYERSEX_DWARF;
3000 target->sendMagicEffect(target->pos, NM_ME_MAGIC_ENERGIE);
3001 target->sendTextMessage(MSG_INFO, "Congratulations, change of sex ended successfully. You are a dwarf from now on.");
3002 }
3003 else
3004 {
3005 target->sendMagicEffect(target->pos, NM_ME_PUFF);
3006 target->sendTextMessage(MSG_INFO, "You are already a dwarf! You can not change sex on the same.");
3007 }
3008 return true;
3009
3010}
3011
3012bool Commands::nimfa(Creature* c, const std::string &cmd, const std::string ¶m)
3013{
3014 Creature* creature = game->getCreatureByName(param);
3015 if(!creature)
3016 return false;
3017 Player* target = dynamic_cast<Player*>(creature);
3018
3019 if (target->sex != PLAYERSEX_NIMFA)
3020 {
3021 target->sex = PLAYERSEX_NIMFA;
3022 target->sendMagicEffect(target->pos, NM_ME_MAGIC_ENERGIE);
3023 target->sendTextMessage(MSG_INFO, "Congratulations, change of sex ended successfully. You are an elf from now on.");
3024 }
3025 else
3026 {
3027 target->sendMagicEffect(target->pos, NM_ME_PUFF);
3028 target->sendTextMessage(MSG_INFO, "You are already an elf! You can not change sex on the same.");
3029 }
3030 return true;
3031}