bool ChatHandler::Levelup(int levelcount) { if(levelcount<1 || levelcount > 79) return false; Player *chr = m_session->GetPlayer(); if(chr && chr->getLevel()+levelcount > 80) return false; HandleCharacterLevel(chr,0,chr->getLevel(),chr->getLevel()+levelcount); return true; }
static bool HandleLevelUpCommand(ChatHandler* handler, char const* args) { char* nameStr; char* levelStr; handler->extractOptFirstArg((char*)args, &nameStr, &levelStr); // exception opt second arg: .character level $name if (levelStr && isalpha(levelStr[0])) { nameStr = levelStr; levelStr = NULL; // current level will used } Player* target; uint64 targetGuid; std::string targetName; if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName)) return false; int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(targetGuid); int32 addlevel = levelStr ? atoi(levelStr) : 1; int32 newlevel = oldlevel + addlevel; if (newlevel < 1) newlevel = 1; if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level newlevel = STRONG_MAX_LEVEL; HandleCharacterLevel(target, targetGuid, oldlevel, newlevel, handler); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) // including chr == NULL { std::string nameLink = handler->playerLink(targetName); handler->PSendSysMessage(LANGUAGE_YOU_CHANGE_LVL, nameLink.c_str(), newlevel); } return true; }