Guest User

Untitled

a guest
May 27th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. use uo;
  2.  
  3. include ":containers:storageAreas";
  4.  
  5. CONST CPM_FORSALE := "Merchant-ForSale";
  6. CONST CPM_BUYING := "Merchant-Buying";
  7. CONST CPM_SHOPPINGCART := "Merchant-ShoppingCart";
  8. CONST CPM_HOLDING := "Merchant-Holding";
  9.  
  10. /*
  11. * NPC_MerchantForSaleContainer(npc)
  12. *
  13. * Purpose
  14. *
  15. * Parameters
  16. * npc:
  17. *
  18. * Return value
  19. * Returns a container
  20. *
  21. */
  22. function CPM_DeleteContainers(npc)
  23. var container_id := CP_GetMobileContainerID(npc);
  24. var area_names := array{CPM_FORSALE, CPM_BUYING, CPM_SHOPPINGCART, CPM_HOLDING};
  25. foreach area_name in ( area_names )
  26. if ( GetObjProperty(npc, "Shared-"+area_name) )
  27. // Dont want to delete shared storage areas.
  28. continue;
  29. elseif ( CP_GetStorageAreaContainer(container_id, area_name) )
  30. CP_RemoveStorageAreaContainer(container_id, area_name);
  31. endif
  32. SleepMS(2);
  33. endforeach
  34.  
  35. return 1;
  36. endfunction
  37.  
  38. /*
  39. * CPM_GetMerchantContainer(npc, type)
  40. *
  41. * Purpose
  42. * Retrieves a merchant (vendor) container.
  43. *
  44. * Parameters
  45. * npc: NPC that owns the container.
  46. * type: Storage area to retrieve the container from.
  47. * CPM_FORSALE - Items the vendor is selling.
  48. * CPM_BUYING - Items the vendor will buy.
  49. * CPM_SHOPPINGCART - Items a buyer has selected (but not paid for).
  50. * CPM_HOLDING - Items the vendor is holding onto for its owner.
  51. *
  52. * Return value
  53. * Returns a container
  54. *
  55. */
  56. function CPM_GetMerchantContainer(npc, type, create:=CP_NOCREATE)
  57. var shared_container := GetObjProperty(npc, "Shared-"+type);
  58. if ( shared_container && type != CPM_SHOPPINGCART )
  59. //Note: The 'Shopping cart' container can never be shared between multiple merchants!
  60. return CP_GetStorageAreaContainer(shared_container, type, create);
  61. else
  62. return CP_GetStorageContainerForMobile(npc, type, create);
  63. endif
  64. endfunction
Add Comment
Please, Sign In to add comment