1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #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;
- }));
- }
- bool 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);
- return true;
- }
- return false;
- }
- int CrantCommand::getSecurityLevel(
- Framework::RCArray<Framework::Text> params) const
- {
- return (int)*params.z(1);
- }
|