Advertisement
johnlol

mass_seller

May 22nd, 2019
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //===== rAthena Script =======================================
  2. //= Mass Seller
  3. //===== By ===================================================
  4. //= llchrisll
  5. //===== Version ==============================================
  6. //= 1.0 - Initial Version
  7. //= 1.1 - Added the feature to ignore items which aren't worth anything
  8. //      - Moved the sell part a bit below
  9. //      - Fixed an missing right curly in "Sell Items" case
  10. //===== Tested With ==========================================
  11. //= rAthena 10/10/2018 Revision
  12. //= GIT Hash: 55acdb9863382d8935d9df25e1462d5d1ebd7d54
  13. //===== Description ==========================================
  14. //= This NPC can sell every item in your inventory at once.
  15. //  But you can use an exception list to let it ignore certain items
  16. //  like Arrows, Potions and more.
  17. //= The Price is always the value which you would get if you would sell
  18. //  the items at an normal NPC.
  19. //===== Comments =============================================
  20. //= ...
  21. //============================================================
  22. sec_in02,143,153,2  script  Mass Seller 100,{
  23.  
  24. mes .n$;
  25. mes "Welcome, "+strcharinfo(0)+"!";
  26. mes "How can I help you?";
  27. next;
  28. switch(select("- Sell Items:- Personal Config:- Leave")) {
  29.  
  30.     case 1:
  31.     mes .n$;
  32.     if(!getarraysize(MS_Types)) {
  33.         mes "If this is your first time using my service, I would recommend you setup your personal config before proceeding.";
  34.         mes "Otherwise I will sell every Item in your Inventory, except Refined Equipment and Equipment with Cards and Items which are not anything of worth.";
  35.         mes " ";
  36.     } else {
  37.         mes "Here is the current list of your ignored items:";
  38.             for ( set .@p,0; .@p < getarraysize(MS_Types); set .@p,.@p + 1)
  39.                 for ( set .@q,0; .@q < getarraysize(.itemtypesid); set .@q,.@q + 1)
  40.                     if(MS_Types[.@p] == .itemtypesid[.@q])
  41.                         mes " > "+.itemtypestxt$[.@q];
  42.     }
  43.     next;
  44.     if(select("- Continue:- Leave") - 1) close;
  45.     getinventorylist;
  46.     for ( set .@i,0; .@i < @inventorylist_count; set .@i,.@i + 1) {
  47.         set .@e,0;
  48.         // Skip Equipment which are/have:
  49.         // > Equipped
  50.         if(@inventorylist_equip[.@i] != 0) continue;
  51.         // > Refined
  52.         if(@inventorylist_refine[.@i] != 0) continue;
  53.         /// > Cards/Enchantments
  54.         if(@inventorylist_card1[.@i] != 0) continue;
  55.         if(@inventorylist_card2[.@i] != 0) continue;
  56.         if(@inventorylist_card3[.@i] != 0) continue;
  57.         if(@inventorylist_card4[.@i] != 0) continue;
  58.         // > No Sell Price
  59.         if(getiteminfo(@inventorylist_id[.@i],1) == 0) continue;
  60.         // Check if the Item Type is in the ignore list
  61.         for ( set .@l,0; .@l < getarraysize(MS_Types); set .@l,.@l + 1)
  62.             if(getiteminfo(@inventorylist_id[.@i],2) == (MS_Types[.@l]-1) ) {
  63.                 set .@e,1;
  64.                 break;
  65.             }
  66.         // Check if the selected item id was already mentioned for having more of the same than once
  67.         for ( set .@d,0; .@d < getarraysize(.@dup_item); set .@d,.@d + 1)
  68.             if(@inventorylist_id[.@i] == .@dup_item[.@d]) {
  69.                 set .@e,1;
  70.                 break;
  71.             }
  72.         if(.@e) continue;
  73.        
  74.         // Checking if an item is equipped while you have multiply items of it in your inventory,
  75.         // preventing it of selling accidently
  76.         for ( set .@t,0; .@t < 20; set .@t,.@t + 1)
  77.             if(getequipid(.@t) == @inventorylist_id[.@i]) {
  78.                 message strcharinfo(0),.n$+": You have the following item equipped and in your inventory, which I will not sell: "+countitem(@inventorylist_id[.@i])+"x "+getitemname(@inventorylist_id[.@i])+"!";
  79.                 setarray .@dup_item[getarraysize(.@dup_item)],@inventorylist_id[.@i];
  80.                 set .@e,1;
  81.                 break;
  82.             }
  83.         if(.@e) continue;
  84.         setarray .@sellid[getarraysize(.@sellid)],@inventorylist_id[.@i];
  85.     }
  86.     mes .n$;
  87.     if(getarraysize(.@sellid) > 0) {
  88.         for ( set .@s,0; .@s < getarraysize(.@sellid); set .@s,.@s + 1) {
  89.             set .@total,.@total + (getiteminfo(.@sellid[.@s],1)*countitem(.@sellid[.@s]));
  90.             delitem2 .@sellid[.@s],countitem(.@sellid[.@s]),1,0,0,0,0,0,0;
  91.         }
  92.         mes "Your items were sold and you recieved "+.@total+" Zeny.";
  93.         set Zeny,Zeny + .@total;
  94.     } else
  95.         mes "No Items were sold, therefore you don't recieve any Zeny.";
  96.     break;
  97.  
  98.     case 2:
  99.     mes .n$;
  100.     if(!getarraysize(MS_Types))
  101.         mes "You didn't add anything to your list yet.";
  102.     else {
  103.         mes "This are your current Item Types:";
  104.         for ( set .@p,0; .@p < getarraysize(MS_Types); set .@p,.@p + 1)
  105.             for ( set .@q,0; .@q < getarraysize(.itemtypesid); set .@q,.@q + 1)
  106.                 if(MS_Types[.@p] == .itemtypesid[.@q])
  107.                     mes "- "+.itemtypestxt$[.@q];
  108.     }
  109.     mes " ";
  110.     mes "What do you want to do?";
  111.     next;
  112.     if(select("- Add Item Type:- Remove Item Type") == 1) {
  113.         mes .n$;
  114.         mes "Please choose which Item Type you want to add to your list:";
  115.         for ( set .@l,0; .@l < getarraysize(.itemtypestxt$); set .@l,.@l + 1)
  116.             set .@ms_list$,.@ms_list$ + "- "+.itemtypestxt$[.@l] + ( (.itemtypestxt$[.@l+1] != "")?":":"");
  117.        
  118.         set .@it,select(.@ms_list$) - 1;
  119.         next;
  120.         mes .n$;
  121.         for ( set .@p,0; .@p < getarraysize(MS_Types); set .@p,.@p + 1)
  122.             if(.@it == MS_Types[.@p]) {
  123.                 mes "This Item Type is already included in your list. Please choose a different one.";
  124.                 close;
  125.             }
  126.         mes "The Item Type \""+.itemtypestxt$[.@it]+"\" has been added.";
  127.         setarray MS_Types[getarraysize(MS_Types)],.itemtypesid[.@it];
  128.     } else {
  129.         mes .n$;
  130.         if(!getarraysize(MS_Types)) {
  131.             mes "I'm sorry, but there is nothing to remove.";
  132.             close;
  133.         }
  134.         mes "Please choose which Item Type you want to remove from your list:";
  135.         for ( set .@p,0; .@p < getarraysize(MS_Types); set .@p,.@p + 1)
  136.             for ( set .@q,0; .@q < getarraysize(.itemtypesid); set .@q,.@q + 1)
  137.                 if(MS_Types[.@p] == .itemtypesid[.@q])
  138.                     set .@ms_list$,.@ms_list$ + "- "+.itemtypestxt$[.@q] + ( (MS_Types[.@p+1] != 0)?":":"");
  139.         next;
  140.         set .@it,select(.@ms_list$) - 1;
  141.         mes .n$;
  142.         for ( set .@p,0; .@p < getarraysize(MS_Types); set .@p,.@p + 1)
  143.             for ( set .@q,0; .@q < getarraysize(.itemtypesid); set .@q,.@q + 1)
  144.                 if(MS_Types[.@it] == .itemtypesid[.@q]) {
  145.                     mes "The Item Type \""+.itemtypestxt$[.@q]+"\" has been removed.";
  146.                     deletearray MS_Types[.@it],1;
  147.                     end;
  148.                 }
  149.     }
  150.     break;
  151.    
  152.     case 3:
  153.     break;
  154. }
  155. end;
  156.    
  157.  
  158. OnInit:
  159. set .n$,"["+strnpcinfo(0)+"]";
  160. setarray .itemtypestxt$[0],"Healing","Usable","Equipment","Weapon","Card","Pet Egg","Pet Equipment","Ammuntion","Usable with delay","Shadow Equipment","Usable with confirmation";
  161. setarray .itemtypesid[0],1,3,5,6,7,8,9,11,12,13,19;
  162. end;
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement