Advertisement
johnlol

Points_to_Item_Exchanger

May 27th, 2019
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*=========================================================
  2. Points to Item Exchanger
  3. by Mumbles
  4. ===========================================================
  5. Request: http://goo.gl/MplDtF
  6. ===========================================================
  7. Preview: http://youtu.be/V-6ahRLqRi4
  8. ===========================================================
  9. Description:
  10. Exchanges items for points and vice-versa at a fixed rate.
  11. ===========================================================
  12. Compatibility:
  13. Optimised for Hercules emulators.
  14. ===========================================================
  15. Changelog:
  16. v1.0 - First version.
  17.     v1.0.1 - Added changelog.
  18. =========================================================*/
  19.  
  20. prontera,181,166,5  script  Donation Manager::points2item   956,{
  21. dispbottom "You currently have " +#KAFRAPOINTS+ " Kafra Points";
  22.    
  23.     /*-----------------------------------------------------
  24.     Script
  25.     -----------------------------------------------------*/
  26.     mes .npc_name$;
  27.     mes "Hello there, ^FF8800"+ strcharinfo(0) +"^000000! "+
  28.         "Would you exchange your "+ .pod_name$ +" "+
  29.         "for "+ .points_name$ +"?";
  30.     mes " ";
  31.     mes "Exchange Rate: "+ .rate +":1";
  32.     mes .points_name$ +": [^FF0000"+ getd(.points_var$) +"^000000]";
  33.     next;
  34.    
  35.     switch (select(implode(.menu_options$, ":"))) {
  36.         case 1:
  37.             mes .npc_name$;
  38.             mes "Okay, come back if you change your mind!";
  39.             break;
  40.            
  41.         case 2:
  42.             mes .npc_name$;
  43.             mes "Please enter the amount of "+ .pod_name$ +" you want to exchange.";
  44.            
  45.             do {
  46.                 mes " ";
  47.                 mes "Input ^0000FF0^000000 to cancel.";
  48.                 next;
  49.                
  50.                 input .@amount;
  51.                 .@total = .@amount / .rate;
  52.                 .@remainder = .@amount % .rate;
  53.                
  54.                 // Check break input
  55.                 if (!.@amount) {
  56.                     message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
  57.                     close;
  58.                 }
  59.                
  60.                 // Check total against inventory
  61.                 if (countitem(.pod_id) < .@amount) {
  62.                     mes .npc_name$;
  63.                     mes "^FF0000Please enter a valid amount.^000000";
  64.                 }
  65.                    
  66.                 // Check remainder [loss prevention]
  67.                 else if (.@remainder) {
  68.                     mes .npc_name$;
  69.                     mes "Sorry, but you must exchange multiples of "+ .rate +".";
  70.                 }
  71.             } while (countitem(.pod_id) < .@amount || .@remainder);
  72.            
  73.             delitem .pod_id, .@amount;
  74.             setd .points_var$, getd(.points_var$) + .@total;
  75.            
  76.             mes .npc_name$;
  77.             mes "You've exchanged "+ .@amount +" "+ .pod_name$ +" for "+ .@total +" "+ .points_name$ +". "+
  78.                 "You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
  79.             break;
  80.            
  81.         case 3:
  82.             mes .npc_name$;
  83.             mes "Please enter the amount of "+ .points_name$ +" that you want to exchange.";
  84.        
  85.             do {
  86.                 mes " ";
  87.                 mes "Input ^0000FF0^000000 to cancel.";
  88.                 next;
  89.                
  90.                 input .@amount;
  91.                 .@total = .@amount * .rate;
  92.                
  93.                 // Check break input
  94.                 if (!.@amount) {
  95.                     message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
  96.                     close;
  97.                 }
  98.                
  99.                 // Check amount against points
  100.                 if (getd(.points_var$) < .@amount) {
  101.                     mes .npc_name$;
  102.                     mes "^FF0000Please enter a valid amount.^000000";
  103.                 }
  104.             } while (getd(.points_var$) < .@amount);
  105.            
  106.             // Check weight
  107.             if (!checkweight(.pod_id, .@total)) {
  108.                 mes .npc_name$;
  109.                 mes "^FF0000You're overweight; please store some items.^000000";
  110.                 break;
  111.             }
  112.            
  113.             setd .points_var$, getd(.points_var$) - .@amount;
  114.             getitem .pod_id, .@total;
  115.            
  116.             mes .npc_name$;
  117.             mes "You've exchanged "+ .@amount +" "+ .points_name$ +" for "+ .@total +" "+ .pod_name$ +". "+
  118.                 "You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
  119.             break;
  120.         }
  121.        
  122.         close;
  123.    
  124.    
  125.     /*-----------------------------------------------------
  126.     Configuration
  127.     -----------------------------------------------------*/
  128.     OnInit:
  129.         .npc_name$ = "[^0000FFDonation Manager^000000]";
  130.         .rate = 1;      // Exchange rate (1 point * rate = total PoDs)
  131.         .pod_id = 7179; // Proof of Donation item ID or constant
  132.         .pod_name$ = getitemname(.pod_id) +"(s)";   // Proof of Donation item name
  133.         .points_name$ = "Kafra Points(s)";          // Points name
  134.         .points_var$ = "#KAFRAPOINTS";              // Points variable
  135.        
  136.         // Modifying these options requires updates to the corresponding case
  137.         setarray .menu_options$[0], "^FF0000>^000000 Cancel",
  138.                                     "^0000FF>^000000 Exchange "+ .pod_name$ +" for "+ .points_name$,
  139.                                     "^0000FF>^000000 Exchange "+ .points_name$ +" for "+ .pod_name$;
  140.        
  141.         end;
  142.    
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement