GrantCommand.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "GrantCommand.h"
  2. #include "Game.h"
  3. CrantCommand::CrantCommand()
  4. : ChatCommand("grant", "Grants a player a permission", 0)
  5. {
  6. addParam(new PlayerNameParameter());
  7. addParam(new IntegerParameter("securityLavel",
  8. "The security level to grant",
  9. true,
  10. [](Entity* actor) {
  11. if (actor) return actor->getChatSecurityLevel();
  12. return INT32_MAX;
  13. }));
  14. }
  15. void CrantCommand::execute(
  16. Framework::RCArray<Framework::Text> params, Entity* zActor) const
  17. {
  18. int securityLevel = (int)*params.z(1);
  19. Entity* zTarget = Game::INSTANCE->zPlayerByName(*params.z(0));
  20. if (zTarget)
  21. {
  22. zTarget->setChatSecurityLevel(securityLevel);
  23. Text message = "The security level of player ";
  24. message += *params.z(0);
  25. message += " is now set to ";
  26. message += securityLevel;
  27. Game::INSTANCE->zChat()->sendMessageTo(
  28. message, zActor, Chat::CHANNEL_INFO);
  29. }
  30. }
  31. int CrantCommand::getSecurityLevel(
  32. Framework::RCArray<Framework::Text> params) const
  33. {
  34. return (int)*params.z(1);
  35. }