Code:function onMove(params, go hear) maxuid = 5000 -- change with max uid of items (can't be infinite, uids are in use for players, creatures, items, npcs, etc) if(item.uid > 0 and item.uid < maxuid) then return true end return false end
function getItemsInContainerById(container, itemid) -- Function By Kydrai
local items = {}
if isContainer(container) and getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag)
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end
function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
if isContainer(item.uid) then
local itemid = 2531 --- isso eh o id do unique item
local a = getItemsInContainerById(item.uid, itemid)
for _, uid in pairs(a) do
if uid then
if (status.inInv == 0 and status.inInvBag == 3 and status.inDepot == 3) or (status.inDepot == 0 and status.inInv == 3 and status.inInvBag == 3 ) or (status.inInvBag == 0 and status.inDepot == 3 and status.inInv == 3) then
doPlayerSendCancel(cid, "You Can't drop this bag, Have a unique item.")
return false
end
end
end
return true
end
return true
end
function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
local hid = getHouseFromPos(toPosition)
if hid == false then
return true
end
-- If you are the owner
if getHouseOwner(hid) == getPlayerGUID(cid) then
doPlayerSendCancel(cid, "OWNER: OK.")
return true
end
-- If you are a guest, allow:
local me = getCreatureName(cid):lower()
for _, name in ipairs(getHouseAccessList(hid, 0x100):explode("\n")) do
if me == name:lower() then
doPlayerSendCancel(cid, "GUEST: OK.")
return true -- Allow movement
end
end
-- If you are a sub-owner, allow:
local me = getCreatureName(cid):lower()
for _, name in ipairs(getHouseAccessList(hid, 0x101):explode("\n")) do
if me == name:lower() then
doPlayerSendCancel(cid, "SUB-OWNER: OK.")
return true -- Allow movement
end
end
-- Else return false
doPlayerSendCancel(cid, "You are not allowed to do that in this house.")
return false
end
function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
-- Fetching house id, if toposition is not a house allow movement
local hid = getHouseFromPos(toPosition)
if hid == false then
return true
end
doPlayerSendTextMessage(cid, 13, "1. toPosition is inside a house!")
-- If you are the owner
if getHouseOwner(hid) == getPlayerGUID(cid) then
doPlayerSendTextMessage(cid, 13, "2. You got full access as owner of the house to move stuff!")
return true
end
-- If you are a guest, allow:
local me = getCreatureName(cid):lower()
for _, name in ipairs(getHouseAccessList(hid, 0x100):explode("\n")) do
if me == name:lower() then
doPlayerSendTextMessage(cid, 13, "3. You are recognized as a guest!")
-- ------------------------ --
-- MOVE ITEM FROM CONTAINER --
-- ------------------------ --
if fromItem.itemid then
doPlayerSendTextMessage(cid, 13, "4. fromItem.uid exist!")
if isContainer(fromItem.uid) then
doPlayerSendTextMessage(cid, 13, "5. fromItem recognized movement from container!")
-- If item you moved to is a slot in character:
if status.inInv >= 1 or status.inInvBag >= 1 and status.inInv == 0 or status.inInvBag == 0 and status.inInv >= 1 then
doPlayerSendTextMessage(cid, 13, "6. You moved something to your inventory!")
return true
end
--If you moved item to container:
if toItem.itemid then
if isContainer(toItem.uid) then
doPlayerSendTextMessage(cid, 13, "6. You moved something between containers in house!")
return true
end
end
end
-- ---------------------- --
-- MOVE ITEM TO CONTAINER --
-- ---------------------- --
elseif toItem.itemid then
if isContainer(toItem.uid) then
-- If you move item to container from container
if isContainer(fromItem.uid) then
return true
-- If you move item to container from inventory
elseif status.inInvBag == 0 then
return true
end
end
end
end
end
-- If you are a sub-owner, allow:
local me = getCreatureName(cid):lower()
for _, name in ipairs(getHouseAccessList(hid, 0x101):explode("\n")) do
if me == name:lower() then
doPlayerSendCancel(cid, "SUB-OWNER: OK.")
return true -- Allow movement
end
end
-- Else return false (deny movement?)
doPlayerSendCancel(cid, "You are not ALLOWED to do that.")
return false
end
function isGuest(cid,house)
for _, name in ipairs(getHouseAccessList(house, 0x100):explode("\n")) do
if getCreatureName(cid):lower() == name:lower() then
return true
end
end
return false
end
function isSubOwner(cid,house)
for _, name in ipairs(getHouseAccessList(house, 0x101):explode("\n")) do
if getCreatureName(cid):lower() == name:lower() then
return true
end
end
return false
end
function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
local house = getHouseFromPos(toPosition)
if not house then
return true
end
if getHouseOwner(house) == getPlayerGUID(cid) or isSubOwner(cid,house) then
return true
end
if not isGuest(cid,house) then
doPlayerSendCancel(cid,"Sorry, You can't move items in this house.")
return false
end
if (status.inInv == 0 and status.inInvBag == 3 and status.inDepot == 3) or
(status.inDepot == 0 and status.inInv == 3 and status.inInvBag == 3 ) or
(status.inInvBag == 0 and status.inDepot == 3 and status.inInv == 3) then
if not isContainer(toItem.uid) then
doPlayerSendCancel(cid,"Sorry, guests only have capability of (adding/taking) items (to/from) house containers.")
return false
end
elseif (status.inInv == 3 and status.inInvBag == 3 and status.inDepot == 3) then
if isContainer(fromItem.uid) and isContainer(toItem.uid) then
return true
end
doPlayerSendCancel(cid,"Sorry, guests only have capability of (adding/taking) items (to/from) house containers.")
return false
end
return true
end
Update : Another Critical crash fix, please you are required to update.
- - - Updated - - -
@Znote, try this
Lua:function isGuest(cid,house) for _, name in ipairs(getHouseAccessList(house, 0x100):explode("\n")) do if getCreatureName(cid):lower() == name:lower() then return true end end return false end function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status) local house = getHouseFromPos(toPosition) if not house then return true end if getHouseOwner(house) == getPlayerGUID(cid) then return true end if not isGuest(cid,house) then doPlayerSendCancel(cid,"Sorry, You can't move items in this house.") return false end if (status.inInv == 0 and status.inInvBag == 3 and status.inDepot == 3) or (status.inDepot == 0 and status.inInv == 3 and status.inInvBag == 3 ) or (status.inInvBag == 0 and status.inDepot == 3 and status.inInv == 3) then if not isContainer(toItem.uid) then doPlayerSendCancel(cid,"Sorry, guests only have capability of (adding/taking) items (to/from) house containers.") return false end elseif (status.inInv == 3 and status.inInvBag == 3 and status.inDepot == 3) then if isContainer(fromItem.uid) and isContainer(toItem.uid) then return true end doPlayerSendCancel(cid,"Sorry, guests only have capability of (adding/taking) items (to/from) house containers.") return false end return true end
I still dont get it what u want ?!! this is a creature script function that is executed every time player move a thing , you do the checks if you dont want a bag to be moved that has a special items, my example in main thread was just a simple one!
--$$ Undropable Items $$--
local items = {2222} -- item ids that is undropable
--[[ Script]]--
function searchContainers(uid,itemss)
local items = itemss
local containers = {}
local check = false
for i = 0, getContainerSize(uid)-1 do
local item = getContainerItem(uid,i)
if not isContainer(item.uid) then
if isInArray(items,item.itemid) then
check = true
end
else
table.insert(containers,item.uid)
end
end
for _, container in ipairs(containers) do
if searchContainers(container,items) then
check = true
break
end
end
return check
end
function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
if status.inInv == 1 and status.inInvBag == 3 and status.inDepot == 3 and isInArray(items,getPlayerSlotItem(cid,status.slot).itemid ) then
doPlayerSendCancel(cid,"You can't drop a special item on the ground.")
doSendMagicEffect(getThingPos(cid),2)
return false
end
if (status.inInv == 0 and status.inInvBag == 3 and status.inDepot == 3) or
(status.inDepot == 0 and status.inInv == 3 and status.inInvBag == 3 ) or
(status.inInvBag == 0 and status.inDepot == 3 and status.inInv == 3) then
if not isContainer(item.uid) then
if isInArray(items,item.itemid) then
doPlayerSendCancel(cid,"You can't drop a special item on the ground.")
doSendMagicEffect(getThingPos(cid),2)
return false
end
else
if searchContainers(item.uid,items) then
doPlayerSendCancel(cid,"You can't throw this bag that contains special item[s] on ground")
doSendMagicEffect(getThingPos(cid),2)
return false
end
end
end
return true
end