123456789101112131415161718192021222324252627282930313233343536373839 |
- #include "GrantCommand.h"
- #include "Game.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);
- Text message = "The security level of player ";
- message += *params.z(0);
- message += " is now set to ";
- message += securityLevel;
- Game::INSTANCE->zChat()->sendMessageTo(
- message, zActor, Chat::CHANNEL_INFO);
- }
- }
- int CrantCommand::getSecurityLevel(
- Framework::RCArray<Framework::Text> params) const
- {
- return (int)*params.z(1);
- }
|