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

How to use pagination on containers?

Lundrial

lundrial:getTitle()
Joined
Apr 15, 2014
Messages
142
Reaction score
104
Location
Chile
As title says, I would like to know how to add pagination to a container item.
I'm using tfs 1.2 btw
 
Solution
As title says, I would like to know how to add pagination to a container item.
I'm using tfs 1.2 btw
Code:
void setPagination(bool state) {
    pagination = state;
}

Or construct it with pagination already like browse field:
Code:
Container(ITEM_BROWSEFIELD, 30, false, true)

To add items to this container in lua you use:
Code:
container:addItemEx(virtualItem, INDEX_WHEREEVER, FLAG_NOLIMIT)

If you want this for store inbox you will have to edit more shit to get it done as pagination state is not serialized.

You can do it in iologindata.cpp where it loads the inventory items:

Code:
            if (pid >= 1 && pid <= 11) {
                if (pid == 11) {
                    Container* container = item->getContainer()...
As title says, I would like to know how to add pagination to a container item.
I'm using tfs 1.2 btw
Code:
void setPagination(bool state) {
    pagination = state;
}

Or construct it with pagination already like browse field:
Code:
Container(ITEM_BROWSEFIELD, 30, false, true)

To add items to this container in lua you use:
Code:
container:addItemEx(virtualItem, INDEX_WHEREEVER, FLAG_NOLIMIT)

If you want this for store inbox you will have to edit more shit to get it done as pagination state is not serialized.

You can do it in iologindata.cpp where it loads the inventory items:

Code:
            if (pid >= 1 && pid <= 11) {
                if (pid == 11) {
                    Container* container = item->getContainer();
                    if (container) {
                        container->setPagination(true);
                    }
                }
                player->internalAddThing(pid, item);
 
Solution
Code:
void setPagination(bool state) {
    pagination = state;
}

Or construct it with pagination already like browse field:
Code:
Container(ITEM_BROWSEFIELD, 30, false, true)

To add items to this container in lua you use:
Code:
container:addItemEx(virtualItem, INDEX_WHEREEVER, FLAG_NOLIMIT)

If you want this for store inbox you will have to edit more shit to get it done as pagination state is not serialized.

You can do it in iologindata.cpp where it loads the inventory items:

Code:
            if (pid >= 1 && pid <= 11) {
                if (pid == 11) {
                    Container* container = item->getContainer();
                    if (container) {
                        container->setPagination(true);
                    }
                }
                player->internalAddThing(pid, item);
I guess I'm fucked then, time to have some experiments with the store inbox, thanks!
 
I test it :oops: have an issue in the script
13595676_1071981952883498_2049626916_n.png
 
Code:
void setPagination(bool state) {
    pagination = state;
}

Or construct it with pagination already like browse field:
Code:
Container(ITEM_BROWSEFIELD, 30, false, true)

To add items to this container in lua you use:
Code:
container:addItemEx(virtualItem, INDEX_WHEREEVER, FLAG_NOLIMIT)

If you want this for store inbox you will have to edit more shit to get it done as pagination state is not serialized.

You can do it in iologindata.cpp where it loads the inventory items:

Code:
            if (pid >= 1 && pid <= 11) {
                if (pid == 11) {
                    Container* container = item->getContainer();
                    if (container) {
                        container->setPagination(true);
                    }
                }
                player->internalAddThing(pid, item);


i do the part of the iologindata.cpp to add pagination to PURSE item. but get error "setPagination its not a member of container
how i can solve this?

im trying to make the purse slot "item" with pagination "true"
 
i do the part of the iologindata.cpp to add pagination to PURSE item. but get error "setPagination its not a member of container
how i can solve this?

im trying to make the purse slot "item" with pagination "true"

You did not add the method setPagination to Container class.
 
yeah D: but now solved jeje thanks bro
a question!
example = if you open the PURSE with pagination true with 32 items inside (vol:32) and you try to add one item (33) to create the 2nd page of the PURSE
it return "you cannot put more objects in this container" but if you use lua like =

Code:
local purse = player:getSlotItem(CONST_SLOT_PURSE)
if purse then
purse:addItem(2160, 100, INDEX_WHEREEVER, FLAG_NOLIMIT)

the 2nd get created (33 of 64 spaces ) but still returning "you cannot put more objects in this container" if you try to move something inside
how i can solve this?
i make this on player on move item
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 17432 then
     local Chest = (toCylinder)
    local newitem = item:getId()
    local itemname = item:getName()
    doRemoveItem(item.uid, count)
    Chest:addItem(newitem, count, INDEX_WHEREEVER, FLAG_NOLIMIT)
    end
    return true
end

its a temporal fix to add items to the next pages of the purse but still returning the message S:
the problem of this onMoveItem its= if player try to move a backpack with items inside, the backpack get deleted and a new empty backpack get create inside the PURSE, maybe adding purse:getItem? to create the containers with the items inside?
its on tfs 1.2 a function to move a item with all theirs properties? without delete, create again?

solved with
Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 17432 then
     local depotChest = (toCylinder)
      item:moveTo(depotChest)
    end
    return true
end
adding this you can move items to the items with pagination like the new depots or the purse like i want, but still getting the message "you cannot add more objects in this container" how i can cancel this message when use the onMove? its possible?

SOLVED = if you add this on Player events onMoveItem = 1

Code:
function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 17432 then // <<< HERE THE ID of your depot, inbox, store inbox etc.
     local depotChest = (toCylinder)
      item:moveTo(depotChest)
    else
return true
    end
    return false
end

remember you need to have pagination TRUE on that container.

Someone can help me here on pagination!

iologindata.cpp

Code:
//load inventory items
    ItemMap itemMap;

    query.str(std::string());
    query << "SELECT `pid`, `sid`, `itemtype`, `count`, `attributes` FROM `player_items` WHERE `player_id` = " << player->getGUID() << " ORDER BY `sid` DESC";
    if ((result = db->storeQuery(query.str()))) {
        loadItems(itemMap, result);

        for (ItemMap::const_reverse_iterator it = itemMap.rbegin(), end = itemMap.rend(); it != end; ++it) {
            const std::pair<Item*, int32_t>& pair = it->second;
            Item* item = pair.first;
            int32_t pid = pair.second;
            if (pid >= 1 && pid <= 11) {
                if (pid == 11) {
                    Container* container = item->getContainer();
                    if (container) {
                        container->setPagination(true);
                    }
                }
           
                player->internalAddThing(pid, item);
            } else {
                ItemMap::const_iterator it2 = itemMap.find(pid);
                if (it2 == itemMap.end()) {
                    continue;
                }

                Container* container = it2->second.first->getContainer();
                if (container) {
                    container->internalAddThing(item);
                }
            }
        }
    }

    if (!player->inventory[CONST_SLOT_PURSE]) {
        player->internalAddThing(CONST_SLOT_PURSE, Item::CreateItem(ITEM_PURSE));
       
    }

here its added the pagination to the ITEM on the slot 11 "purse" <

now i want to add pagination to all the CONTAINER items.

something like
item get container
if container then Set pagination true
player internal add thing

someone?
 
Last edited by a moderator:
Someone can help me here on pagination!

iologindata.cpp

Code:
//load inventory items
    ItemMap itemMap;

    query.str(std::string());
    query << "SELECT `pid`, `sid`, `itemtype`, `count`, `attributes` FROM `player_items` WHERE `player_id` = " << player->getGUID() << " ORDER BY `sid` DESC";
    if ((result = db->storeQuery(query.str()))) {
        loadItems(itemMap, result);

        for (ItemMap::const_reverse_iterator it = itemMap.rbegin(), end = itemMap.rend(); it != end; ++it) {
            const std::pair<Item*, int32_t>& pair = it->second;
            Item* item = pair.first;
            int32_t pid = pair.second;
            if (pid >= 1 && pid <= 11) {
                if (pid == 11) {
                    Container* container = item->getContainer();
                    if (container) {
                        container->setPagination(true);
                    }
                }
          
                player->internalAddThing(pid, item);
            } else {
                ItemMap::const_iterator it2 = itemMap.find(pid);
                if (it2 == itemMap.end()) {
                    continue;
                }

                Container* container = it2->second.first->getContainer();
                if (container) {
                    container->internalAddThing(item);
                }
            }
        }
    }

    if (!player->inventory[CONST_SLOT_PURSE]) {
        player->internalAddThing(CONST_SLOT_PURSE, Item::CreateItem(ITEM_PURSE));
      
    }

here its added the pagination to the ITEM on the slot 11 "purse" <

now i want to add pagination to all the CONTAINER items.

something like
item get container
if container then Set pagination true
player internal add thing

someone?
Can you not quadruple post? You can use the EDIT function.

There reason why you cant move it to the container with pagination: You need the flag FLAG_NOLIMIT to move items to paginated containers. (item:moveTo uses this flag).

If you wanna add pagination to all containers you have to edit the source to always use the FLAG_NOLIMIT when a player moves an item and you can just construct with pagination set with true as default here:
https://github.com/otland/forgottenserver/blob/master/src/container.h#L53
 
Can you not quadruple post? You can use the EDIT function.

There reason why you cant move it to the container with pagination: You need the flag FLAG_NOLIMIT to move items to paginated containers. (item:moveTo uses this flag).

If you wanna add pagination to all containers you have to edit the source to always use the FLAG_NOLIMIT when a player moves an item and you can just construct with pagination set with true as default here:
forgottenserver/container.h at master · otland/forgottenserver · GitHub
Hello again Mkalo, im trying to add the FLAG_NOLIMIT only when the toCylinder get pagination true.
do you know where it is?
i do something on events onMove
but is not working good.

if item is container and size == 32 then (32 because on my tsf 32 vol= pagination true)
item moveTo
 
Last edited:
Back
Top