Ir para conteúdo
  • Cadastre-se

(Resolvido)[Pedido] Account Manager


Ir para solução Resolvido por MaTTch,

Posts Recomendados

Boa noite, queria perguntar se alguem sabe como faço pra alterar isso na source, ficarei muito grato :)

Eu uso TFS 0.4

queria alterar desse

Hidden Content

    Give reaction to this post to see the hidden content.

pra esse

Hidden Content

    Give reaction to this post to see the hidden content.

 

Obrigado :)

 

Link para o post
Compartilhar em outros sites
  • Respostas 6
  • Created
  • Última resposta

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Posts

Não testado.

Posted Images

void Player::manageAccount(const std::string &text)
{
    std::stringstream msg;
    msg << "Account Manager: ";

    bool noSwap = true;
    switch(accountManager)
    {
        case MANAGER_NAMELOCK:
        {
            if(!talkState[1])
            {
                managerString = text;
                trimString(managerString);
                if(managerString.length() < 4)
                    msg << "Your name you want is too short, please select a longer name.";
                else if(managerString.length() > 20)
                    msg << "The name you want is too long, please select a shorter name.";
                else if(!isValidName(managerString))
                    msg << "That name seems to contain invalid symbols, please choose another name.";
                else if(IOLoginData::getInstance()->playerExists(managerString, true))
                    msg << "A player with that name already exists, please choose another name.";
                else
                {
                    std::string tmp = asLowerCaseString(managerString);
                    if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
                    {
                        talkState[1] = true;
                        talkState[2] = true;
                        msg << managerString << ", are you sure?";
                    }
                    else
                        msg << "Your character is not a staff member, please tell me another name!";
                }
            }
            else if(checkText(text, "no") && talkState[2])
            {
                talkState[1] = talkState[2] = false;
                msg << "What else would you like to name your character?";
            }
            else if(checkText(text, "yes") && talkState[2])
            {
                if(!IOLoginData::getInstance()->playerExists(managerString, true))
                {
                    uint32_t tmp;
                    if(IOLoginData::getInstance()->getGuidByName(tmp, managerString2) &&
                        IOLoginData::getInstance()->changeName(tmp, managerString, managerString2) &&
                        IOBan::getInstance()->removePlayerBanishment(tmp, PLAYERBAN_LOCK))
                    {
                        if(House* house = Houses::getInstance()->getHouseByPlayerId(tmp))
                            house->updateDoorDescription(managerString);

                        talkState[1] = true;
                        talkState[2] = false;
                        msg << "Your character has been successfully renamed, you should now be able to login at it without any problems.";
                    }
                    else
                    {
                        talkState[1] = talkState[2] = false;
                        msg << "Failed to change your name, please try again.";
                    }
                }
                else
                {
                    talkState[1] = talkState[2] = false;
                    msg << "A player with that name already exists, please choose another name.";
                }
            }
            else
                msg << "Sorry, but I can't understand you, please try to repeat that!";

            break;
        }
        case MANAGER_ACCOUNT:
        {
            Account account = IOLoginData::getInstance()->loadAccount(managerNumber);
            if(checkText(text, "cancel") || (checkText(text, "account") && !talkState[1]))
            {
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState[i] = false;

                msg << "Do you want to change your 'password', request a 'recovery key', add a 'character', or 'delete' a character?";
            }
            else if(checkText(text, "delete") && talkState[1])
            {
                talkState[1] = false;
                talkState[2] = true;
                msg << "Which character would you like to delete?";
            }
            else if(talkState[2])
            {
                std::string tmp = text;
                trimString(tmp);
                if(!isValidName(tmp, false))
                    msg << "That name contains invalid characters, try to say your name again, you might have typed it wrong.";
                else
                {
                    talkState[2] = false;
                    talkState[3] = true;
                    managerString = tmp;
                    msg << "Do you really want to delete the character named " << managerString << "?";
                }
            }
            else if(checkText(text, "yes") && talkState[3])
            {
                switch(IOLoginData::getInstance()->deleteCharacter(managerNumber, managerString))
                {
                    case DELETE_INTERNAL:
                        msg << "An error occured while deleting your character. Either the character does not belong to you or it doesn't exist.";
                        break;

                    case DELETE_SUCCESS:
                        msg << "Your character has been deleted.";
                        break;

                    case DELETE_HOUSE:
                        msg << "Your character owns a house. To make sure you really want to lose your house by deleting your character, you have to login and leave the house or pass it to someone else first.";
                        break;

                    case DELETE_LEADER:
                        msg << "Your character is the leader of a guild. You need to disband or pass the leadership someone else to delete your character.";
                        break;

                    case DELETE_ONLINE:
                        msg << "A character with that name is currently online, to delete a character it has to be offline.";
                        break;
                }

                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState[i] = false;
            }
            else if(checkText(text, "no") && talkState[3])
            {
                talkState[1] = true;
                talkState[3] = false;
                msg << "Tell me what character you want to delete.";
            }
            else if(checkText(text, "password") && talkState[1])
            {
                talkState[1] = false;
                talkState[4] = true;
                msg << "Tell me your new password please.";
            }
            else if(talkState[4])
            {
                std::string tmp = text;
                trimString(tmp);
                if(tmp.length() < 6)
                    msg << "That password is too short, at least 6 digits are required. Please select a longer password.";
                else if(!isValidPassword(tmp))
                    msg << "Your password contains invalid characters... please tell me another one.";
                else
                {
                    talkState[4] = false;
                    talkState[5] = true;
                    managerString = tmp;
                    msg << "Should '" << managerString << "' be your new password?";
                }
            }
            else if(checkText(text, "yes") && talkState[5])
            {
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState[i] = false;

                IOLoginData::getInstance()->setPassword(managerNumber, managerString);
                msg << "Your password has been changed.";
            }
            else if(checkText(text, "no") && talkState[5])
            {
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState[i] = false;

                msg << "Then not.";
            }
            else if(checkText(text, "character") && talkState[1])
            {
                if(account.charList.size() <= 15)
                {
                    talkState[1] = false;
                    talkState[6] = true;
                    msg << "What would you like as your character name?";
                }
                else
                {
                    talkState[1] = true;
                    for(int8_t i = 2; i <= 12; i++)
                        talkState[i] = false;

                    msg << "Your account reach the limit of 15 players, you can 'delete' a character if you want to create a new one.";
                }
            }
            else if(talkState[6])
            {
                managerString = text;
                trimString(managerString);
                if(managerString.length() < 4)
                    msg << "Your name you want is too short, please select a longer name.";
                else if(managerString.length() > 20)
                    msg << "The name you want is too long, please select a shorter name.";
                else if(!isValidName(managerString))
                    msg << "That name seems to contain invalid symbols, please choose another name.";
                else if(IOLoginData::getInstance()->playerExists(managerString, true))
                    msg << "A player with that name already exists, please choose another name.";
                else
                {
                    std::string tmp = asLowerCaseString(managerString);
                    if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
                    {
                        talkState[6] = false;
                        talkState[7] = true;
                        msg << managerString << ", are you sure?";
                    }
                    else
                        msg << "Your character is not a staff member, please tell me another name!";
                }
            }
            else if(checkText(text, "no") && talkState[7])
            {
                talkState[6] = true;
                talkState[7] = false;
                msg << "What else would you like to name your character?";
            }
            else if(checkText(text, "yes") && talkState[7])
            {
                talkState[7] = false;
                talkState[8] = true;
                msg << "Should your character be a 'male' or a 'female'.";
            }
            else if(talkState[8] && (checkText(text, "female") || checkText(text, "male")))
            {
                talkState[8] = false;
                talkState[9] = true;
                if(checkText(text, "female"))
                {
                    msg << "A female, are you sure?";
                    managerSex = PLAYERSEX_FEMALE;
                }
                else
                {
                    msg << "A male, are you sure?";
                    managerSex = PLAYERSEX_MALE;
                }
            }
            else if(checkText(text, "no") && talkState[9])
            {
                talkState[8] = true;
                talkState[9] = false;
                msg << "Tell me... would you like to be a 'male' or a 'female'?";
            }
            else if(checkText(text, "yes") && talkState[9])
            {
                if(g_config.getBool(ConfigManager::START_CHOOSEVOC))
                {
                    talkState[9] = false;
                    talkState[11] = true;

                    bool firstPart = true;
                    for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
                    {
                        if(it->first == it->second->getFromVocation() && it->first != 0)
                        {
                            if(firstPart)
                            {
                                msg << "What do you want to be... " << it->second->getDescription();
                                firstPart = false;
                            }
                            else if(it->first - 1 != 0)
                                msg << ", " << it->second->getDescription();
                            else
                                msg << " or " << it->second->getDescription() << ".";
                        }
                    }
                }
                else if(!IOLoginData::getInstance()->playerExists(managerString, true))
                {
                    talkState[1] = true;
                    for(int8_t i = 2; i <= 12; i++)
                        talkState[i] = false;

                    if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
                        msg << "Your character has been created.";
                    else
                        msg << "Your character couldn't be created, please try again.";
                }
                else
                {
                    talkState[6] = true;
                    talkState[9] = false;
                    msg << "A player with that name already exists, please choose another name.";
                }
            }
            else if(talkState[11])
            {
                for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
                {
                    std::string tmp = asLowerCaseString(it->second->getName());
                    if(checkText(text, tmp) && it != Vocations::getInstance()->getLastVocation() && it->first == it->second->getFromVocation() && it->first != 0)
                    {
                        msg << "So you would like to be " << it->second->getDescription() << "... are you sure?";
                        managerNumber2 = it->first;
                        talkState[11] = false;
                        talkState[12] = true;
                    }
                }

                if(msg.str().length() == 17)
                    msg << "I don't understand what vocation you would like to be... could you please repeat it?";
            }
            else if(checkText(text, "yes") && talkState[12])
            {
                if(!IOLoginData::getInstance()->playerExists(managerString, true))
                {
                    talkState[1] = true;
                    for(int8_t i = 2; i <= 12; i++)
                        talkState[i] = false;

                    if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
                        msg << "Your character has been created.";
                    else
                        msg << "Your character couldn't be created, please try again.";
                }
                else
                {
                    talkState[6] = true;
                    talkState[9] = false;
                    msg << "A player with that name already exists, please choose another name.";
                }
            }
            else if(checkText(text, "no") && talkState[12])
            {
                talkState[11] = true;
                talkState[12] = false;
                msg << "No? Then what would you like to be?";
            }
            else if(checkText(text, "recovery key") && talkState[1])
            {
                talkState[1] = false;
                talkState[10] = true;
                msg << "Would you like a recovery key?";
            }
            else if(checkText(text, "yes") && talkState[10])
            {
                if(account.recoveryKey != "0")
                    msg << "Sorry, you already have a recovery key, for security reasons I may not give you a new one.";
                else
                {
                    managerString = generateRecoveryKey(4, 4);
                    IOLoginData::getInstance()->setRecoveryKey(managerNumber, managerString);
                    msg << "Your recovery key is: " << managerString << ".";
                }

                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState[i] = false;
            }
            else if(checkText(text, "no") && talkState[10])
            {
                msg << "Then not.";
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState[i] = false;
            }
            else
                msg << "Please read the latest message that I have specified, I don't understand the current requested action.";

            break;
        }
        case MANAGER_NEW:
        {
            if(checkText(text, "account") && !talkState[1])
            {
                msg << "What would you like your password to be?";
                talkState[1] = true;
                talkState[2] = true;
            }
            else if(talkState[2])
            {
                std::string tmp = text;
                trimString(tmp);
                if(tmp.length() < 6)
                    msg << "That password is too short, at least 6 digits are required. Please select a longer password.";
                else if(!isValidPassword(tmp))
                    msg << "Your password contains invalid characters... please tell me another one.";
                else
                {
                    talkState[3] = true;
                    talkState[2] = false;
                    managerString = tmp;
                    msg << managerString << " is it? 'yes' or 'no'?";
                }
            }
            else if(checkText(text, "yes") && talkState[3])
            {
                if(g_config.getBool(ConfigManager::GENERATE_ACCOUNT_NUMBER))
                {
                    do
                        sprintf(managerChar, "%d%d%d%d%d%d%d", random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9));
                    while(IOLoginData::getInstance()->accountNameExists(managerChar));

                    uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
                    if(id)
                    {
                        accountManager = MANAGER_ACCOUNT;
                        managerNumber = id;

                        noSwap = talkState[1] = false;
                        msg << "Your account has been created, you may manage it now, but remember your account name: '"
                            << managerChar << "' and password: '" << managerString
                            << "'! If the account name is too hard to remember, please note it somewhere.";
                    }
                    else
                        msg << "Your account could not be created, please try again.";

                    for(int8_t i = 2; i <= 5; i++)
                        talkState[i] = false;
                }
                else
                {
                    msg << "What would you like your account name to be?";
                    talkState[3] = false;
                    talkState[4] = true;
                }
            }
            else if(checkText(text, "no") && talkState[3])
            {
                talkState[2] = true;
                talkState[3] = false;
                msg << "What would you like your password to be then?";
            }
            else if(talkState[4])
            {
                std::string tmp = text;
                trimString(tmp);
                if(tmp.length() < 3)
                    msg << "That account name is too short, at least 3 digits are required. Please select a longer account name.";
                else if(tmp.length() > 25)
                    msg << "That account name is too long, not more than 25 digits are required. Please select a shorter account name.";
                else if(!isValidAccountName(tmp))
                    msg << "Your account name contains invalid characters, please choose another one.";
                else if(asLowerCaseString(tmp) == asLowerCaseString(managerString))
                    msg << "Your account name cannot be same as password, please choose another one.";
                else
                {
                    sprintf(managerChar, "%s", tmp.c_str());
                    msg << managerChar << ", are you sure?";
                    talkState[4] = false;
                    talkState[5] = true;
                }
            }
            else if(checkText(text, "yes") && talkState[5])
            {
                if(!IOLoginData::getInstance()->accountNameExists(managerChar))
                {
                    uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
                    if(id)
                    {
                        accountManager = MANAGER_ACCOUNT;
                        managerNumber = id;

                        noSwap = talkState[1] = false;
                        msg << "Your account has been created, you may manage it now, but remember your account name: '"
                            << managerChar << "' and password: '" << managerString << "'!";
                    }
                    else
                        msg << "Your account could not be created, please try again.";

                    for(int8_t i = 2; i <= 5; i++)
                        talkState[i] = false;
                }
                else
                {
                    msg << "An account with that name already exists, please try another account name.";
                    talkState[4] = true;
                    talkState[5] = false;
                }
            }
            else if(checkText(text, "no") && talkState[5])
            {
                talkState[5] = false;
                talkState[4] = true;
                msg << "What else would you like as your account name?";
            }
            else if(checkText(text, "recover") && !talkState[6])
            {
                talkState[6] = true;
                talkState[7] = true;
                msg << "What was your account name?";
            }
            else if(talkState[7])
            {
                managerString = text;
                if(IOLoginData::getInstance()->getAccountId(managerString, (uint32_t&)managerNumber))
                {
                    talkState[7] = false;
                    talkState[8] = true;
                    msg << "What was your recovery key?";
                }
                else
                {
                    msg << "Sorry, but account with such name doesn't exists.";
                    talkState[6] = talkState[7] = false;
                }
            }
            else if(talkState[8])
            {
                managerString2 = text;
                if(IOLoginData::getInstance()->validRecoveryKey(managerNumber, managerString2) && managerString2 != "0")
                {
                    sprintf(managerChar, "%s%d", g_config.getString(ConfigManager::SERVER_NAME).c_str(), random_range(100, 999));
                    IOLoginData::getInstance()->setPassword(managerNumber, managerChar);
                    msg << "Correct! Your new password is: " << managerChar << ".";
                }
                else
                    msg << "Sorry, but this key doesn't match to account you gave me.";

                talkState[7] = talkState[8] = false;
            }
            else
                msg << "Sorry, but I can't understand you, please try to repeat that.";

            break;
        }
        default:
            return;
            break;
    }

    sendTextMessage(MSG_STATUS_CONSOLE_BLUE, msg.str().c_str());
    if(!noSwap)
        sendTextMessage(MSG_STATUS_CONSOLE_ORANGE, "Hint: Type 'account' to manage your account and if you want to start over then type 'cancel'.");
}



@up

Link para o post
Compartilhar em outros sites
  • Solução
 

void Player::manageAccount(const std::string &text)
{
    std::stringstream msg;
    msg << "Account Manager: ";

    bool noSwap = true;
    switch(accountManager)
    {
        case MANAGER_NAMELOCK:
        {
            if(!talkState[1])
            {
                managerString = text;
                trimString(managerString);
                if(managerString.length() < 4)
                    msg << "Your name you want is too short, please select a longer name.";
                else if(managerString.length() > 20)
                    msg << "The name you want is too long, please select a shorter name.";
                else if(!isValidName(managerString))
                    msg << "That name seems to contain invalid symbols, please choose another name.";
                else if(IOLoginData::getInstance()->playerExists(managerString, true))
                    msg << "A player with that name already exists, please choose another name.";
                else
                {
                    std::string tmp = asLowerCaseString(managerString);
                    if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
                    {
                        talkState[1] = true;
                        talkState[2] = true;
                        msg << managerString << ", are you sure?";
                    }
                    else
                        msg << "Your character is not a staff member, please tell me another name!";
                }
            }
            else if(checkText(text, "no") && talkState[2])
            {
                talkState[1] = talkState[2] = false;
                msg << "What else would you like to name your character?";
            }
            else if(checkText(text, "yes") && talkState[2])
            {
                if(!IOLoginData::getInstance()->playerExists(managerString, true))
                {
                    uint32_t tmp;
                    if(IOLoginData::getInstance()->getGuidByName(tmp, managerString2) &&
                        IOLoginData::getInstance()->changeName(tmp, managerString, managerString2) &&
                        IOBan::getInstance()->removePlayerBanishment(tmp, PLAYERBAN_LOCK))
                    {
                        if(House* house = Houses::getInstance()->getHouseByPlayerId(tmp))
                            house->updateDoorDescription(managerString);

                        talkState[1] = true;
                        talkState[2] = false;
                        msg << "Your character has been successfully renamed, you should now be able to login at it without any problems.";
                    }
                    else
                    {
                        talkState[1] = talkState[2] = false;
                        msg << "Failed to change your name, please try again.";
                    }
                }
                else
                {
                    talkState[1] = talkState[2] = false;
                    msg << "A player with that name already exists, please choose another name.";
                }
            }
            else
                msg << "Sorry, but I can't understand you, please try to repeat that!";

            break;
        }
        case MANAGER_ACCOUNT:
        {
            Account account = IOLoginData::getInstance()->loadAccount(managerNumber);
            if(checkText(text, "cancel") || (checkText(text, "account") && !talkState[1]))
            {
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState = false;

                msg << "Do you want to change your 'password', request a 'recovery key', add a 'character', or 'delete' a character?";
            }
            else if(checkText(text, "delete") && talkState[1])
            {
                talkState[1] = false;
                talkState[2] = true;
                msg << "Which character would you like to delete?";
            }
            else if(talkState[2])
            {
                std::string tmp = text;
                trimString(tmp);
                if(!isValidName(tmp, false))
                    msg << "That name contains invalid characters, try to say your name again, you might have typed it wrong.";
                else
                {
                    talkState[2] = false;
                    talkState[3] = true;
                    managerString = tmp;
                    msg << "Do you really want to delete the character named " << managerString << "?";
                }
            }
            else if(checkText(text, "yes") && talkState[3])
            {
                switch(IOLoginData::getInstance()->deleteCharacter(managerNumber, managerString))
                {
                    case DELETE_INTERNAL:
                        msg << "An error occured while deleting your character. Either the character does not belong to you or it doesn't exist.";
                        break;

                    case DELETE_SUCCESS:
                        msg << "Your character has been deleted.";
                        break;

                    case DELETE_HOUSE:
                        msg << "Your character owns a house. To make sure you really want to lose your house by deleting your character, you have to login and leave the house or pass it to someone else first.";
                        break;

                    case DELETE_LEADER:
                        msg << "Your character is the leader of a guild. You need to disband or pass the leadership someone else to delete your character.";
                        break;

                    case DELETE_ONLINE:
                        msg << "A character with that name is currently online, to delete a character it has to be offline.";
                        break;
                }

                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState = false;
            }
            else if(checkText(text, "no") && talkState[3])
            {
                talkState[1] = true;
                talkState[3] = false;
                msg << "Tell me what character you want to delete.";
            }
            else if(checkText(text, "password") && talkState[1])
            {
                talkState[1] = false;
                talkState[4] = true;
                msg << "Tell me your new password please.";
            }
            else if(talkState[4])
            {
                std::string tmp = text;
                trimString(tmp);
                if(tmp.length() < 6)
                    msg << "That password is too short, at least 6 digits are required. Please select a longer password.";
                else if(!isValidPassword(tmp))
                    msg << "Your password contains invalid characters... please tell me another one.";
                else
                {
                    talkState[4] = false;
                    talkState[5] = true;
                    managerString = tmp;
                    msg << "Should '" << managerString << "' be your new password?";
                }
            }
            else if(checkText(text, "yes") && talkState[5])
            {
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState = false;

                IOLoginData::getInstance()->setPassword(managerNumber, managerString);
                msg << "Your password has been changed.";
            }
            else if(checkText(text, "no") && talkState[5])
            {
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState = false;

                msg << "Then not.";
            }
            else if(checkText(text, "character") && talkState[1])
            {
                if(account.charList.size() <= 15)
                {
                    talkState[1] = false;
                    talkState[6] = true;
                    msg << "What would you like as your character name?";
                }
                else
                {
                    talkState[1] = true;
                    for(int8_t i = 2; i <= 12; i++)
                        talkState = false;

                    msg << "Your account reach the limit of 15 players, you can 'delete' a character if you want to create a new one.";
                }
            }
            else if(talkState[6])
            {
                managerString = text;
                trimString(managerString);
                if(managerString.length() < 4)
                    msg << "Your name you want is too short, please select a longer name.";
                else if(managerString.length() > 20)
                    msg << "The name you want is too long, please select a shorter name.";
                else if(!isValidName(managerString))
                    msg << "That name seems to contain invalid symbols, please choose another name.";
                else if(IOLoginData::getInstance()->playerExists(managerString, true))
                    msg << "A player with that name already exists, please choose another name.";
                else
                {
                    std::string tmp = asLowerCaseString(managerString);
                    if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
                    {
                        talkState[6] = false;
                        talkState[7] = true;
                        msg << managerString << ", are you sure?";
                    }
                    else
                        msg << "Your character is not a staff member, please tell me another name!";
                }
            }
            else if(checkText(text, "no") && talkState[7])
            {
                talkState[6] = true;
                talkState[7] = false;
                msg << "What else would you like to name your character?";
            }
            else if(checkText(text, "yes") && talkState[7])
            {
                talkState[7] = false;
                talkState[8] = true;
                msg << "Should your character be a 'male' or a 'female'.";
            }
            else if(talkState[8] && (checkText(text, "female") || checkText(text, "male")))
            {
                talkState[8] = false;
                talkState[9] = true;
                if(checkText(text, "female"))
                {
                    msg << "A female, are you sure?";
                    managerSex = PLAYERSEX_FEMALE;
                }
                else
                {
                    msg << "A male, are you sure?";
                    managerSex = PLAYERSEX_MALE;
                }
            }
            else if(checkText(text, "no") && talkState[9])
            {
                talkState[8] = true;
                talkState[9] = false;
                msg << "Tell me... would you like to be a 'male' or a 'female'?";
            }
            else if(checkText(text, "yes") && talkState[9])
            {
                if(g_config.getBool(ConfigManager::START_CHOOSEVOC))
                {
                    talkState[9] = false;
                    talkState[11] = true;

                    bool firstPart = true;
                    for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
                    {
                        if(it->first == it->second->getFromVocation() && it->first != 0)
                        {
                            if(firstPart)
                            {
                                msg << "What do you want to be... " << it->second->getDescription();
                                firstPart = false;
                            }
                            else if(it->first - 1 != 0)
                                msg << ", " << it->second->getDescription();
                            else
                                msg << " or " << it->second->getDescription() << ".";
                        }
                    }
                }
                else if(!IOLoginData::getInstance()->playerExists(managerString, true))
                {
                    talkState[1] = true;
                    for(int8_t i = 2; i <= 12; i++)
                        talkState = false;

                    if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
                        msg << "Your character has been created.";
                    else
                        msg << "Your character couldn't be created, please try again.";
                }
                else
                {
                    talkState[6] = true;
                    talkState[9] = false;
                    msg << "A player with that name already exists, please choose another name.";
                }
            }
            else if(talkState[11])
            {
                for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
                {
                    std::string tmp = asLowerCaseString(it->second->getName());
                    if(checkText(text, tmp) && it != Vocations::getInstance()->getLastVocation() && it->first == it->second->getFromVocation() && it->first != 0)
                    {
                        msg << "So you would like to be " << it->second->getDescription() << "... are you sure?";
                        managerNumber2 = it->first;
                        talkState[11] = false;
                        talkState[12] = true;
                    }
                }

                if(msg.str().length() == 17)
                    msg << "I don't understand what vocation you would like to be... could you please repeat it?";
            }
            else if(checkText(text, "yes") && talkState[12])
            {
                if(!IOLoginData::getInstance()->playerExists(managerString, true))
                {
                    talkState[1] = true;
                    for(int8_t i = 2; i <= 12; i++)
                        talkState = false;

                    if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
                        msg << "Your character has been created.";
                    else
                        msg << "Your character couldn't be created, please try again.";
                }
                else
                {
                    talkState[6] = true;
                    talkState[9] = false;
                    msg << "A player with that name already exists, please choose another name.";
                }
            }
            else if(checkText(text, "no") && talkState[12])
            {
                talkState[11] = true;
                talkState[12] = false;
                msg << "No? Then what would you like to be?";
            }
            else if(checkText(text, "recovery key") && talkState[1])
            {
                talkState[1] = false;
                talkState[10] = true;
                msg << "Would you like a recovery key?";
            }
            else if(checkText(text, "yes") && talkState[10])
            {
                if(account.recoveryKey != "0")
                    msg << "Sorry, you already have a recovery key, for security reasons I may not give you a new one.";
                else
                {
                    managerString = generateRecoveryKey(4, 4);
                    IOLoginData::getInstance()->setRecoveryKey(managerNumber, managerString);
                    msg << "Your recovery key is: " << managerString << ".";
                }

                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState = false;
            }
            else if(checkText(text, "no") && talkState[10])
            {
                msg << "Then not.";
                talkState[1] = true;
                for(int8_t i = 2; i <= 12; i++)
                    talkState = false;
            }
            else
                msg << "Please read the latest message that I have specified, I don't understand the current requested action.";

            break;
        }
        case MANAGER_NEW:
        {
            if(checkText(text, "account") && !talkState[1])
            {
                msg << "What would you like your password to be?";
                talkState[1] = true;
                talkState[2] = true;
            }
            else if(talkState[2])
            {
                std::string tmp = text;
                trimString(tmp);
                if(tmp.length() < 6)
                    msg << "That password is too short, at least 6 digits are required. Please select a longer password.";
                else if(!isValidPassword(tmp))
                    msg << "Your password contains invalid characters... please tell me another one.";
                else
                {
                    talkState[3] = true;
                    talkState[2] = false;
                    managerString = tmp;
                    msg << managerString << " is it? 'yes' or 'no'?";
                }
            }
            else if(checkText(text, "yes") && talkState[3])
            {
                if(g_config.getBool(ConfigManager::GENERATE_ACCOUNT_NUMBER))
                {
                    do
                        sprintf(managerChar, "%d%d%d%d%d%d%d", random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9));
                    while(IOLoginData::getInstance()->accountNameExists(managerChar));

                    uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
                    if(id)
                    {
                        accountManager = MANAGER_ACCOUNT;
                        managerNumber = id;

                        noSwap = talkState[1] = false;
                        msg << "Your account has been created, you may manage it now, but remember your account name: '"
                            << managerChar << "' and password: '" << managerString
                            << "'! If the account name is too hard to remember, please note it somewhere.";
                    }
                    else
                        msg << "Your account could not be created, please try again.";

                    for(int8_t i = 2; i <= 5; i++)
                        talkState = false;
                }
                else
                {
                    msg << "What would you like your account name to be?";
                    talkState[3] = false;
                    talkState[4] = true;
                }
            }
            else if(checkText(text, "no") && talkState[3])
            {
                talkState[2] = true;
                talkState[3] = false;
                msg << "What would you like your password to be then?";
            }
            else if(talkState[4])
            {
                std::string tmp = text;
                trimString(tmp);
                if(tmp.length() < 3)
                    msg << "That account name is too short, at least 3 digits are required. Please select a longer account name.";
                else if(tmp.length() > 25)
                    msg << "That account name is too long, not more than 25 digits are required. Please select a shorter account name.";
                else if(!isValidAccountName(tmp))
                    msg << "Your account name contains invalid characters, please choose another one.";
                else if(asLowerCaseString(tmp) == asLowerCaseString(managerString))
                    msg << "Your account name cannot be same as password, please choose another one.";
                else
                {
                    sprintf(managerChar, "%s", tmp.c_str());
                    msg << managerChar << ", are you sure?";
                    talkState[4] = false;
                    talkState[5] = true;
                }
            }
            else if(checkText(text, "yes") && talkState[5])
            {
                if(!IOLoginData::getInstance()->accountNameExists(managerChar))
                {
                    uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
                    if(id)
                    {
                        accountManager = MANAGER_ACCOUNT;
                        managerNumber = id;

                        noSwap = talkState[1] = false;
                        msg << "Your account has been created, you may manage it now, but remember your account name: '"
                            << managerChar << "' and password: '" << managerString << "'!";
                    }
                    else
                        msg << "Your account could not be created, please try again.";

                    for(int8_t i = 2; i <= 5; i++)
                        talkState = false;
                }
                else
                {
                    msg << "An account with that name already exists, please try another account name.";
                    talkState[4] = true;
                    talkState[5] = false;
                }
            }
            else if(checkText(text, "no") && talkState[5])
            {
                talkState[5] = false;
                talkState[4] = true;
                msg << "What else would you like as your account name?";
            }
            else if(checkText(text, "recover") && !talkState[6])
            {
                talkState[6] = true;
                talkState[7] = true;
                msg << "What was your account name?";
            }
            else if(talkState[7])
            {
                managerString = text;
                if(IOLoginData::getInstance()->getAccountId(managerString, (uint32_t&)managerNumber))
                {
                    talkState[7] = false;
                    talkState[8] = true;
                    msg << "What was your recovery key?";
                }
                else
                {
                    msg << "Sorry, but account with such name doesn't exists.";
                    talkState[6] = talkState[7] = false;
                }
            }
            else if(talkState[8])
            {
                managerString2 = text;
                if(IOLoginData::getInstance()->validRecoveryKey(managerNumber, managerString2) && managerString2 != "0")
                {
                    sprintf(managerChar, "%s%d", g_config.getString(ConfigManager::SERVER_NAME).c_str(), random_range(100, 999));
                    IOLoginData::getInstance()->setPassword(managerNumber, managerChar);
                    msg << "Correct! Your new password is: " << managerChar << ".";
                }
                else
                    msg << "Sorry, but this key doesn't match to account you gave me.";

                talkState[7] = talkState[8] = false;
            }
            else
                msg << "Sorry, but I can't understand you, please try to repeat that.";

            break;
        }
        default:
            return;
            break;
    }

    sendTextMessage(MSG_STATUS_CONSOLE_BLUE, msg.str().c_str());
    if(!noSwap)
        sendTextMessage(MSG_STATUS_CONSOLE_ORANGE, "Hint: Type 'account' to manage your account and if you want to start over then type 'cancel'.");
}



@up

 

 

void Player::manageAccount(const std::string &text)
{
	std::stringstream msg;
	bool noSwap = true;
	switch(accountManager)
	{
		case MANAGER_NAMELOCK:
		{
			if(!talkState[1])
			{
				managerString = text;
				trimString(managerString);
				if(managerString.length() < 3)
					msg << "The name is too short, please select a longer one.";
				else if(managerString.length() > 30)
					msg << "The name is too long, please select a shorter one.";
				else if(!isValidName(managerString))
					msg << "Your name seems to contain invalid symbols, please choose another one.";
				else if(IOLoginData::getInstance()->playerExists(managerString, true))
					msg << "Player with that name already exists, please choose another one.";
				else
				{
					std::string tmp = asLowerCaseString(managerString);
					if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
					{
						talkState[1] = talkState[2] = true;
						msg << "{" << managerString << "}, are you sure? {yes} or {no}?";
					}
					else
						msg << "Your character is not a staff member, please choose another name.";
				}
			}
			else if(checkText(text, "no") && talkState[2])
			{
				talkState[1] = talkState[2] = false;
				msg << "What new name would you like have then?";
			}
			else if(checkText(text, "yes") && talkState[2])
			{
				if(!IOLoginData::getInstance()->playerExists(managerString, true))
				{
					uint32_t tmp;
					if(IOLoginData::getInstance()->getGuidByName(tmp, managerString2) &&
						IOLoginData::getInstance()->changeName(tmp, managerString, managerString2) &&
						IOBan::getInstance()->removePlayerBanishment(tmp, PLAYERBAN_LOCK))
					{
						msg << "Your character {" << managerString << "} has been successfully renamed to {" << managerString2 << "}, you should be able to login now.";
						if(House* house = Houses::getInstance()->getHouseByPlayerId(tmp))
							house->updateDoorDescription(managerString);

						talkState[1] = true;
						talkState[2] = false;
					}
					else
					{
						talkState[1] = talkState[2] = false;
						msg << "Failed to change your name, please contact with staff.";
					}
				}
				else
				{
					talkState[1] = talkState[2] = false;
					msg << "Player with that name already exists, please choose another one.";
				}
			}
			else
				msg << "Sorry, but I can't understand you, please try to repeat.";

			break;
		}
		case MANAGER_ACCOUNT:
		{
			Account account = IOLoginData::getInstance()->loadAccount(managerNumber);
			if(checkText(text, "cancel") || (checkText(text, "account") && !talkState[1]))
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;

				msg << "Do you want to change your {password}, generate a {recovery key}, create a {character}, or {delete} an existing character?";
			}
			else if(checkText(text, "delete") && talkState[1])
			{
				talkState[1] = false;
				talkState[2] = true;
				msg << "Which character would you like to delete?";
			}
			else if(talkState[2])
			{
				std::string tmp = text;
				trimString(tmp);
				if(!isValidName(tmp, false))
					msg << "That name to contain invalid symbols, please try again.";
				else
				{
					talkState[2] = false;
					talkState[3] = true;
					managerString = tmp;
					msg << "Do you really want to delete the character {" << managerString << "}? {yes} or {no}?";
				}
			}
			else if(checkText(text, "yes") && talkState[3])
			{
				switch(IOLoginData::getInstance()->deleteCharacter(managerNumber, managerString))
				{
					case DELETE_INTERNAL:
						msg << "An error occured while deleting your character. Either the character does not belong to you or it doesn't exist.";
						break;

					case DELETE_SUCCESS:
						msg << "Your character has been deleted.";
						break;

					case DELETE_HOUSE:
						msg << "Your character owns a house. You have to login and leave the house or pass it to someone else to complete.";
						break;

					case DELETE_LEADER:
						msg << "Your character is leader of a guild. You have to disband the guild or pass the leadership to someone else to complete.";
						break;

					case DELETE_ONLINE:
						msg << "Character with that name is currently online, to delete a character it has to be offline.";
						break;
				}

				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;
			}
			else if(checkText(text, "no") && talkState[3])
			{
				talkState[1] = true;
				talkState[3] = false;
				msg << "Which character would you like to delete then?";
			}
			else if(checkText(text, "password") && talkState[1])
			{
				talkState[1] = false;
				talkState[4] = true;
				msg << "What would you like your password to be?";
			}
			else if(talkState[4])
			{
				std::string tmp = text;
				trimString(tmp);
				if(tmp.length() < 6)
					msg << "That password is too short, please select a longer one.";
				else if(!isValidPassword(tmp))
					msg << "Your password seems to contain invalid symbols, please choose another one.";
				else
				{
					talkState[4] = false;
					talkState[5] = true;
					managerString = tmp;
					msg << "{" << managerString << "} is it? {yes} or {no}?";
				}
			}
			else if(checkText(text, "yes") && talkState[5])
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;

				IOLoginData::getInstance()->setPassword(managerNumber, managerString);
				msg << "Your password has been changed.";
			}
			else if(checkText(text, "no") && talkState[5])
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;

				msg << "Ok, then not.";
			}
			else if(checkText(text, "character") && talkState[1])
			{
				if(account.charList.size() <= 15)
				{
					talkState[1] = false;
					talkState[6] = true;
					msg << "What would you like as your character name?";
				}
				else
				{
					talkState[1] = true;
					for(int8_t i = 2; i <= 12; ++i)
						talkState[i] = false;

					msg << "Your account has reached the limit of 15 characters, you should {delete} a character if you want to create a new one.";
				}
			}
			else if(talkState[6])
			{
				managerString = text;
				trimString(managerString);
				if(managerString.length() < 3)
					msg << "That name is too short, please select a longer one.";
				else if(managerString.length() > 30)
					msg << "That name is too long, please select a shorter one.";
				else if(!isValidName(managerString))
					msg << "Your name seems to contain invalid symbols, please choose another one.";
				else if(IOLoginData::getInstance()->playerExists(managerString, true))
					msg << "Player with that name already exists, please choose another one.";
				else
				{
					std::string tmp = asLowerCaseString(managerString);
					if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
					{
						talkState[6] = false;
						talkState[7] = true;
						msg << "{" << managerString << "}, are you sure? {yes} or {no}?";
					}
					else
						msg << "Your character is not a staff member, please choose another name.";
				}
			}
			else if(checkText(text, "no") && talkState[7])
			{
				talkState[6] = true;
				talkState[7] = false;
				msg << "What would you like your character name to be then?";
			}
			else if(checkText(text, "yes") && talkState[7])
			{
				talkState[7] = false;
				talkState[8] = true;
				msg << "Would you like to be a {male} or a {female}?";
			}
			else if(talkState[8] && (checkText(text, "female") || checkText(text, "male")))
			{
				talkState[8] = false;
				talkState[9] = true;
				if(checkText(text, "female"))
				{
					msg << "A female, are you sure? {yes} or {no}?";
					managerSex = PLAYERSEX_FEMALE;
				}
				else
				{
					msg << "A male, are you sure? {yes} or {no}?";
					managerSex = PLAYERSEX_MALE;
				}
			}
			else if(checkText(text, "no") && talkState[9])
			{
				talkState[8] = true;
				talkState[9] = false;
				msg << "Tell me then, would you like to be a {male} or a {female}?";
			}
			else if(checkText(text, "yes") && talkState[9])
			{
				if(g_config.getBool(ConfigManager::START_CHOOSEVOC))
				{
					talkState[9] = false;
					talkState[11] = true;

					std::vector<std::string> vocations;
					for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
					{
						if(it->first == it->second->getFromVocation() && it->first != 0)
							vocations.push_back(it->second->getName());
					}

					msg << "What would you like to be... ";
					for(std::vector<std::string>::const_iterator it = vocations.begin(); it != vocations.end(); ++it)
					{
						if(it == vocations.begin())
							msg << "{" << *it << "}";
						else if(*it == *(vocations.rbegin()))
							msg << " or {" << *it << "}.";
						else
							msg << ", {" << *it << "}";
					}
				}
				else if(!IOLoginData::getInstance()->playerExists(managerString, true))
				{
					talkState[1] = true;
					for(int8_t i = 2; i <= 12; ++i)
						talkState[i] = false;

					if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
						msg << "Your character {" << managerString << "} has been created.";
					else
						msg << "Your character couldn't be created, please contact with staff.";
				}
				else
				{
					talkState[6] = true;
					talkState[9] = false;
					msg << "Player with that name already exists, please choose another one.";
				}
			}
			else if(talkState[11])
			{
				for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
				{
					if(checkText(text, asLowerCaseString(it->second->getName())) &&
						it->first == it->second->getFromVocation() && it->first != 0)
					{
						msg << "So you would like to be " << it->second->getDescription() << ", {yes} or {no}?";
						managerNumber2 = it->first;
						talkState[11] = false;
						talkState[12] = true;
					}
				}
			}
			else if(checkText(text, "yes") && talkState[12])
			{
				if(!IOLoginData::getInstance()->playerExists(managerString, true))
				{
					talkState[1] = true;
					for(int8_t i = 2; i <= 12; ++i)
						talkState[i] = false;

					if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
						msg << "Your character {" << managerString << "} has been created.";
					else
						msg << "Your character couldn't be created, please contact with staff.";
				}
				else
				{
					talkState[6] = true;
					talkState[9] = false;
					msg << "Player with that name already exists, please choose another one.";
				}
			}
			else if(checkText(text, "no") && talkState[12])
			{
				talkState[11] = true;
				talkState[12] = false;
				msg << "What would you like to be then?";
			}
			else if(checkText(text, "recovery key") && talkState[1])
			{
				talkState[1] = false;
				talkState[10] = true;
				msg << "Would you like to generate a recovery key? {yes} or {no}?";
			}
			else if(checkText(text, "yes") && talkState[10])
			{
				if(account.recoveryKey != "0")
					msg << "Sorry, but you already have a recovery key. For security reasons I may not generate for you you a new one.";
				else
				{
					managerString = generateRecoveryKey(4, 4);
					IOLoginData::getInstance()->setRecoveryKey(managerNumber, managerString);
					msg << "Your recovery key is {" << managerString << "}.";
				}

				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;
			}
			else if(checkText(text, "no") && talkState[10])
			{
				msg << "Ok, then not.";
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;
			}
			else
				msg << "Sorry, but I can't understand you, please try to repeat.";

			break;
		}
		case MANAGER_NEW:
		{
			if(checkText(text, "account") && !talkState[1])
			{
				msg << "What would you like your password to be?";
				talkState[1] = true;
				talkState[2] = true;
			}
			else if(talkState[2])
			{
				std::string tmp = text;
				trimString(tmp);
				if(tmp.length() < 6)
					msg << "That password is too short, please select a longer one.";
				else if(!isValidPassword(tmp))
					msg << "Your password seems to contain invalid symbols, please choose another one.";
				else
				{
					talkState[3] = true;
					talkState[2] = false;
					managerString = tmp;
					msg << "{" << managerString << "} is it? {yes} or {no}?";
				}
			}
			else if(checkText(text, "yes") && talkState[3])
			{
				if(g_config.getBool(ConfigManager::GENERATE_ACCOUNT_NUMBER))
				{
					do
						sprintf(managerChar, "%d%d%d%d%d%d%d", random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9));
					while(IOLoginData::getInstance()->accountNameExists(managerChar));

					uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
					if(id)
					{
						accountManager = MANAGER_ACCOUNT;
						managerNumber = id;

						noSwap = talkState[1] = false;
						msg << "Your account has been created, you may manage it now, but please remember your account name {"
							<< managerChar << "} and password {" << managerString << "}!";
					}
					else
						msg << "Your account could not be created, please contact with staff.";

					for(int8_t i = 2; i <= 5; ++i)
						talkState[i] = false;
				}
				else
				{
					msg << "What would you like your account name to be?";
					talkState[3] = false;
					talkState[4] = true;
				}
			}
			else if(checkText(text, "no") && talkState[3])
			{
				talkState[2] = true;
				talkState[3] = false;
				msg << "What would you like your password to be then?";
			}
			else if(talkState[4])
			{
				std::string tmp = text;
				trimString(tmp);
				if(tmp.length() < 3)
					msg << "That account name is too short, please select a longer one.";
				else if(tmp.length() > 32)
					msg << "That account name is too long, please select a shorter one.";
				else if(!isValidAccountName(tmp))
					msg << "Your account name seems to contain invalid symbols, please choose another one.";
				else if(asLowerCaseString(tmp) == asLowerCaseString(managerString))
					msg << "Your account name cannot be same as password, please choose another one.";
				else
				{
					sprintf(managerChar, "%s", tmp.c_str());
					msg << "{" << managerChar << "}, is it? {yes} or {no}?";
					talkState[4] = false;
					talkState[5] = true;
				}
			}
			else if(checkText(text, "yes") && talkState[5])
			{
				if(!IOLoginData::getInstance()->accountNameExists(managerChar))
				{
					uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
					if(id)
					{
						accountManager = MANAGER_ACCOUNT;
						managerNumber = id;

						noSwap = talkState[1] = false;
						msg << "Your account has been created, you may manage it now, but please remember your account name {"
							<< managerChar << "} and password {" << managerString << "}!";
					}
					else
						msg << "Your account could not be created, please contact with staff.";

					for(int8_t i = 2; i <= 5; ++i)
						talkState[i] = false;
				}
				else
				{
					msg << "Account with that name already exists, please choose another one.";
					talkState[4] = true;
					talkState[5] = false;
				}
			}
			else if(checkText(text, "no") && talkState[5])
			{
				talkState[5] = false;
				talkState[4] = true;
				msg << "What would you like your account name to be then?";
			}
			else if(checkText(text, "recover") && !talkState[6])
			{
				talkState[6] = true;
				talkState[7] = true;
				msg << "What was your account name?";
			}
			else if(talkState[7])
			{
				managerString = text;
				if(IOLoginData::getInstance()->getAccountId(managerString, (uint32_t&)managerNumber))
				{
					talkState[7] = false;
					talkState[8] = true;
					msg << "What was your recovery key?";
				}
				else
				{
					msg << "Sorry, but account with name {" << managerString << "} does not exists.";
					talkState[6] = talkState[7] = false;
				}
			}
			else if(talkState[8])
			{
				managerString2 = text;
				if(IOLoginData::getInstance()->validRecoveryKey(managerNumber, managerString2) && managerString2 != "0")
				{
					sprintf(managerChar, "%s%d", g_config.getString(ConfigManager::SERVER_NAME).c_str(), random_range(100, 999));
					IOLoginData::getInstance()->setPassword(managerNumber, managerChar);
					msg << "Correct! Your new password is {" << managerChar << "}.";
				}
				else
					msg << "Sorry, but this key does not match to specified account.";

				talkState[7] = talkState[8] = false;
			}
			else
				msg << "Sorry, but I can't understand you, please try to repeat.";

			break;
		}
		default:
			return;
			break;
	}

	sendCreatureSay(this, SPEAK_PRIVATE_NP, msg.str());
	if(!noSwap)
		sendCreatureSay(this, SPEAK_PRIVATE_NP, "Hint: Type {account} to manage your account and if you want to start over then type {cancel}.");
} 

 

Não testado.

Editado por MaTTch (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

 

 
 

 

void Player::manageAccount(const std::string &text)
{
	std::stringstream msg;
	bool noSwap = true;
	switch(accountManager)
	{
		case MANAGER_NAMELOCK:
		{
			if(!talkState[1])
			{
				managerString = text;
				trimString(managerString);
				if(managerString.length() < 3)
					msg << "The name is too short, please select a longer one.";
				else if(managerString.length() > 30)
					msg << "The name is too long, please select a shorter one.";
				else if(!isValidName(managerString))
					msg << "Your name seems to contain invalid symbols, please choose another one.";
				else if(IOLoginData::getInstance()->playerExists(managerString, true))
					msg << "Player with that name already exists, please choose another one.";
				else
				{
					std::string tmp = asLowerCaseString(managerString);
					if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
					{
						talkState[1] = talkState[2] = true;
						msg << "{" << managerString << "}, are you sure? {yes} or {no}?";
					}
					else
						msg << "Your character is not a staff member, please choose another name.";
				}
			}
			else if(checkText(text, "no") && talkState[2])
			{
				talkState[1] = talkState[2] = false;
				msg << "What new name would you like have then?";
			}
			else if(checkText(text, "yes") && talkState[2])
			{
				if(!IOLoginData::getInstance()->playerExists(managerString, true))
				{
					uint32_t tmp;
					if(IOLoginData::getInstance()->getGuidByName(tmp, managerString2) &&
						IOLoginData::getInstance()->changeName(tmp, managerString, managerString2) &&
						IOBan::getInstance()->removePlayerBanishment(tmp, PLAYERBAN_LOCK))
					{
						msg << "Your character {" << managerString << "} has been successfully renamed to {" << managerString2 << "}, you should be able to login now.";
						if(House* house = Houses::getInstance()->getHouseByPlayerId(tmp))
							house->updateDoorDescription(managerString);

						talkState[1] = true;
						talkState[2] = false;
					}
					else
					{
						talkState[1] = talkState[2] = false;
						msg << "Failed to change your name, please contact with staff.";
					}
				}
				else
				{
					talkState[1] = talkState[2] = false;
					msg << "Player with that name already exists, please choose another one.";
				}
			}
			else
				msg << "Sorry, but I can't understand you, please try to repeat.";

			break;
		}
		case MANAGER_ACCOUNT:
		{
			Account account = IOLoginData::getInstance()->loadAccount(managerNumber);
			if(checkText(text, "cancel") || (checkText(text, "account") && !talkState[1]))
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;

				msg << "Do you want to change your {password}, generate a {recovery key}, create a {character}, or {delete} an existing character?";
			}
			else if(checkText(text, "delete") && talkState[1])
			{
				talkState[1] = false;
				talkState[2] = true;
				msg << "Which character would you like to delete?";
			}
			else if(talkState[2])
			{
				std::string tmp = text;
				trimString(tmp);
				if(!isValidName(tmp, false))
					msg << "That name to contain invalid symbols, please try again.";
				else
				{
					talkState[2] = false;
					talkState[3] = true;
					managerString = tmp;
					msg << "Do you really want to delete the character {" << managerString << "}? {yes} or {no}?";
				}
			}
			else if(checkText(text, "yes") && talkState[3])
			{
				switch(IOLoginData::getInstance()->deleteCharacter(managerNumber, managerString))
				{
					case DELETE_INTERNAL:
						msg << "An error occured while deleting your character. Either the character does not belong to you or it doesn't exist.";
						break;

					case DELETE_SUCCESS:
						msg << "Your character has been deleted.";
						break;

					case DELETE_HOUSE:
						msg << "Your character owns a house. You have to login and leave the house or pass it to someone else to complete.";
						break;

					case DELETE_LEADER:
						msg << "Your character is leader of a guild. You have to disband the guild or pass the leadership to someone else to complete.";
						break;

					case DELETE_ONLINE:
						msg << "Character with that name is currently online, to delete a character it has to be offline.";
						break;
				}

				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;
			}
			else if(checkText(text, "no") && talkState[3])
			{
				talkState[1] = true;
				talkState[3] = false;
				msg << "Which character would you like to delete then?";
			}
			else if(checkText(text, "password") && talkState[1])
			{
				talkState[1] = false;
				talkState[4] = true;
				msg << "What would you like your password to be?";
			}
			else if(talkState[4])
			{
				std::string tmp = text;
				trimString(tmp);
				if(tmp.length() < 6)
					msg << "That password is too short, please select a longer one.";
				else if(!isValidPassword(tmp))
					msg << "Your password seems to contain invalid symbols, please choose another one.";
				else
				{
					talkState[4] = false;
					talkState[5] = true;
					managerString = tmp;
					msg << "{" << managerString << "} is it? {yes} or {no}?";
				}
			}
			else if(checkText(text, "yes") && talkState[5])
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;

				IOLoginData::getInstance()->setPassword(managerNumber, managerString);
				msg << "Your password has been changed.";
			}
			else if(checkText(text, "no") && talkState[5])
			{
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;

				msg << "Ok, then not.";
			}
			else if(checkText(text, "character") && talkState[1])
			{
				if(account.charList.size() <= 15)
				{
					talkState[1] = false;
					talkState[6] = true;
					msg << "What would you like as your character name?";
				}
				else
				{
					talkState[1] = true;
					for(int8_t i = 2; i <= 12; ++i)
						talkState[i] = false;

					msg << "Your account has reached the limit of 15 characters, you should {delete} a character if you want to create a new one.";
				}
			}
			else if(talkState[6])
			{
				managerString = text;
				trimString(managerString);
				if(managerString.length() < 3)
					msg << "That name is too short, please select a longer one.";
				else if(managerString.length() > 30)
					msg << "That name is too long, please select a shorter one.";
				else if(!isValidName(managerString))
					msg << "Your name seems to contain invalid symbols, please choose another one.";
				else if(IOLoginData::getInstance()->playerExists(managerString, true))
					msg << "Player with that name already exists, please choose another one.";
				else
				{
					std::string tmp = asLowerCaseString(managerString);
					if(tmp.substr(0, 4) != "god " && tmp.substr(0, 3) != "cm " && tmp.substr(0, 3) != "gm ")
					{
						talkState[6] = false;
						talkState[7] = true;
						msg << "{" << managerString << "}, are you sure? {yes} or {no}?";
					}
					else
						msg << "Your character is not a staff member, please choose another name.";
				}
			}
			else if(checkText(text, "no") && talkState[7])
			{
				talkState[6] = true;
				talkState[7] = false;
				msg << "What would you like your character name to be then?";
			}
			else if(checkText(text, "yes") && talkState[7])
			{
				talkState[7] = false;
				talkState[8] = true;
				msg << "Would you like to be a {male} or a {female}?";
			}
			else if(talkState[8] && (checkText(text, "female") || checkText(text, "male")))
			{
				talkState[8] = false;
				talkState[9] = true;
				if(checkText(text, "female"))
				{
					msg << "A female, are you sure? {yes} or {no}?";
					managerSex = PLAYERSEX_FEMALE;
				}
				else
				{
					msg << "A male, are you sure? {yes} or {no}?";
					managerSex = PLAYERSEX_MALE;
				}
			}
			else if(checkText(text, "no") && talkState[9])
			{
				talkState[8] = true;
				talkState[9] = false;
				msg << "Tell me then, would you like to be a {male} or a {female}?";
			}
			else if(checkText(text, "yes") && talkState[9])
			{
				if(g_config.getBool(ConfigManager::START_CHOOSEVOC))
				{
					talkState[9] = false;
					talkState[11] = true;

					std::vector<std::string> vocations;
					for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
					{
						if(it->first == it->second->getFromVocation() && it->first != 0)
							vocations.push_back(it->second->getName());
					}

					msg << "What would you like to be... ";
					for(std::vector<std::string>::const_iterator it = vocations.begin(); it != vocations.end(); ++it)
					{
						if(it == vocations.begin())
							msg << "{" << *it << "}";
						else if(*it == *(vocations.rbegin()))
							msg << " or {" << *it << "}.";
						else
							msg << ", {" << *it << "}";
					}
				}
				else if(!IOLoginData::getInstance()->playerExists(managerString, true))
				{
					talkState[1] = true;
					for(int8_t i = 2; i <= 12; ++i)
						talkState[i] = false;

					if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
						msg << "Your character {" << managerString << "} has been created.";
					else
						msg << "Your character couldn't be created, please contact with staff.";
				}
				else
				{
					talkState[6] = true;
					talkState[9] = false;
					msg << "Player with that name already exists, please choose another one.";
				}
			}
			else if(talkState[11])
			{
				for(VocationsMap::iterator it = Vocations::getInstance()->getFirstVocation(); it != Vocations::getInstance()->getLastVocation(); ++it)
				{
					if(checkText(text, asLowerCaseString(it->second->getName())) &&
						it->first == it->second->getFromVocation() && it->first != 0)
					{
						msg << "So you would like to be " << it->second->getDescription() << ", {yes} or {no}?";
						managerNumber2 = it->first;
						talkState[11] = false;
						talkState[12] = true;
					}
				}
			}
			else if(checkText(text, "yes") && talkState[12])
			{
				if(!IOLoginData::getInstance()->playerExists(managerString, true))
				{
					talkState[1] = true;
					for(int8_t i = 2; i <= 12; ++i)
						talkState[i] = false;

					if(IOLoginData::getInstance()->createCharacter(managerNumber, managerString, managerNumber2, (uint16_t)managerSex))
						msg << "Your character {" << managerString << "} has been created.";
					else
						msg << "Your character couldn't be created, please contact with staff.";
				}
				else
				{
					talkState[6] = true;
					talkState[9] = false;
					msg << "Player with that name already exists, please choose another one.";
				}
			}
			else if(checkText(text, "no") && talkState[12])
			{
				talkState[11] = true;
				talkState[12] = false;
				msg << "What would you like to be then?";
			}
			else if(checkText(text, "recovery key") && talkState[1])
			{
				talkState[1] = false;
				talkState[10] = true;
				msg << "Would you like to generate a recovery key? {yes} or {no}?";
			}
			else if(checkText(text, "yes") && talkState[10])
			{
				if(account.recoveryKey != "0")
					msg << "Sorry, but you already have a recovery key. For security reasons I may not generate for you you a new one.";
				else
				{
					managerString = generateRecoveryKey(4, 4);
					IOLoginData::getInstance()->setRecoveryKey(managerNumber, managerString);
					msg << "Your recovery key is {" << managerString << "}.";
				}

				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;
			}
			else if(checkText(text, "no") && talkState[10])
			{
				msg << "Ok, then not.";
				talkState[1] = true;
				for(int8_t i = 2; i <= 12; ++i)
					talkState[i] = false;
			}
			else
				msg << "Sorry, but I can't understand you, please try to repeat.";

			break;
		}
		case MANAGER_NEW:
		{
			if(checkText(text, "account") && !talkState[1])
			{
				msg << "What would you like your password to be?";
				talkState[1] = true;
				talkState[2] = true;
			}
			else if(talkState[2])
			{
				std::string tmp = text;
				trimString(tmp);
				if(tmp.length() < 6)
					msg << "That password is too short, please select a longer one.";
				else if(!isValidPassword(tmp))
					msg << "Your password seems to contain invalid symbols, please choose another one.";
				else
				{
					talkState[3] = true;
					talkState[2] = false;
					managerString = tmp;
					msg << "{" << managerString << "} is it? {yes} or {no}?";
				}
			}
			else if(checkText(text, "yes") && talkState[3])
			{
				if(g_config.getBool(ConfigManager::GENERATE_ACCOUNT_NUMBER))
				{
					do
						sprintf(managerChar, "%d%d%d%d%d%d%d", random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9), random_range(2, 9));
					while(IOLoginData::getInstance()->accountNameExists(managerChar));

					uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
					if(id)
					{
						accountManager = MANAGER_ACCOUNT;
						managerNumber = id;

						noSwap = talkState[1] = false;
						msg << "Your account has been created, you may manage it now, but please remember your account name {"
							<< managerChar << "} and password {" << managerString << "}!";
					}
					else
						msg << "Your account could not be created, please contact with staff.";

					for(int8_t i = 2; i <= 5; ++i)
						talkState[i] = false;
				}
				else
				{
					msg << "What would you like your account name to be?";
					talkState[3] = false;
					talkState[4] = true;
				}
			}
			else if(checkText(text, "no") && talkState[3])
			{
				talkState[2] = true;
				talkState[3] = false;
				msg << "What would you like your password to be then?";
			}
			else if(talkState[4])
			{
				std::string tmp = text;
				trimString(tmp);
				if(tmp.length() < 3)
					msg << "That account name is too short, please select a longer one.";
				else if(tmp.length() > 32)
					msg << "That account name is too long, please select a shorter one.";
				else if(!isValidAccountName(tmp))
					msg << "Your account name seems to contain invalid symbols, please choose another one.";
				else if(asLowerCaseString(tmp) == asLowerCaseString(managerString))
					msg << "Your account name cannot be same as password, please choose another one.";
				else
				{
					sprintf(managerChar, "%s", tmp.c_str());
					msg << "{" << managerChar << "}, is it? {yes} or {no}?";
					talkState[4] = false;
					talkState[5] = true;
				}
			}
			else if(checkText(text, "yes") && talkState[5])
			{
				if(!IOLoginData::getInstance()->accountNameExists(managerChar))
				{
					uint32_t id = (uint32_t)IOLoginData::getInstance()->createAccount(managerChar, managerString);
					if(id)
					{
						accountManager = MANAGER_ACCOUNT;
						managerNumber = id;

						noSwap = talkState[1] = false;
						msg << "Your account has been created, you may manage it now, but please remember your account name {"
							<< managerChar << "} and password {" << managerString << "}!";
					}
					else
						msg << "Your account could not be created, please contact with staff.";

					for(int8_t i = 2; i <= 5; ++i)
						talkState[i] = false;
				}
				else
				{
					msg << "Account with that name already exists, please choose another one.";
					talkState[4] = true;
					talkState[5] = false;
				}
			}
			else if(checkText(text, "no") && talkState[5])
			{
				talkState[5] = false;
				talkState[4] = true;
				msg << "What would you like your account name to be then?";
			}
			else if(checkText(text, "recover") && !talkState[6])
			{
				talkState[6] = true;
				talkState[7] = true;
				msg << "What was your account name?";
			}
			else if(talkState[7])
			{
				managerString = text;
				if(IOLoginData::getInstance()->getAccountId(managerString, (uint32_t&)managerNumber))
				{
					talkState[7] = false;
					talkState[8] = true;
					msg << "What was your recovery key?";
				}
				else
				{
					msg << "Sorry, but account with name {" << managerString << "} does not exists.";
					talkState[6] = talkState[7] = false;
				}
			}
			else if(talkState[8])
			{
				managerString2 = text;
				if(IOLoginData::getInstance()->validRecoveryKey(managerNumber, managerString2) && managerString2 != "0")
				{
					sprintf(managerChar, "%s%d", g_config.getString(ConfigManager::SERVER_NAME).c_str(), random_range(100, 999));
					IOLoginData::getInstance()->setPassword(managerNumber, managerChar);
					msg << "Correct! Your new password is {" << managerChar << "}.";
				}
				else
					msg << "Sorry, but this key does not match to specified account.";

				talkState[7] = talkState[8] = false;
			}
			else
				msg << "Sorry, but I can't understand you, please try to repeat.";

			break;
		}
		default:
			return;
			break;
	}

	sendCreatureSay(this, SPEAK_PRIVATE_NP, msg.str());
	if(!noSwap)
		sendCreatureSay(this, SPEAK_PRIVATE_NP, "Hint: Type {account} to manage your account and if you want to start over then type {cancel}.");
} 

 

Não testado.

 

Deu certo, krai mano, ce e show, se pudesse dar 100 rep por dia, meus 100 era seu kk, vlw mesmo, agora so falta uma coisa pra fechar ela, sabe a paradinha de limitar o attackspeed?, deixar igualado com bot ou sem bot tlgd?, acho que isso e algum codigo de fixar o ping, algo do tipo, <3

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96844
    Tópicos
    519600
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo