• 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!

Problem with new parcel

Lucas Durais

New Member
Joined
Jan 13, 2017
Messages
40
Reaction score
1
Hello otland

My problem is that I want to make a new parcel for the vip people and that will only be sold in the npc of vip area.

I already compiled the tfs so it will send trough the mailbox, the problem is that when i send it, i receive in the mailbox in the depot a item with the id of the new parcel +1.

To be easier to understand, the new parcel have the id 26054, and when i send it, i receive an item with id 26055.

I would like to receive the same parcel with id 26054, so it can be used again. How can I do that?

Thank you already!
 
Hello otland

My problem is that I want to make a new parcel for the vip people and that will only be sold in the npc of vip area.

I already compiled the tfs so it will send trough the mailbox, the problem is that when i send it, i receive in the mailbox in the depot a item with the id of the new parcel +1.

To be easier to understand, the new parcel have the id 26054, and when i send it, i receive an item with id 26055.

I would like to receive the same parcel with id 26054, so it can be used again. How can I do that?

Thank you already!
https://github.com/otland/forgottenserver/blob/master/src/mailbox.cpp#L107
 
Code:
if (!item->getId() == 26054) {
    g_game.transformItem(item, item->getID() + 1);
}
player->onRecieveMail();
return true;
you might need to change the one on line 119 too
 
I tried to compile with this code you send me but it didn't work.

I actually want the id 26054 don't give this extra +1 id. I also tried to change in the line 119 but i got a lot of errors:

'getID: is not a member of 'item'
'onRecieveMail': is not a member of 'Player'
'getID': is not a mbember of 'item' -- again
class "item" has no member "getID"
class "Player" has no member "onRecieveMail"
class "Item" has nom ember "getID"


My source mailbox.cpp it's like this:

Code:
#include "otpch.h"

#include "mailbox.h"
#include "game.h"
#include "iologindata.h"

extern Game g_game;

ReturnValue Mailbox::queryAdd(int32_t, const Thing& thing, uint32_t, uint32_t, Creature*) const
{
    const Item* item = thing.getItem();
    if (item && Mailbox::canSend(item)) {
        return RETURNVALUE_NOERROR;
    }
    return RETURNVALUE_NOTPOSSIBLE;
}

ReturnValue Mailbox::queryMaxCount(int32_t, const Thing&, uint32_t count, uint32_t& maxQueryCount, uint32_t) const
{
    maxQueryCount = std::max<uint32_t>(1, count);
    return RETURNVALUE_NOERROR;
}

ReturnValue Mailbox::queryRemove(const Thing&, uint32_t, uint32_t) const
{
    return RETURNVALUE_NOTPOSSIBLE;
}

Cylinder* Mailbox::queryDestination(int32_t&, const Thing&, Item**, uint32_t&)
{
    return this;
}

void Mailbox::addThing(Thing* thing)
{
    return addThing(0, thing);
}

void Mailbox::addThing(int32_t, Thing* thing)
{
    Item* item = thing->getItem();
    if (item && Mailbox::canSend(item)) {
        sendItem(item);
    }
}

void Mailbox::updateThing(Thing*, uint16_t, uint32_t)
{
    //
}

void Mailbox::replaceThing(uint32_t, Thing*)
{
    //
}

void Mailbox::removeThing(Thing*, uint32_t)
{
    //
}

void Mailbox::postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t)
{
    getParent()->postAddNotification(thing, oldParent, index, LINK_PARENT);
}

void Mailbox::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, cylinderlink_t)
{
    getParent()->postRemoveNotification(thing, newParent, index, LINK_PARENT);
}

bool Mailbox::sendItem(Item* item) const
{
    std::string receiver;
    if (!getReceiver(item, receiver)) {
        return false;
    }

    /**No need to continue if its still empty**/
    if (receiver.empty()) {
        return false;
    }

    Player* player = g_game.getPlayerByName(receiver);
    if (player) {
        if (g_game.internalMoveItem(item->getParent(), player->getInbox(), INDEX_WHEREEVER,
                                    item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
            g_game.transformItem(item, item->getID() + 1);
            player->onReceiveMail();
            return true;
        if (!item->getId() == 26054) {
            g_game.transformItem(item, item->getID() + 0);
            }
            player->onRecieveMail();
            return true;
        }
    } else {
        Player tmpPlayer(nullptr);
        if (!IOLoginData::loadPlayerByName(&tmpPlayer, receiver)) {
            return false;
        }

        if (g_game.internalMoveItem(item->getParent(), tmpPlayer.getInbox(), INDEX_WHEREEVER,
                                    item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
            g_game.transformItem(item, item->getID() + 1);
            IOLoginData::savePlayer(&tmpPlayer);
            return true;
        if (!item->getId() == 26054) {
                g_game.transformItem(item, item->getID() + 0);
            }
            IOLoginData::savePlayer(&tmpPlayer);
            return true;
        }
    }
    return false;
}

bool Mailbox::getReceiver(Item* item, std::string& name) const
{
    const Container* container = item->getContainer();
    if (container) {
        for (Item* containerItem : container->getItemList()) {
            if (containerItem->getID() == ITEM_LABEL && getReceiver(containerItem, name)) {
                return true;
            }
        }
        return false;
    }

    const std::string& text = item->getText();
    if (text.empty()) {
        return false;
    }

    name = getFirstLine(text);
    trimString(name);
    return true;
}

bool Mailbox::canSend(const Item* item)
{
    return item->getID() == ITEM_ROYALPARCEL || item->getID() == ITEM_LETTER;
    return item->getID() == ITEM_PARCEL || item->getID() == ITEM_LETTER;

}
 
you did it wrong but i also misspelled
here
Code:
bool Mailbox::sendItem(Item* item) const
{
    std::string receiver;
    if (!getReceiver(item, receiver)) {
        return false;
    }

    /**No need to continue if its still empty**/
    if (receiver.empty()) {
        return false;
    }

    Player* player = g_game.getPlayerByName(receiver);
    if (player) {
        if (g_game.internalMoveItem(item->getParent(), player->getInbox(), INDEX_WHEREEVER,
                                    item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
            if (item->getID() != 26054) {
                g_game.transformItem(item, item->getID() + 1);
            }
            player->onReceiveMail();
            return true;
        }
    } else {
        Player tmpPlayer(nullptr);
        if (!IOLoginData::loadPlayerByName(&tmpPlayer, receiver)) {
            return false;
        }

        if (g_game.internalMoveItem(item->getParent(), tmpPlayer.getInbox(), INDEX_WHEREEVER,
                                    item, item->getItemCount(), nullptr, FLAG_NOLIMIT) == RETURNVALUE_NOERROR) {
            if (item->getID() != 26054) {
                g_game.transformItem(item, item->getID() + 1);
            }
            IOLoginData::savePlayer(&tmpPlayer);
            return true;
        }
    }
    return false;
}
 
I replaced my code with yours and now my new parcel is sending and receiving perfectly.

But now the usual parcel doesn't send. Why is that?
 
Back
Top