And this si my events/player.h onMoveItemfunction us_onMoveItem(player, item, fromPosition, toPosition)
if not item:getType():isUpgradable() or toPosition.y == CONST_SLOT_AMMO then
return true
end
if not item:getType():usesSlot(toPosition.y) then
return true
end
if item:isUnidentified() then
if toPosition.y <= CONST_SLOT_AMMO and toPosition.y ~= CONST_SLOT_BACKPACK then
--player:sendTextMessage(MESSAGE_STATUS_SMALL, "You can't wear unidentified items.")
player:say("You can't wear unidentified items!", TALKTYPE_MONSTER_SAY)
return false
end
end
if US_CONFIG.REQUIRE_LEVEL == true then
if player:getLevel() < item:getItemLevel() and not item:isLimitless() then
if toPosition.y <= CONST_SLOT_AMMO and toPosition.y ~= CONST_SLOT_BACKPACK then
--player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need higher level to equip that item.")
player:say("Need higher level!", TALKTYPE_MONSTER_SAY)
return false
end
end
end
if toPosition.y <= CONST_SLOT_AMMO then
if toPosition.y ~= CONST_SLOT_BACKPACK then
if fromPosition.y >= 64 or fromPosition.x ~= CONTAINER_POSITION then
-- remove old
local oldItem = player:getSlotItem(toPosition.y)
if oldItem then
if oldItem:getType():isUpgradable() then
local oldBonuses = oldItem:getBonusAttributes()
if oldBonuses then
for key, value in pairs(oldBonuses) do
local attr = US_ENCHANTMENTS[value[1]]
if attr then
if attr.combatType == US_TYPES.CONDITION then
if US_CONDITIONS[value[1]] and US_CONDITIONS[value[1]][value[2]] then
if US_CONDITIONS[value[1]][value[2]]:getType() ~= CONDITION_MANASHIELD then
player:removeCondition(
US_CONDITIONS[value[1]][value[2]]:getType(),
CONDITIONID_COMBAT,
US_CONDITIONS[value[1]][value[2]]:getSubId()
)
else
player:removeCondition(US_CONDITIONS[value[1]][value[2]]:getType(), CONDITIONID_COMBAT)
end
end
end
end
end
end
end
end
-- apply new
if item:getType():isUpgradable() then
local newBonuses = item:getBonusAttributes()
if newBonuses then
for key, value in pairs(newBonuses) do
local attr = US_ENCHANTMENTS[value[1]]
if attr then
if attr.combatType == US_TYPES.CONDITION then
if not US_CONDITIONS[value[1]] then
US_CONDITIONS[value[1]] = {}
end
if not US_CONDITIONS[value[1]][value[2]] then
US_CONDITIONS[value[1]][value[2]] = Condition(attr.condition)
if attr.condition ~= CONDITION_MANASHIELD then
US_CONDITIONS[value[1]][value[2]]:setParameter(attr.param, attr.percentage == true and 100 + value[2] or value[2])
US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_TICKS, -1)
US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_SUBID, 1000 + math.ceil(value[1] ^ 2) + value[2])
else
US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_TICKS, 86400000)
end
US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
player:addCondition(US_CONDITIONS[value[1]][value[2]])
if attr == BONUS_TYPE_MAXHP then
if player:getHealth() == maxHP then
player:addHealth(player:getMaxHealth())
end
end
if attr == BONUS_TYPE_MAXMP then
if player:getMana() == maxMP then
player:addMana(player:getMaxMana())
end
end
else
player:addCondition(US_CONDITIONS[value[1]][value[2]])
if attr.param == CONDITION_PARAM_STAT_MAXHITPOINTS then
if player:getHealth() == maxHP then
player:addHealth(player:getMaxHealth())
end
end
if attr.param == CONDITION_PARAM_STAT_MAXMANAPOINTS then
if player:getMana() == maxMP then
player:addMana(player:getMaxMana())
end
end
end
end
end
end
end
end
end
end
end
return true
end
function PlayernMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if item:getActionId() == CURSED_CHESTS_AID then return false end
if toPosition.x ~= CONTAINER_POSITION then
return true
end
if item:getTopParent() == self and bit.band(toPosition.y, 0x40) == 0 then
local itemType, moveItem = ItemType(item:getId())
if bit.band(itemType:getSlotPosition(), SLOTP_TWO_HAND) ~= 0 and toPosition.y == CONST_SLOT_LEFT then
moveItem = self:getSlotItem(CONST_SLOT_RIGHT)
elseif itemType:getWeaponType() == WEAPON_SHIELD and toPosition.y == CONST_SLOT_RIGHT then
moveItem = self:getSlotItem(CONST_SLOT_LEFT)
if moveItem and bit.band(ItemType(moveItem:getId()):getSlotPosition(), SLOTP_TWO_HAND) == 0 then
return true
end
end
if moveItem then
local parent = item:getParent()
if parent:isContainer() and parent:getSize() == parent:getCapacity() then
self:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_CONTAINERNOTENOUGHROOM))
return false
else
return moveItem:moveTo(parent)
end
end
end
return us_onMoveItem(self, item, fromPosition, toPosition)
end
that is how it works on rl tibiafrom ground
Its possible block equip items from ground?that is how it works on rl tibia
const Cylinder* cylinder = item->getTopParent();
if (cylinder && (dynamic_cast<const DepotChest*>(cylinder) || dynamic_cast<const Player*>(cylinder)))
return RETURNVALUE_NOTENOUGHROOM;
I tested later. ThanksHere
Remove those then recompile and it will work like you want.forgottenserver/src/player.cpp at master · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
C++:const Cylinder* cylinder = item->getTopParent(); if (cylinder && (dynamic_cast<const DepotChest*>(cylinder) || dynamic_cast<const Player*>(cylinder))) return RETURNVALUE_NOTENOUGHROOM;
If it's so simple, then why wont you write it?bump
Post automatically merged:
Simple script if item is on ground cant equip in slots
if i have knowledge of CO ++ it's simple but i dont.If it's so simple, then why wont you write it?
Nope. Not work.Here
Remove those then recompile and it will work like you want.forgottenserver/src/player.cpp at master · otland/forgottenserver
A free and open-source MMORPG server emulator written in C++ - otland/forgottenservergithub.com
C++:const Cylinder* cylinder = item->getTopParent(); if (cylinder && (dynamic_cast<const DepotChest*>(cylinder) || dynamic_cast<const Player*>(cylinder))) return RETURNVALUE_NOTENOUGHROOM;
Can you tell, how you managed to make it work like this ?No, It works, This is TFS 1.3 I am testing on it's same code as yours and had same issue the only difference is it's a downgrade.
View attachment 52170
player.cpp
//need an exchange with source? (destination item is swapped with currently moved item)
const Item* inventoryItem = getInventoryItem(static_cast<slots_t>(index));
if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->getID() != item->getID())) {
const Cylinder* cylinder = item->getTopParent();
if (cylinder && (dynamic_cast<const DepotChest*>(cylinder) || dynamic_cast<const Player*>(cylinder))) {
return RETURNVALUE_NEEDEXCHANGE;
}
return RETURNVALUE_NOTENOUGHROOM;
}
return ret;
}
//need an exchange with source? (destination item is swapped with currently moved item)
const Item* inventoryItem = getInventoryItem(static_cast<slots_t>(index));
if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->getID() != item->getID())) {
return RETURNVALUE_NEEDEXCHANGE;
}
return ret;
}
Was looking for this, thanks. How too add a bool to read config.lua so if it has classicequpmentslot turned on it would work with the new config? To not delete codeAs I mentioned, I only changed this inplayer.cpp
to thisC++://need an exchange with source? (destination item is swapped with currently moved item) const Item* inventoryItem = getInventoryItem(static_cast<slots_t>(index)); if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->getID() != item->getID())) { const Cylinder* cylinder = item->getTopParent(); if (cylinder && (dynamic_cast<const DepotChest*>(cylinder) || dynamic_cast<const Player*>(cylinder))) { return RETURNVALUE_NEEDEXCHANGE; } return RETURNVALUE_NOTENOUGHROOM; } return ret; }
C++://need an exchange with source? (destination item is swapped with currently moved item) const Item* inventoryItem = getInventoryItem(static_cast<slots_t>(index)); if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->getID() != item->getID())) { return RETURNVALUE_NEEDEXCHANGE; } return ret; }
//need an exchange with source? (destination item is swapped with currently moved item)
const Item* inventoryItem = getInventoryItem(static_cast<slots_t>(index));
if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->getID() != item->getID())) {
if (!g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) {
const Cylinder* cylinder = item->getTopParent();
if (cylinder && (dynamic_cast<const DepotChest*>(cylinder) || dynamic_cast<const Player*>(cylinder))) {
return RETURNVALUE_NEEDEXCHANGE;
}
return RETURNVALUE_NOTENOUGHROOM;
}
return RETURNVALUE_NEEDEXCHANGE;
}
return ret;
}
Thank gonna test later but I'm sure it's working, thanks againThis should work
C++://need an exchange with source? (destination item is swapped with currently moved item) const Item* inventoryItem = getInventoryItem(static_cast<slots_t>(index)); if (inventoryItem && (!inventoryItem->isStackable() || inventoryItem->getID() != item->getID())) { if (!g_config.getBoolean(ConfigManager::CLASSIC_EQUIPMENT_SLOTS)) { const Cylinder* cylinder = item->getTopParent(); if (cylinder && (dynamic_cast<const DepotChest*>(cylinder) || dynamic_cast<const Player*>(cylinder))) { return RETURNVALUE_NEEDEXCHANGE; } return RETURNVALUE_NOTENOUGHROOM; } return RETURNVALUE_NEEDEXCHANGE; } return ret; }