Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
- local amount = amount or 1
- local subType = subType or 1
- local ignoreCap = ignoreCap and true or false
- local item = 0
- if(isItemStackable(itemid)) then
- if(isItemRune(itemid)) then
- amount = amount * subType
- end
- local count = amount
- repeat
- item = doCreateItemEx(itemid, math.min(100, count))
- if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
- return 0, 0
- end
- count = count - math.min(100, count)
- until count == 0
- return amount, 0
- end
- local a = 0
- if(inBackpacks) then
- local container = doCreateItemEx(backpack, 1)
- local b = 1
- for i = 1, amount do
- item = doAddContainerItem(container, itemid, subType)
- if(itemid == ITEM_PARCEL) then
- doAddContainerItem(item, ITEM_LABEL)
- end
- if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then
- if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
- b = b - 1
- break
- end
- a = i
- if(amount > i) then
- container = doCreateItemEx(backpack, 1)
- b = b + 1
- end
- end
- end
- return a, b
- end
- for i = 1, amount do
- item = doCreateItemEx(itemid, subType)
- if(itemid == ITEM_PARCEL) then
- doAddContainerItem(item, ITEM_LABEL)
- end
- if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
- break
- end
- a = i
- end
- return a, 0
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement