+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] GOLD <NUMBER>");
+ return;
+ }
+ target->stats->gold = stringtoint(cmd2);
+ notice(s_GameServ, u, "Gold set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "STRENGTH") == 0 && stricmp(cmd2, "POTIONS") != 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] STRENGTH <NUMBER>");
+ return;
+ }
+
+ target->stats->strength = stringtoint(cmd2);
+ notice(s_GameServ, u, "Strength set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "DEFENSE") == 0 && stricmp(cmd2, "POTIONS") != 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] DEFENSE <NUMBER>");
+ return;
+ }
+
+ target->stats->defense = stringtoint(cmd2);
+ notice(s_GameServ, u, "Defense set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "HP") == 0 && stricmp(cmd2, "POTIONS") != 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] HP <NUMBER>");
+ return;
+ }
+ target->stats->hp = stringtoint(cmd2);
+ notice(s_GameServ, u, "HP set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "MAXHP") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] MAXHP <NUMBER>");
+ return;
+ }
+ target->stats->maxhp = stringtoint(cmd2);
+ notice(s_GameServ, u, "MaxHP set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "EXPERIENCE") == 0 || stricmp(cmd, "EXP") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {EXPERIENCE|EXP} <NUMBER>");
+ return;
+ }
+
+ target->stats->exp = stringtoint(cmd2);
+ notice(s_GameServ, u, "Exp set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "LEVEL") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] LEVEL <NUMBER>");
+ return;
+ }
+ target->stats->level = stringtoint(cmd2);
+ notice(s_GameServ, u, "Level set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "WEAPON") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] WEAPON <NUMBER>");
+ return;
+ }
+
+ target->stats->weapon = stringtoint(cmd2);
+ notice(s_GameServ, u, "Weapon set to %s", weapons[target->stats->weapon]);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "ARMOR") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] ARMOR <NUMBER>");
+ return;
+ }
+ target->stats->armor = stringtoint(cmd2);
+ notice(s_GameServ, u, "Armor set to %s", armors[target->stats->armor]);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "HP") == 0 && stricmp(cmd2, "POTIONS") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] HP POTIONS <NUMBER>");
+ return;
+ }
+ target->stats->inventory.setHP(stringtoint(cmd2));
+ notice(s_GameServ, u, "HP Potions set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "HEALING") == 0 && stricmp(cmd2, "POTIONS") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] HEALING POTIONS <NUMBER>");
+ return;
+ }
+ target->stats->inventory.setHealing(stringtoint(cmd2));
+ notice(s_GameServ, u, "Healing Potions set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "STRENGTH") == 0 && stricmp(cmd2, "POTIONS") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] STRENGTH POTIONS <NUMBER>");
+ return;
+ }
+ target->stats->inventory.setStrength(stringtoint(cmd2));
+ notice(s_GameServ, u, "Strength Potions set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "DEFENSE") == 0 && stricmp(cmd2, "POTIONS") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] DEFENSE POTIONS <NUMBER>");
+ return;
+ }
+ target->stats->inventory.setDefense(stringtoint(cmd2));
+ notice(s_GameServ, u, "Defense Potions set to %s", cmd2);
+ return;
+ }
+ }
+ else if (stricmp(cmd, "ALIVE") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2 || (stricmp(cmd2, "TRUE") != 0 && stricmp(cmd2, "FALSE") != 0))
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET ALIVE TRUE|FALSE");
+ return;
+ }
+ else if (stricmp(cmd2, "TRUE") == 0)
+ {
+ notice(s_GameServ, u, "Target has been Resurrected!");
+ target->addFlag(FLAG_ALIVE);
+ }
+ else
+ {
+ notice(s_GameServ, u, "Target is now dead!");
+ target->remFlag(FLAG_ALIVE);
+ }
+ }
+ }
+ else if (stricmp(cmd, "SEEN") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else if (stricmp(cmd2, "MASTER") != 0)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] SEEN MASTER {TRUE|FALSE}");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2 || (stricmp(cmd2, "TRUE") != 0 && stricmp(cmd2, "FALSE") != 0))
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NICK] SEEN MASTER {TRUE|FALSE}");
+ return;
+ }
+ else if (stricmp(cmd2, "TRUE") == 0)
+ {
+ notice(s_GameServ, u, "Target has seen their master now.");
+ target->addFlag(FLAG_MASTER);
+ }
+ else
+ {
+ notice(s_GameServ, u, "Target has not seen their master now.");
+ target->remFlag(FLAG_MASTER);
+ }
+ }
+ }
+ else
+ {
+ notice(s_GameServ, u, "Unknown command: SET %s", cmd);
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|WEAPON|ARMOR|HP POTIONS|STRENGTH POTIONS|DEFENSE POTIONS|HEALING POTIONS|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+ return;
+ }
+}
+
+void do_logout(char *u)
+{
+ aClient *user;
+ char *name = strtok(NULL, " ");
+
+ if (!(user = find(u)))
+ {
+ notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
+ "Buf: %s LOGOUT", u);
+ log("Could not find aClient Buf: %s LOGOUT",
+ u);
+ return;
+ }
+ else if (isIgnore(user))
+ {
+ #ifdef DEBUGMODE
+ log("Ignoring %s.", user->getNick());
+ #endif
+ return;
+ }
+
+ if (name)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "You must be a %S admin to use this command!");
+ }
+ else if (!(user = findplayer(name)))
+ {
+ notice(s_GameServ, u, "Couldn't find a player named %s", name);
+ }
+ else
+ {
+ notice(s_GameServ, u, "Logging out %s", user->stats->name.c_str());
+ logout(user);
+ }
+ }
+ else if (!name)
+ {
+ if (!is_playing(user))
+ {
+ notice(s_GameServ, u, "You're not logged in!");
+ }
+ else if (is_fighting(user))
+ {
+ notice(s_GameServ, u, "You can't logout while fighting!");
+ }
+ else
+ {
+ notice(s_GameServ, u, "You have left the fields. You have lived to kill another day!");
+ logout(user);
+ }
+ }
+}
+
+void logout(aClient *user)
+{
+ if (is_playing(user))
+ {
+ ListNode<aClient> *it;
+ aClient *temp;
+ unsigned long hv = iHASH((unsigned char *) user->stats->name.c_str());
+ it = players[hv].Find(user);
+
+ if (!it)
+ {
+ notice(s_GameServ, user->getNick(), "Fatal error. Contact "\
+ "%S Admin. Cannot find you in the players list.");
+ log("Error on logout(). Can't find %s in the players list",
+ #ifdef P10
+ user->getRealNick()
+ #else
+ user->getNick()
+ #endif
+ );
+ return;
+ }
+
+ temp = new aClient;
+ temp->stats = new Player;
+ temp->stats->setData(user->stats);
+ user->stats->client = NULL;
+
+ if (player_fight(user))
+ user->stats->battle->stats->battle = NULL;
+
+ delete user->stats;
+ user->stats = NULL;
+ temp->stats->client = NULL;
+ #ifdef P10
+ temp->setRealNick("Not Playing");
+ #endif
+ temp->setNick("Not Playing");
+
+ it->setNewPtr(temp);
+ #ifdef DEBUGMODE
+ log("Logged out player %s",
+ #ifdef P10
+ user->getRealNick()
+ #else
+ user->getNick()
+ #endif
+ );
+ #endif
+ }
+ clearPlaying(user);