• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Removing Offline Training From Beds

Sir Richard

New Member
Joined
Jun 10, 2009
Messages
19
Reaction score
3
Location
Brazil
Hello everyone!

Well, basically I just want to remove the offline training from beds, which leads me to the following question:
Which are and where exactly can I find the specific lines regarding this matter, inside the sources? It might be obvious, but I just can't seem to find it :|

Using the latest version of TFS.

Thanks in advance,

Richard
 
Last edited:
In actions.cpp, search for sendOfflineTrainingDialog. You will need to replace this line with the one that will actually make the player sleep (look at game.cpp playerAnswerModal~).
 
In actions.cpp, search for sendOfflineTrainingDialog. You will need to replace this line with the one that will actually make the player sleep (look at game.cpp playerAnswerModal~).
I'm no C++ magician. I should change g_game.sendOfflineTrainingDialog(player); in actions.cpp for what?
Code:
void Game::playerAnswerModalWindow(uint32_t playerId, uint32_t modalWindowId, uint8_t button, uint8_t choice)
{
    Player* player = getPlayerByID(playerId);
    if (!player) {
        return;
    }

    if (!player->hasModalWindowOpen(modalWindowId)) {
        return;
    }

    player->onModalWindowHandled(modalWindowId);

    // offline training, hardcoded
    if (modalWindowId == std::numeric_limits<uint32_t>::max()) {
        if (button == 1) {
            if (choice == SKILL_SWORD || choice == SKILL_AXE || choice == SKILL_CLUB || choice == SKILL_DISTANCE || choice == SKILL_MAGLEVEL) {
                BedItem* bedItem = player->getBedItem();
                if (bedItem && bedItem->sleep(player)) {
                    player->setOfflineTrainingSkill(choice);
                    return;
                }
            }
        } else {
            player->sendTextMessage(MESSAGE_EVENT_ADVANCE, "Offline training aborted.");
        }

        player->setBedItem(nullptr);
    } else {
        for (auto creatureEvent : player->getCreatureEvents(CREATURE_EVENT_MODALWINDOW)) {
            creatureEvent->executeModalWindow(player, modalWindowId, button, choice);
        }
    }
}
 
search for a part where when you click on bed it sends modal window and replace sending modal window to this:
Code:
bedItem->sleep(player)
 
search for a part where when you click on bed it sends modal window and replace sending modal window to this:
Code:
bedItem->sleep(player)
I got an error.
Code:
uilding CXX object CMakeFiles/tfs.dir/src/actions.cpp.o
/home/otsmanager/forgottenserver/forgottenserver-8d4745e6fcd3caf69cc5c941869fe5c2b27c903f/src/actions.cpp: In member function ‘ReturnValue Actions::internalUseItem(Player, const Position&, uint8_t, Item, bool)’:
/home/otsmanager/forgottenserver/forgottenserver-8d4745e6fcd3caf69cc5c941869fe5c2b27c903f/src/actions.cpp:313:4: error: ‘bedItem’ was not declared in this scope
    bedItem->sleep(player);
    ^
make[2]: *** [CMakeFiles/tfs.dir/src/actions.cpp.o] Error 1
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
make: *** [all] Error 2
 
Code:
BedItem* bedItem = player->getBedItem();
if (bedItem) {
    bedItem->sleep(player);
}
 
Last edited:
Yes, that's looks fine (don't forget to add the missing semicolon after bedItem->sleep(player) :p).
 
somewhere above thing which put player to sleep:
Code:
BedItem* bedItem = player->getBedItem();

not sure if it needs passing something else, I don't know much about c++
 
From what I've read above, it's not possible to remove it or change it in any way without C++?

Kind Regards,
Eldin.
 
Back
Top