+void do_set(char *u)
+{
+ aClient *user, *target;
+ char *name = strtok(NULL, " ");
+ char *cmd = strtok(NULL, " ");
+ char *cmd2;
+
+ if (!(user = find(u)))
+ {
+ notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
+ "Buf: %s LOGOUT", u);
+ return;
+ }
+ else if (isIgnore(user))
+ {
+#ifdef DEBUGMODE
+ log("Ignoring %s.", user->getNick());
+#endif
+ return;
+ }
+ else if (!name || !cmd)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+ return;
+ }
+ else if (!(target = findplayer(name)))
+ {
+ // Back the pointers up... they didn't send a name probably
+ cmd2 = cmd;
+ cmd = name;
+ target = user;
+
+ if (!is_playing(user))
+ {
+ notice(s_GameServ, u, "You must be playing to set things for yourself!");
+ return;
+ }
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ }
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+ return;
+ }
+
+ // Regardless of the previous if/else, if it got here, we know we have the cmd pointer at the right spot.
+ if (stricmp(cmd, "PASSWORD") == 0)
+ {
+ // Person is looking to change their password
+ // If they're an admin, or it's theirself, allow it
+ // cmd2 is pointing to the password now
+ if (isAdmin(user) || user == target)
+ {
+ target->stats->setPassword(cmd2);
+ notice(s_GameServ, u, "Password successfully changed");
+ }
+ else if (user != target && !isAdmin(user))
+ {
+ notice(s_GameServ, u, "You must be a %S admin to set other peoples' passwords.");
+ return;
+ }
+ }
+ else if (stricmp(cmd, "BANK") == 0 || stricmp(cmd, "BALANCE") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else if (stricmp(cmd, "BANK") == 0)
+ {
+ cmd2 = strtok(NULL, " "); // Need an extra parameter for set bank balance
+ }
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] [BANK] BALANCE <NUMBER>");
+ return;
+ }
+
+ target->stats->setBank(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Bank balance changed to %ld!", target->stats->getBank());
+ }
+ else if (stricmp(cmd, "PLAYER") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else if (stricmp(cmd2, "FIGHTS") != 0)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <NUMBER>");
+ return;
+ }
+ target->stats->setPlayerFights(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Player fights changed to %d!", target->stats->getPlayerFights());
+ }
+ }
+ else if (stricmp(cmd, "FOREST") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else if (stricmp(cmd2, "FIGHTS") != 0)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <number>");
+ return;
+ }
+ else
+ {
+ cmd2 = strtok(NULL, " ");
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <NUMBER>");
+ return;
+ }
+
+ target->stats->setForestFights(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Forest fights changed to %d!", target->stats->getForestFights());
+ }
+ }
+ else if (stricmp(cmd, "GOLD") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] GOLD <NUMBER>");
+ return;
+ }
+ target->stats->setGold(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Gold set to %ld", target->stats->getGold());
+ 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->setStrength(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Strength set to %d", target->stats->getStrength());
+ 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->setDefense(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Defense set to %d", target->stats->getDefense());
+ 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->setHP(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "HP set to %d", target->stats->getHP());
+ 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->setMaxHP(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "MaxHP set to %d", target->stats->getMaxHP());
+ 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->setExp(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Exp set to %ld", target->stats->getExp());
+ 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->setLevel(stringtoint(cmd2));
+
+ notice(s_GameServ, u, "Level set to %d", target->stats->getLevel());
+ return;
+ }
+ }
+ else if (stricmp(cmd, "ALIVE") == 0)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "Admins Only!");
+ return;
+ }
+ else
+ {
+ if (!cmd2)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] ALIVE TRUE|FALSE");
+ return;
+ }
+ else if (stricmp(cmd2, "TRUE") == 0)
+ {
+ notice(s_GameServ, u, "%s has been Resurrected!", target->stats->getName().c_str());
+ setAlive(target->stats);
+ }
+ else
+ {
+ notice(s_GameServ, u, "%s is now dead!", target->stats->getName().c_str());
+ clearAlive(target->stats);
+ }
+ }
+ }
+ 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)
+ {
+ notice(s_GameServ, u, "SYNTAX: /msg %S SET [NICK] SEEN MASTER {TRUE|FALSE}");
+ return;
+ }
+ else if (stricmp(cmd2, "TRUE") == 0)
+ {
+ notice(s_GameServ, u, "%s has seen their master now.", target->stats->getName().c_str());
+ target->stats->addFlag(FLAG_MASTER);
+ }
+ else
+ {
+ notice(s_GameServ, u, "%s has not seen their master now.", target->stats->getName().c_str());
+ target->stats->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|ALIVE|SEEN MASTER} {STRING|NUMBER|TRUE|FALSE}");
+ return;
+ }
+}