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

C++ - Quiver Issue TFS 1.2 - Nostalrius

dropz

Member
Joined
May 4, 2022
Messages
46
Reaction score
24
hello everyone!!

here we go again

im implementing a quiver for my server, i found a good content here on the forum thats helped me a lot in the way but now im facing a problem that im not knowing how to deal with...

well, i used the solutions of this thread for the implementation:

but fow now im getting a issue about the container items, every backpack, bag or parcel that i put on the arrow slot with ammunition inside works like a quiver.
i tried create a some conditions on player.cpp using some tips that i saw in few other threads about quivers, but unfortunately nothing worked for me..

anyone knows a way to solve it?

here's my player.cpp function that's used for ammunition:

C++:
Item* Player::getAmmunition() const
{
    Item* item = inventory[CONST_SLOT_AMMO];
    if(!item)
        return nullptr;

    if(Container *container = item->getContainer()){
        Item* weapon = getWeapon();
        const ItemType& it = Item::items[weapon->getID()];
        for(ContainerIterator iter = container->iterator(); iter.hasNext(); iter.advance()) {
            const ItemType& itr = Item::items[(*iter)->getID()];
            if(itr.ammoType == it.ammoType)
                return (*iter);
        }
    }

    return item;
}

i tried create a another "if" below "if(Container *container = item->getContainer())" to try deal with the idea of item->getName() = "quiver", something like that buuut no results..
better example of one try:

C++:
Container* container = ammoItem->getContainer()
if (container && container->getName() == "Quiver")
{
    for(ContainerIterator iter = container->begin(), end = container->end(); iter != end; ++iter)
    {
        if (item->getAmmoType() == (*iter)->getAmmoType())
        {
            ammoItem = (*iter);
            break;
        }
    }
}
but it didnt works too...

Thanks in advance, you guys are rock.
Post automatically merged:

solved:
if you came here trying found a solution for it, add this new "if" that has the comment of quiver id.
use the thread that i mencioned before to get the base of the quiver system creation, then use this funcition for the getAmmution on "player.cpp":

C++:
Item* Player::getAmmunition() const
{
    Item* item = inventory[CONST_SLOT_AMMO];
    if(!item)
        return nullptr;

    if(Container *container = item->getContainer()){
    if(container->getID() == 5090 || container->getID() == 5101){ // id of quiver items.
        Item* weapon = getWeapon();
        const ItemType& it = Item::items[weapon->getID()];
        for(ContainerIterator iter = container->iterator(); iter.hasNext(); iter.advance()) {
            const ItemType& itr = Item::items[(*iter)->getID()];
            if(itr.ammoType == it.ammoType)
                return (*iter);
            }
        }
    }

    return item;
}

:D
 
Last edited:
Back
Top