Advertisement
Emistry

[RO] - iRO Ben Recycle

Apr 3rd, 2019
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.72 KB | None | 0 0
  1. // https://irowiki.org/wiki/Ben_Recycle
  2.  
  3. -   shop    ben_recycle_shop#iro    -1,909:-1
  4.  
  5. prontera,161,279,4  script  Ben Recycle#iro 4_F_KAFRA1,{
  6.     function func_GetItemName;
  7.     function func_AddItem;
  8.    
  9.     mes "Hi, I can convert certain equipment into ores.";
  10.     mes "Would you give it a try?";
  11.     next;
  12.     if (select("Convert", "Information") == 2) {
  13.         for (.@i = 0; .@i < .size; .@i++) {
  14.             mes func_GetItemName(.nameid[.@i]);
  15.             if (.amount1[.@i] > 0 && .nameid1[.@i] > 0)
  16.                 mes " ~ "+F_InsertComma(.amount1[.@i])+"x "+func_GetItemName(.nameid1[.@i]);
  17.             if (.amount2[.@i] > 0 && .nameid2[.@i] > 0)
  18.                 mes " ~ "+F_InsertComma(.amount2[.@i])+"x "+func_GetItemName(.nameid2[.@i]);
  19.             mes " ";
  20.         }
  21.         next;
  22.     }
  23.     if (.shop_npc$ != "") {
  24.         mes "Place all the equipments you wish to convert into ores.";
  25.         close2;
  26.         npcshopattach .shop_npc$, 1;
  27.         callshop .shop_npc$, 2;
  28.         end;
  29.     }
  30.     else {
  31.         for (.@i = 0; .@i < .size; .@i++)
  32.             .@menu$ = .@menu$ + func_GetItemName(.nameid[.@i]) + ":";
  33.         .@i = select(.@menu$) - 1;
  34.         if (countitem(.nameid[.@i])) {
  35.             delitem .nameid[.@i], 1;
  36.             mes "Exchanged "+func_GetItemName(.nameid[.@i])+":";
  37.             if (.nameid1[.@i] > 0 && .amount1[.@i] > 0) {
  38.                 mes " ~ "+F_InsertComma(.amount1[.@i])+"x "+func_GetItemName(.nameid1[.@i]);
  39.                 getitem .nameid1[.@i], .amount1[.@i];
  40.             }
  41.             if (.nameid2[.@i] > 0 && .amount2[.@i] > 0) {
  42.                 mes " ~ "+F_InsertComma(.amount2[.@i])+"x "+func_GetItemName(.nameid2[.@i]);
  43.                 getitem .nameid2[.@i], .amount2[.@i];
  44.             }
  45.         }
  46.         else {
  47.             mes "you dont have "+func_GetItemName(.nameid[.@i]);
  48.         }
  49.     }
  50.     close;
  51.    
  52.     OnSellItem:
  53.         .@sold_nameid_size = getarraysize(@sold_nameid);
  54.         for (.@i = 0; .@i < .@sold_nameid_size && !.@fail; .@i++) {
  55.             for (.@x = 0; .@x < .size && !.@fail; .@x++) {
  56.                 if (.nameid[.@x] == @sold_nameid[.@i]) {
  57.                     if (!checkweight(.nameid1[.@x], .amount1[.@x])) {
  58.                         mes "Exchange stopped, you're overweight.";
  59.                         .@fail++;
  60.                     }
  61.                     else {
  62.                         .@total++;
  63.                         delitem2(@sold_nameid[.@i], @sold_quantity[.@i], @sold_identify[.@i], @sold_refine[.@i], @sold_attribute[.@i], @sold_card1[.@i], @sold_card2[.@i], @sold_card3[.@i], @sold_card4[.@i]);
  64.                         mes "Exchanged "+func_GetItemName(.nameid[.@x])+":";
  65.                         if (.nameid1[.@x] > 0 && .amount1[.@x] > 0) {
  66.                             mes " ~ "+F_InsertComma(.amount1[.@x])+"x "+func_GetItemName(.nameid1[.@x]);
  67.                             getitem .nameid1[.@x], .amount1[.@x];
  68.                         }
  69.                         if (.nameid2[.@x] > 0 && .amount2[.@x] > 0) {
  70.                             mes " ~ "+F_InsertComma(.amount2[.@x])+"x "+func_GetItemName(.nameid2[.@x]);
  71.                             getitem .nameid2[.@x], .amount2[.@x];
  72.                         }
  73.                         mes " ";
  74.                     }
  75.                 }
  76.             }
  77.             if (.@i && .@i % 10 == 0) sleep2 1;
  78.         }
  79.         mes "Exchanged "+.@total+" item(s).";
  80.         close2;
  81.         npcshopattach .shop_npc$, 0;
  82.         end;
  83.    
  84.     function    func_GetItemName    {
  85.         .@itemid = getarg(0, 0);
  86.         .@itemslot = getitemslots(.@itemid);
  87.         .@item_name$ = getitemname(.@itemid);
  88.         .@itemtype = getiteminfo(.@itemid, 2);
  89.         if (.@itemslot || .@itemtype == IT_WEAPON || .@itemtype == IT_ARMOR)
  90.             .@item_name$ = .@item_name$ + " ["+.@itemslot+"]";
  91.         return .@item_name$;
  92.     }
  93.    
  94.     function    func_AddItem    {
  95.         .@nameid = getarg(0, 0);
  96.         .@nameid1 = getarg(1, 0);
  97.         .@amount1 = getarg(2, 0);
  98.         .@nameid2 = getarg(3, 0);
  99.         .@amount2 = getarg(4, 0);
  100.        
  101.         if (.@nameid > 0
  102.             && .@nameid1 > 0 && .@amount1 > 0
  103.             && .@nameid2 > 0 && .@amount2 > 0
  104.         ) {
  105.             .nameid[.size] = .@nameid;
  106.             .nameid1[.size] = .@nameid1;
  107.             .amount1[.size] = .@amount1;
  108.             .nameid2[.size] = .@nameid2;
  109.             .amount2[.size] = .@amount2;
  110.             .size++;
  111.         }
  112.     }
  113.    
  114.     OnInit:
  115.         // if enable shop UI (only work if items can sell to npc shop)
  116.         .shop_npc$ = "ben_recycle_shop#iro";
  117.        
  118.         // func_AddItem(<equipment_id>, <item1>, <amount1>, <item2>, <amount2>);
  119.        
  120.         // WEAPONS
  121.         func_AddItem(1421, 757, 4, 756, 4);
  122.         func_AddItem(1822, 757, 2, 756, 2);
  123.         func_AddItem(1625, 757, 5, 756, 5);
  124.         func_AddItem(1819, 757, 3, 756, 3);
  125.         func_AddItem(1269, 757, 4, 756, 4);
  126.         func_AddItem(1142, 757, 3, 756, 3);
  127.         func_AddItem(1624, 757, 5, 756, 5);
  128.         func_AddItem(1626, 757, 5, 756, 5);
  129.         func_AddItem(13404, 757, 5, 756, 5);
  130.         func_AddItem(13027, 757, 6, 756, 6);
  131.         func_AddItem(1821, 757, 1, 756, 1);
  132.         func_AddItem(1268, 757, 5, 756, 5);
  133.        
  134.         // ARMORS
  135.         func_AddItem(2422, 757, 3, 756, 3);
  136.         func_AddItem(2104, 757, 1, 756, 1);
  137.         func_AddItem(5124, 757, 2, 756, 1);
  138.         func_AddItem(2406, 757, 3, 756, 3);
  139.         func_AddItem(5122, 757, 2, 756, 1);
  140.         func_AddItem(5126, 757, 2, 756, 1);
  141.         func_AddItem(2504, 757, 2, 756, 1);
  142.         func_AddItem(2353, 757, 15, 756, 15);
  143.         func_AddItem(2514, 757, 6, 756, 6);
  144.         func_AddItem(2404, 757, 2, 756, 1);
  145.         func_AddItem(2315, 757, 2, 756, 1);
  146.         func_AddItem(2102, 757, 2, 756, 1);
  147.         func_AddItem(2114, 757, 2, 756, 2);
  148.         end;
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement