viewing paste Another Bank Manager | 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
 
 
volterra,85,103,5   script  Bank Manager    757,{
function int__;
 
do{
    callsub exchange_rate;
    .@menu = select( "Zeny to Card","Card to Zeny","Close" );
    switch( .@menu ){
        Case 1:
            mes "Convert Zeny to ATM Card ?";
            .@coin = select( implode( .coin_name$,":" ) ) - 1;
            if( Zeny <  .value[.@coin] ){
                mes "^FF0000[ERROR]^000000 You didnt have enough zeny.";
            }else{
                .@maximum = Zeny / .value[.@coin];
                mes "You can get maximum of ^FF0000"+int__( .@maximum )+" x "+getitemname( .coin_id[.@coin] )+"^000000";
                input .@amount,0,.@maximum;
                if( .@amount )
                    if( checkweight( .coin_id[.@coin],.@amount ) ){
                        .@total = ( .@amount * .value[.@coin] );
                        Zeny -= .@total;
                        getitem .coin_id[.@coin],.@amount;
                        message strcharinfo(0),"Exchanged "+int__( .@total )+" Zeny to "+int__( .@amount )+" "+getitemname( .coin_id[.@coin] )+"^000000";
                    }else{
                        mes "^FF0000[ERROR]^000000 You cant take this much.";
                    }
            }
            break;
        Case 2:
            mes "Convert ATM Card to Zeny ?";
            .@coin = select( implode( .coin_name$,":" ) ) - 1;
            if( !countitem( .coin_id[.@coin] ) ){
                mes "^FF0000[ERROR]^000000 You didnt have any "+getitemname( .coin_id[.@coin] )+".";
            }else if( ( .max_zeny - Zeny ) < .value[.@coin] ){
                mes "^FF0000[ERROR]^000000 You cant exchange this Card as it will exceed the Zeny limit.";
            }else{
                .@maximum = (( .max_zeny - Zeny ) / .value[.@coin] );
                if( .@maximum > countitem( .coin_id[.@coin] ) ) .@maximum = countitem( .coin_id[.@coin] );
                mes "You can exchange maximum of ^FF0000"+int__( .@maximum )+" x "+getitemname( .coin_id[.@coin] )+"^000000 to zeny";
                input .@amount,0,.@maximum;
                if( .@amount ){
                    .@total = ( .@amount * .value[.@coin] );
                    Zeny += .@total;
                    delitem .coin_id[.@coin],.@amount;
                    message strcharinfo(0),"Exchanged "+int__( .@amount )+" "+getitemname( .coin_id[.@coin] )+" to "+int__( .@total )+" Zeny^000000";
                }
            }
            break;
        default: break;
    }
    next;
}while( .@menu != 3 );
mes "Thank you.";
close;
 
exchange_rate:
    mes "Exchange Rate :";
    for( .@i = 0; .@i < .coin_size; .@i++ )
        mes "^777777 > "+.coin_name$[.@i]+" - "+int__( .value[.@i] )+" z^000000";
    return;
    
OnInit:
// server max zeny
.max_zeny = 1000000000;
// coin list + name + value
setarray .coin_name$,"ATM Card";
setarray .coin_id,6101;
setarray .value,10000000;
 
.coin_size = getarraysize( .coin_name$ );
end;
 
 
// credits to annieruru
function    int__   {
    set .@num, atoi(""+getarg(0));
    if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
    set .@l, getstrlen(""+.@num);
    for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
        set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
            if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
    }
    return .@num$;
}
 
}
Viewed 1225 times, submitted by diconfrost13.