123456789101112131415161718192021222324252627282930313233343536373839 |
- #include "GrantCommand.h"
- #include "Chat.h"
- #include "Game.h"
- #include "Player.h"
- CrantCommand::CrantCommand()
- : ChatCommand("grant", "Grants a player a permission", 0)
- {
- addParam(new PlayerNameParameter());
- addParam(new IntegerParameter("securityLavel",
- "The security level to grant",
- true,
- [](Entity* actor) {
- if (actor) return actor->getChatSecurityLevel();
- return INT32_MAX;
- }));
- }
- void CrantCommand::execute(
- Framework::RCArray<Framework::Text> params, Entity* zActor) const
- {
- int securityLevel = (int)*params.z(1);
- Entity* zTarget = Game::INSTANCE->zPlayerByName(*params.z(0));
- if (zTarget)
- {
- zTarget->setChatSecurityLevel(securityLevel);
- Framework::Text message = "The security level of player ";
- message.append() << *params.z(0) << " is now set to " << securityLevel;
- Game::INSTANCE->zChat()->sendMessageTo(
- message, zActor, Chat::CHANNEL_INFO);
- }
- }
- int CrantCommand::getSecurityLevel(
- Framework::RCArray<Framework::Text> params) const
- {
- return (int)*params.z(1);
- }
|