Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
  2. local amount = amount or 1
  3. local subType = subType or 1
  4. local ignoreCap = ignoreCap and true or false
  5.  
  6. local item = 0
  7. if(isItemStackable(itemid)) then
  8. if(isItemRune(itemid)) then
  9. amount = amount * subType
  10. end
  11.  
  12. local count = amount
  13. repeat
  14. item = doCreateItemEx(itemid, math.min(100, count))
  15. if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
  16. return 0, 0
  17. end
  18.  
  19. count = count - math.min(100, count)
  20. until count == 0
  21. return amount, 0
  22. end
  23.  
  24. local a = 0
  25. if(inBackpacks) then
  26. local container = doCreateItemEx(backpack, 1)
  27. local b = 1
  28. for i = 1, amount do
  29. item = doAddContainerItem(container, itemid, subType)
  30. if(itemid == ITEM_PARCEL) then
  31. doAddContainerItem(item, ITEM_LABEL)
  32. end
  33.  
  34. if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then
  35. if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
  36. b = b - 1
  37. break
  38. end
  39.  
  40. a = i
  41. if(amount > i) then
  42. container = doCreateItemEx(backpack, 1)
  43. b = b + 1
  44. end
  45. end
  46. end
  47.  
  48. return a, b
  49. end
  50.  
  51. for i = 1, amount do
  52. item = doCreateItemEx(itemid, subType)
  53. if(itemid == ITEM_PARCEL) then
  54. doAddContainerItem(item, ITEM_LABEL)
  55. end
  56.  
  57. if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
  58. break
  59. end
  60.  
  61. a = i
  62. end
  63.  
  64. return a, 0
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement