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

Limit Slots C++ TFS 1.4.2 / Otcv8

alejandro762

Well-Known Member
Joined
Sep 6, 2021
Messages
242
Reaction score
68
I started to see if there is possible to add many slots on client and TFS.

Got working all slots till number 15, above on Slot number 16, i see on visual says:

C++ enum SlotPositionBits::SLOTP_SLOT16 = 65536U

I see on OTC: &position: {x=65535, y=16, z=0}


Is there the 65536, the same as 65535 , so the cap is 15 slots on client side ?
There is a possibility to go higher?

Client returns: Cannot dress this object here

Since cannot equip any item on slot16, slot17, slot18...

Slot add with this script: TFS 1.X+ - Help new inventory slot TFS 1.3 and OTClient (https://otland.net/threads/help-new-inventory-slot-tfs-1-3-and-otclient.264537/)
12, 13, 14, 15 works perfect, above 15 won't work TFS 1.4 using otcv8
 
Last edited:
To add prints onEquip and deEquip, while giving "You cannot dress this object here" i changed the RETURNVALUE to NOERROR, in order to equip everything, everywhere and check:
LUA:
ReturnValue MoveEvent::fireEquip(Player* player, Item* item, slots_t slot, bool isCheck)
{
    if (scripted) {
        if (!equipFunction || equipFunction(this, player, item, slot, isCheck) == RETURNVALUE_NOERROR) {
            if (executeEquip(player, item, slot, isCheck)) {
                return RETURNVALUE_NOERROR;
            }
            return RETURNVALUE_NOERROR;
        }
        return equipFunction(this, player, item, slot, isCheck);
    } else {
        return equipFunction(this, player, item, slot, isCheck);
    }
}
Code:
if ((slotPosition & SLOTP_HEAD) || (slotPosition & SLOTP_NECKLACE) ||
            (slotPosition & SLOTP_BACKPACK) || (slotPosition & SLOTP_ARMOR) ||
            (slotPosition & SLOTP_LEGS) || (slotPosition & SLOTP_FEET) ||
            (slotPosition & SLOTP_RING) || (slotPosition & SLOTP_CONTAINER) ||
            (slotPosition & SLOTP_RING2) || (slotPosition & SLOTP_ELEVATOR) ||
            (slotPosition & SLOTP_WINGS) || (slotPosition & SLOTP_OBLI)) {
        ret = RETURNVALUE_NOERROR;
    } else if (slotPosition & SLOTP_TWO_HAND) {
        ret = RETURNVALUE_PUTTHISOBJECTINBOTHHANDS;
    } else if ((slotPosition & SLOTP_RIGHT) || (slotPosition & SLOTP_LEFT)) {
        if (!g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
            ret = RETURNVALUE_CANNOTBEDRESSED;
        } else {
            ret = RETURNVALUE_PUTTHISOBJECTINYOURHAND;
        }
    }
Code:
<item id="26647" article="a" name="Obliverator">
    <attribute key="slotType" value="obli" />
    <attribute key="weight" value="1500" />
    </item>
<movevent event="Equip" itemid="26647" slot="obli" function="onEquipItem" script="onequip.lua"/>
    <movevent event="DeEquip" itemid="26647" slot="obli" function="onDeEquipItem" script="deequip.lua"/>

Prints:
Code:
function onEquip(player, item, slot, isCheck)
    if isCheck then
        return true
    end
    print("Equipping item in slot:", slot)
    return true
end
function onDeEquip(player, item, slot)
    print("De-equipping item from slot:", slot)
return true
end

Returns:
Equipping item in slot: 16
De-equipping item from slot: 16

Redo Changes back to original RETURNVALUE:
Seems the slot 16 is correct, but for some reason the CONST_SLOT_OBLI is returning RETURNVALUE_CANNOTBEDRESSED directly
 
Seems the slot 16 Is detected as "classic slot": ( But 17 .... 26 ) As i tried before also are detected as classic slot

LUA:
Cannot dress item classic in slot: 48
Cannot dress item classic in slot: 48
Cannot dress item classic in slot: 48
Cannot dress item classic in slot: 48
Cannot dress item classic in slot: 48
Cannot dress item classic in slot: 48


Code:
if ((slotPosition & SLOTP_HEAD) || (slotPosition & SLOTP_NECKLACE) ||      
(slotPosition & SLOTP_BACKPACK) || (slotPosition & SLOTP_ARMOR) ||
            (slotPosition & SLOTP_LEGS) || (slotPosition & SLOTP_FEET) ||
            (slotPosition & SLOTP_RING) || (slotPosition & SLOTP_CONTAINER) ||
            (slotPosition & SLOTP_RING2) || (slotPosition & SLOTP_ELEVATOR) ||
            (slotPosition & SLOTP_WINGS) || (slotPosition & SLOTP_OBLI))
{
        ret = RETURNVALUE_CANNOTBEDRESSED;
        std::cout << "Cannot dress item in slot: " << slotPosition << std::endl;
    } else if (slotPosition & SLOTP_TWO_HAND) {
        ret = RETURNVALUE_PUTTHISOBJECTINBOTHHANDS;
    } else if ((slotPosition & SLOTP_RIGHT) || (slotPosition & SLOTP_LEFT)) {
        if (!g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
            ret = RETURNVALUE_CANNOTBEDRESSED;

            std::cout << "Cannot dress item classic in slot: " << slotPosition << std::endl;
        } else {
            ret = RETURNVALUE_PUTTHISOBJECTINYOURHAND;
        }
    }

Code:
enum slots_t : uint8_t {
    CONST_SLOT_WHEREEVER = 0,
    CONST_SLOT_HEAD = 1,
    CONST_SLOT_NECKLACE = 2,
    CONST_SLOT_BACKPACK = 3,
    CONST_SLOT_ARMOR = 4,
    CONST_SLOT_RIGHT = 5,
    CONST_SLOT_LEFT = 6,
    CONST_SLOT_LEGS = 7,
    CONST_SLOT_FEET = 8,
    CONST_SLOT_RING = 9,
    CONST_SLOT_AMMO = 10,
    CONST_SLOT_STORE_INBOX = 11,
    CONST_SLOT_CONTAINER = 12,
    CONST_SLOT_RING2 = 13,
    CONST_SLOT_ELEVATOR = 14,
    CONST_SLOT_WINGS = 15,
    CONST_SLOT_OBLI = 16,
    CONST_SLOT_FIRST = CONST_SLOT_HEAD,
    CONST_SLOT_LAST = CONST_SLOT_OBLI,
};

if i add "classic slots" to true on config it allows to add it on Hand.


So strange
 
So i started all directly from new server 1.4: GitHub - otland/forgottenserver at 1.4 (https://github.com/otland/forgottenserver/tree/1.4)

And new client otcv8 from otacademy repository.

You can add 15 slots, on slot 16 are detected as classic slot and you cannot equip any item, seems weird.
Post automatically merged:

Item detected as Classic Slot.. Output of console: Cannot equip Classic Slot item: 48 , tried add an if statment with slotPosition and returnvalue no error, but doesn't work.


cannotbedressed.gif
 
Last edited:
Bro, its a uint8, which uint8 has a limit of 65535 just like it told you.

1 << 16 = 65536

Therefore you cannot have a value of more than 15, because those values are calculated like flags. To support more you would have to make some source edits in both the server and the client and change the uint8 to a uint16, adjusting the protocol for these changes as well ofc... but as I think about it, I believe that is also the max packet size, 65535. Which means you would need to completely change how those values are read in the client and the server, which is a massive undertaking.

1722069218799.webp
 
Last edited:
you solve this?
Doing a trick, you can go with, going to say no limit ?
The limit will be the screen you got and client view, lol.

Since you can add 200 Slots if you want, but using groups, otherwise as i already see the 65536 on Sources, you cannot go upper than change everything from client/server side.
 
@alejandro762 can you little explain how to make groups?

you mean

for example
C++:
enum slots_t : uint8_t {
    CONST_SLOT_WHEREEVER = 0,
    CONST_SLOT_HEAD = 1,
    CONST_SLOT_NECKLACE = 2,
    CONST_SLOT_BACKPACK = 3,
    CONST_SLOT_ARMOR = 4,
    CONST_SLOT_RIGHT = 5,
    CONST_SLOT_LEFT = 6,
    CONST_SLOT_LEGS = 7,
    CONST_SLOT_FEET = 8,
    CONST_SLOT_RING = 9,
    CONST_SLOT_AMMO = 10,
    CONST_SLOT_STORE_INBOX = 11,

    CONST_SLOT_FIRST = CONST_SLOT_HEAD,
    CONST_SLOT_LAST = CONST_SLOT_AMMO
};

and add
C++:
enum slots_additional_t : uint8_t {
    CONST_SLOT_WHEREEVER_1 = 1,
    CONST_SLOT_WHEREEVER_2 = 2,
    CONST_SLOT_WHEREEVER_3 = 3,
    CONST_SLOT_WHEREEVER_4 = 3,
    CONST_SLOT_WHEREEVER_5 = 4,
    CONST_SLOT_FIRST =CONST_SLOT_WHEREEVER_1,
    CONST_SLOT_LAST = CONST_SLOT_WHEREEVER_5
};
 
@alejandro762 can you little explain how to make groups?

you mean

for example
C++:
enum slots_t : uint8_t {
    CONST_SLOT_WHEREEVER = 0,
    CONST_SLOT_HEAD = 1,
    CONST_SLOT_NECKLACE = 2,
    CONST_SLOT_BACKPACK = 3,
    CONST_SLOT_ARMOR = 4,
    CONST_SLOT_RIGHT = 5,
    CONST_SLOT_LEFT = 6,
    CONST_SLOT_LEGS = 7,
    CONST_SLOT_FEET = 8,
    CONST_SLOT_RING = 9,
    CONST_SLOT_AMMO = 10,
    CONST_SLOT_STORE_INBOX = 11,

    CONST_SLOT_FIRST = CONST_SLOT_HEAD,
    CONST_SLOT_LAST = CONST_SLOT_AMMO
};

and add
C++:
enum slots_additional_t : uint8_t {
    CONST_SLOT_WHEREEVER_1 = 1,
    CONST_SLOT_WHEREEVER_2 = 2,
    CONST_SLOT_WHEREEVER_3 = 3,
    CONST_SLOT_WHEREEVER_4 = 3,
    CONST_SLOT_WHEREEVER_5 = 4,
    CONST_SLOT_FIRST =CONST_SLOT_WHEREEVER_1,
    CONST_SLOT_LAST = CONST_SLOT_WHEREEVER_5
};
Probelm is not on Slots_t
but on SlotPositionBits uint32_t.

So for example if you go to slotp_idk = 1 << 16 ( you can it's the limit)
If you wanted add more, you should add for example:

SLOTP_LEFT & SLOTP_RIGHT as a group, so you can add a shield at left or at right, and weapon at left or right, yes i know it's not the better thing, but doing groups, can make the slots go higher in numbers.

Example:

SLOTP_HAND = (SLOTP_LEFT | SLOTP_RIGHT)

And you should use SLOTP_HAND to call this new items and change completely the movement of weapons.
 
Back
Top