#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 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 params) const { return (int)*params.z(1); }