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

TFS 1.X+ New slot not saving items (TFS 1.2)

bizao030188

Member
Joined
Jun 4, 2012
Messages
50
Solutions
2
Reaction score
7
I've created a new slot that is working properly (I can put items marked with xml tag slotType value "order" on it) but when I logout id doesn't save the item I put there.
I will put down the code I inserted on tfs sources and on otclient lua scripts. I will appreciate if you help me figure out what I am missing.

movement.cpp:
After
C++:
        case CONST_SLOT_RING: slotp = SLOTP_RING; break;
I inserted
C++:
        case CONST_SLOT_ORDER: slotp = SLOTP_ORDER; break;
After
C++:
            } else if (tmpStr == "ammo") {
                slot = SLOTP_AMMO;
I inserted
C++:
            } else if (tmpStr == "order") { 
                slot = SLOTP_ORDER;

items.h:
After
C++:
     SLOTP_TWO_HAND = 1 << 11,
I added
C++:
    SLOTP_ORDER = 1 << 12,

items.cpp:
After
C++:
            } else if (tmpStrValue == "hand") {
                it.slotPosition |= SLOTP_HAND;
I added
C++:
             } else if (tmpStrValue == "order") { 
                it.slotPosition |= SLOTP_ORDER;

enums.h:
After
C++:
     CONDITIONID_AMMO,
I added
C++:
     CONDITIONID_ORDER,

creature.h:
After
C++:
    CONST_SLOT_AMMO = 10,
Added
C++:
    CONST_SLOT_ORDER = 11,
and changed to:
C++:
     CONST_SLOT_LAST = CONST_SLOT_ORDER,

player.cpp:
After
C++:
(slotPosition & SLOTP_FEET) ||
Added
C++:
(slotPosition & SLOTP_ORDER) ||

After
C++:
        case CONST_SLOT_AMMO: {
            if ((slotPosition & SLOTP_AMMO) || g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
                ret = RETURNVALUE_NOERROR;
            }
            break;
        }
Added
C++:
        case CONST_SLOT_ORDER: { 
            if (slotPosition & SLOTP_ORDER) {
                ret = RETURNVALUE_NOERROR;
            }
            break;
        }

protocalgame.cpp
After
C++:
sendInventoryItem(CONST_SLOT_AMMO, player->getInventoryItem(CONST_SLOT_AMMO));
Added
C++:
sendInventoryItem(CONST_SLOT_ORDER, player->getInventoryItem(CONST_SLOT_ORDER));

luascript.cpp
After
C++:
registerEnum(SLOTP_TWO_HAND)
Added
C++:
registerEnum(SLOTP_ORDER)

After
C++:
registerEnum(CONDITIONID_AMMO)
Added
C++:
registerEnum(CONDITIONID_ORDER)

After
C++:
registerEnum(CONST_SLOT_AMMO)
Added
C++:
registerEnum(CONST_SLOT_ORDER)

TFS data/lib/core/itemtype.lua:
After
C++:
[CONST_SLOT_AMMO] = SLOTP_AMMO,
Added
C++:
[CONST_SLOT_ORDER] = SLOTP_ORDER

otclient modules/gameinventory/inventory.lua:
After
C++:
[InventorySlotAmmo] = "AmmoSlot",
Added
C++:
[InventorySlotOrder] = "OrderSlot",

modules/game_inventory/inventory.otui
Added
C++:
OrderSlot < InventoryItem
  id: slot11
  image-source: /images/game/slots/right-hand
  &position: {x=65535, y=11, z=0}
  $on:
    image-source: /images/game/slots/right-hand-blessed

    OrderSlot
      anchors.top: parent.bottom
      anchors.horizontalCenter: parent.horizontalCenter
      margin-top: 3

modules/gamelib/player.lua
After
C++:
InventorySlotAmmo = 10
Added
C++:
InventorySlotOrder = 11

Thanks in advance!
 
Solution
You miss the part at iologindata.cpp
in
Code:
bool IOLoginData::loadPlayer(Player* player, DBResult_ptr result)
Code:
if (pid >= 1 && pid <= 10) {
to:
Code:
if (pid >= 1 && pid <= 11) {
and in
Code:
bool IOLoginData::savePlayer(Player* player)
Code:
for (int32_t slotId = 1; slotId <= 10; ++slotId) {
to:
Code:
for (int32_t slotId = 1; slotId <= 11; ++slotId) {
should be working now.
You miss the part at iologindata.cpp
in
Code:
bool IOLoginData::loadPlayer(Player* player, DBResult_ptr result)
Code:
if (pid >= 1 && pid <= 10) {
to:
Code:
if (pid >= 1 && pid <= 11) {
and in
Code:
bool IOLoginData::savePlayer(Player* player)
Code:
for (int32_t slotId = 1; slotId <= 10; ++slotId) {
to:
Code:
for (int32_t slotId = 1; slotId <= 11; ++slotId) {
should be working now.
 
Solution
You miss the part at iologindata.cpp
in
Code:
bool IOLoginData::loadPlayer(Player* player, DBResult_ptr result)
Code:
if (pid >= 1 && pid <= 10) {
to:
Code:
if (pid >= 1 && pid <= 11) {
and in
Code:
bool IOLoginData::savePlayer(Player* player)
Code:
for (int32_t slotId = 1; slotId <= 10; ++slotId) {
to:
Code:
for (int32_t slotId = 1; slotId <= 11; ++slotId) {
should be working now.

Hi @Evil Hero thanks for your answer. Now the item is being saved at player_items table in mysql but still not being loaded.

The pid is also correct since I got this
Code:
player_id pid sid itemtype count attributes
3 11 105 2270 1 [BLOB - 2 Bytes]
 
@Evil Hero anything else that I could try?
Thanks

If I create the item marked with "order" slot using /i command it goes directly to the right slot. Can't understand why it is not being loaded.

--Edit

Got it!
I had also to change player.cpp:
Code:
void Player::internalAddThing(uint32_t index, Thing* thing)
if (index > 0 && index < 12)
 
Last edited:
Back
Top