viewing paste Unknown #11190 | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
turbo_room,123,111,3    script  Voucher A Manager   4_M_OPERATION,{
    
    /*-----------------------------------------------------
    Script
    -----------------------------------------------------*/
    mes .npc_name$;
    mes "Hello there, ^FF8800"+ strcharinfo(0) +"^000000! "+
        "Would you exchange your "+ .pod_name$ +" "+
        "for "+ .points_name$ +"?";
    mes " ";
    mes "Exchange Rate: "+ .rate +":1";
    mes .points_name$ +": [^FF0000"+ getd(.points_var$) +"^000000]";
    next;
    
    switch (select(implode(.menu_options$, ":"))) {
        case 1:
            mes .npc_name$;
            mes "Okay, come back if you change your mind!";
            break;
            
        case 2:
            mes .npc_name$;
            mes "Please enter the amount of "+ .pod_name$ +" you want to exchange.";
            
            do {
                mes " ";
                mes "Input ^0000FF0^000000 to cancel.";
                next;
                
                input .@amount;
                .@total = .@amount / .rate;
                .@remainder = .@amount % .rate;
                
                // Check break input
                if (!.@amount) {
                    message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
                    close;
                }
                
                // Check total against inventory
                if (countitem(.pod_id) < .@amount) {
                    mes .npc_name$;
                    mes "^FF0000Please enter a valid amount.^000000";
                }
                    
                // Check remainder [loss prevention]
                else if (.@remainder) {
                    mes .npc_name$;
                    mes "Sorry, but you must exchange multiples of "+ .rate +".";
                }
            } while (countitem(.pod_id) < .@amount || .@remainder);
            
            delitem .pod_id, .@amount;
            setd .points_var$, getd(.points_var$) + .@total;
            
            mes .npc_name$;
            mes "You've exchanged "+ .@amount +" "+ .pod_name$ +" for "+ .@total +" "+ .points_name$ +". "+
                "You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
            break;
            
        case 3:
            mes .npc_name$;
            mes "Please enter the amount of "+ .points_name$ +" that you want to exchange.";
        
            do {
                mes " ";
                mes "Input ^0000FF0^000000 to cancel.";
                next;
                
                input .@amount;
                .@total = .@amount * .rate;
                
                // Check break input
                if (!.@amount) {
                    message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
                    close;
                }
                
                // Check amount against points
                if (getd(.points_var$) < .@amount) {
                    mes .npc_name$;
                    mes "^FF0000Please enter a valid amount.^000000";
                }
            } while (getd(.points_var$) < .@amount);
            
            // Check weight
            if (!checkweight(.pod_id, .@total)) {
                mes .npc_name$;
                mes "^FF0000You're overweight; please store some items.^000000";
                break;
            }
            
            setd .points_var$, getd(.points_var$) - .@amount;
            getitem .pod_id, .@total;
            
            mes .npc_name$;
            mes "You've exchanged "+ .@amount +" "+ .points_name$ +" for "+ .@total +" "+ .pod_name$ +". "+
                "You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
            break;
        }
        
        close;
    
    
    /*-----------------------------------------------------
    Configuration
    -----------------------------------------------------*/
    OnInit:
        .npc_name$ = "[^0000FFVoucher  Manager^000000]";
        .rate = 10;     // Exchange rate (1 point * rate = total PoDs)
        .pod_id = 7615; // Proof of Donation item ID or constant
        .pod_name$ = getitemname(.pod_id) +"(s)";   // Proof of Donation item name
        .points_name$ = "Cash Point(s)";            // Points name
        .points_var$ = "#CASHPOINTS";               // Points variable
        
        // Modifying these options requires updates to the corresponding case
        setarray .menu_options$[0], "^FF0000>^000000 Cancel",
                                    "^0000FF>^000000 Exchange "+ .pod_name$ +" for "+ .points_name$,
                                    "^0000FF>^000000 Exchange "+ .points_name$ +" for "+ .pod_name$;
        
        end;
    
}
Viewed 1084 times, submitted by Guest.