]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_set.cpp
11 char *name
= strtok(NULL
, " ");
12 char *cmd
= strtok(NULL
, " ");
15 if (!(user
= find(u
)))
17 notice(s_GameServ
, u
, "Fatal error. Cannot find aClient. "\
21 else if (isIgnore(user
))
24 log("Ignoring %s.", user
->getNick());
28 else if (!name
|| !cmd
)
30 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}");
33 else if (!(p
= findplayer(name
)))
35 // Back the pointers up... they didn't send a name probably
40 if (!is_playing(user
))
42 notice(s_GameServ
, u
, "You must be playing to set things for yourself!");
48 cmd2
= strtok(NULL
, " ");
52 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}");
56 // Regardless of the previous if/else, if it got here, we know we have the cmd pointer at the right spot.
57 if (stricmp(cmd
, "PASSWORD") == 0)
59 // Person is looking to change their password
60 // If they're an admin, or it's theirself, allow it
61 // cmd2 is pointing to the password now
62 if (isAdmin(user
) || user
== p
->getClient())
65 notice(s_GameServ
, u
, "Password successfully changed");
67 else if (user
!= p
->getClient() && !isAdmin(user
))
69 notice(s_GameServ
, u
, "You must be a <S admin to set other peoples' passwords.");
73 else if (stricmp(cmd
, "BANK") == 0 || stricmp(cmd
, "BALANCE") == 0)
77 notice(s_GameServ
, u
, "Admins Only!");
80 else if (stricmp(cmd
, "BANK") == 0)
82 cmd2
= strtok(NULL
, " "); // Need an extra parameter for set bank balance
86 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] [BANK] BALANCE <NUMBER>");
90 p
->setBank(stringtoint(cmd2
));
92 notice(s_GameServ
, u
, "Bank balance changed to %ld!", p
->getBank());
94 else if (stricmp(cmd
, "PLAYER") == 0)
98 notice(s_GameServ
, u
, "Admins Only!");
101 else if (stricmp(cmd2
, "FIGHTS") != 0)
103 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] PLAYER FIGHTS <NUMBER>");
108 cmd2
= strtok(NULL
, " ");
111 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] PLAYER FIGHTS <NUMBER>");
114 p
->setPlayerFights(stringtoint(cmd2
));
116 notice(s_GameServ
, u
, "Player fights changed to %d!", p
->getPlayerFights());
119 else if (stricmp(cmd
, "FOREST") == 0)
123 notice(s_GameServ
, u
, "Admins Only!");
126 else if (stricmp(cmd2
, "FIGHTS") != 0)
128 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] FOREST FIGHTS <number>");
133 cmd2
= strtok(NULL
, " ");
136 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] FOREST FIGHTS <NUMBER>");
140 p
->setForestFights(stringtoint(cmd2
));
142 notice(s_GameServ
, u
, "Forest fights changed to %d!", p
->getForestFights());
145 else if (stricmp(cmd
, "GOLD") == 0)
149 notice(s_GameServ
, u
, "Admins Only!");
156 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] GOLD <NUMBER>");
159 p
->setGold(stringtoint(cmd2
));
161 notice(s_GameServ
, u
, "Gold set to %ld", p
->getGold());
165 else if (stricmp(cmd
, "STRENGTH") == 0 && stricmp(cmd2
, "POTIONS") != 0)
169 notice(s_GameServ
, u
, "Admins Only!");
176 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] STRENGTH <NUMBER>");
180 p
->setStrength(stringtoint(cmd2
));
182 notice(s_GameServ
, u
, "Strength set to %d", p
->getStrength());
186 else if (stricmp(cmd
, "DEFENSE") == 0 && stricmp(cmd2
, "POTIONS") != 0)
190 notice(s_GameServ
, u
, "Admins Only!");
197 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] DEFENSE <NUMBER>");
201 p
->setDefense(stringtoint(cmd2
));
203 notice(s_GameServ
, u
, "Defense set to %d", p
->getDefense());
207 else if (stricmp(cmd
, "HP") == 0 && stricmp(cmd2
, "POTIONS") != 0)
211 notice(s_GameServ
, u
, "Admins Only!");
218 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] HP <NUMBER>");
222 // Make sure it's easy for an admin to set the hp
223 if (p
->getMaxHP() < stringtoint(cmd2
))
224 p
->setMaxHP(stringtoint(cmd2
));
226 p
->setHP(stringtoint(cmd2
));
228 notice(s_GameServ
, u
, "HP set to %d", p
->getHP());
232 else if (stricmp(cmd
, "MAXHP") == 0)
236 notice(s_GameServ
, u
, "Admins Only!");
243 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] MAXHP <NUMBER>");
246 p
->setMaxHP(stringtoint(cmd2
));
248 notice(s_GameServ
, u
, "MaxHP set to %d", p
->getMaxHP());
252 else if (stricmp(cmd
, "EXPERIENCE") == 0 || stricmp(cmd
, "EXP") == 0)
256 notice(s_GameServ
, u
, "Admins Only!");
263 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] {EXPERIENCE|EXP} <NUMBER>");
267 p
->setExp(stringtoint(cmd2
));
269 notice(s_GameServ
, u
, "Exp set to %ld", p
->getExp());
273 else if (stricmp(cmd
, "LEVEL") == 0)
277 notice(s_GameServ
, u
, "Admins Only!");
284 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] LEVEL <NUMBER>");
287 p
->setLevel(stringtoint(cmd2
));
289 notice(s_GameServ
, u
, "Level set to %d", p
->getLevel());
293 else if (stricmp(cmd
, "ALIVE") == 0)
297 notice(s_GameServ
, u
, "Admins Only!");
304 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] ALIVE TRUE|FALSE");
307 else if (stricmp(cmd2
, "TRUE") == 0)
309 notice(s_GameServ
, u
, "%s has been Resurrected!", p
->getName().c_str());
314 notice(s_GameServ
, u
, "%s is now dead!", p
->getName().c_str());
319 else if (stricmp(cmd
, "SEEN") == 0)
323 notice(s_GameServ
, u
, "Admins Only!");
326 else if (stricmp(cmd2
, "MASTER") != 0)
328 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NAME] SEEN MASTER {TRUE|FALSE}");
333 cmd2
= strtok(NULL
, " ");
336 notice(s_GameServ
, u
, "SYNTAX: /msg <S SET [NICK] SEEN MASTER {TRUE|FALSE}");
339 else if (stricmp(cmd2
, "TRUE") == 0)
341 notice(s_GameServ
, u
, "%s has seen their master now.", p
->getName().c_str());
342 p
->addFlag(FLAG_MASTER
);
346 notice(s_GameServ
, u
, "%s has not seen their master now.", p
->getName().c_str());
347 p
->remFlag(FLAG_MASTER
);
353 notice(s_GameServ
, u
, "Unknown command: SET %s", cmd
);
354 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}");