viewing paste rA-115606-z Bank | Athena

Posted on the | Last edited on
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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
/*
create table `zeny_bank` (
    `account_id` int(11) primary key,
    `bank_type` enum('B','P','W') default 'B',
    `zeny` bigint(20) unsigned default 0,
    `daily_deposit` bigint(20) default 0,
    `daily_withdraw` bigint(20) default 0,
    `last_access` datetime
) engine = innodb;
*/
 
prontera,155,186,5  script  Banking 1_F_MARIA,{
    mes "["+ strnpcinfo(0) +"]";
    if ( !query_sql( "select bank_type, zeny, daily_deposit, daily_withdraw, date(last_access) from zeny_bank where account_id = "+ getcharid(3), .@bank_enum$, .@zeny$, .@deposit$, .@withdraw$, .@date$ ) )
        goto L_Open_Account;
    if ( gettimestr("%Y-%m-%d", 20) != .@date$ ) {
        query_sql "update zeny_bank set daily_deposit = 0, daily_withdraw = 0, last_access = now() where account_id = "+ getcharid(3);
        .@deposit$ = "0";
        .@withdraw$ = "0";
    }
    if ( .@bank_enum$ == "B" ) .@t = 1;
    else if ( .@bank_enum$ == "P" ) .@t = 2;
    else if ( .@bank_enum$ == "W" ) .@t = 3;
    mes "^0000FF"+ .bank_type$[.@t] +"^000000";
    mes "    "+ F_InsertComma(.@zeny$) +" Zeny";
    mes "- Deposit ->";
    mes "[ "+ F_InsertComma(.@deposit$) +" / "+ F_InsertComma(.bank_depo$[.@t]) +" ]";
    mes "- Withdraw ->";
    mes "[ "+ F_InsertComma(.@withdraw$) +" / "+ F_InsertComma(.bank_with$[.@t]) +" ]";
    next;
    switch ( select ( "Deposit Money", "Withdraw Zeny" ) ) {
//  switch ( select ( "Deposit Money", "Withdraw Zeny", "Close This Account" ) ) {
    mes "["+ strnpcinfo(0) +"]";
    mes "^0000FF"+ .bank_type$[.@t] +"^000000";
    case 1:
        if ( .@deposit$ == .bank_depo$[.@t] ) {
            mes "You have reach the maximum daily deposit limit";
            close;
        }
        mes "Current Zeny";
        mes "    "+ F_InsertComma(.@zeny$) +" Zeny";
        mes "- Deposit ->";
        mes "[ "+ F_InsertComma(.@deposit$) +" / "+ F_InsertComma(.bank_depo$[.@t]) +" ]";
        next;
        if ( Zeny == 0 ) {
            mes "["+ strnpcinfo(0) +"]";
            mes "You don't even have a Single Zeny.";
            close;
        }
        query_sql "select "+ .bank_depo$[.@t] +" - "+ .@deposit$, .@limit$;
        input .@num, 0, min( Zeny, atoi( .@limit$ ) );
        mes "["+ strnpcinfo(0) +"]";
        if ( !.@num ) {
            mes "Transaction cancelled";
            close;
        }
        mes "Are you sure you want to deposit";
        mes F_InsertComma(.@num) +" Zeny";
        mes "into the bank account?";
        next;
        select "Yes";
        mes "["+ strnpcinfo(0) +"]";
        Zeny -= .@num;
        query_sql "update zeny_bank set zeny = zeny + "+ .@num +", daily_deposit = daily_deposit + "+ .@num +", last_access = now() where account_id = "+ getcharid(3);
        mes "You have successfully deposit "+ F_InsertComma(.@num) +" Zeny into the bank account.";
        close;
    case 2:
        if ( .@withdraw$ == .bank_with$[.@t] ) {
            mes "You have reach the maximum daily withdrawal limit";
            close;
        }
        mes "Current Zeny";
        mes "    "+ F_InsertComma(.@zeny$) +" Zeny";
        mes "- Withdraw ->";
        mes "[ "+ F_InsertComma(.@withdraw$) +" / "+ F_InsertComma(.bank_with$[.@t]) +" ]";
        next;
        if ( Zeny == MAX_ZENY ) {
            mes "["+ strnpcinfo(0) +"]";
            mes "You are carrying the maximum amount of Zeny.";
            close;
        }
        query_sql "select "+ .bank_with$[.@t] +" - "+ .@withdraw$, .@limit$;
        input .@num, 0, min( atoi( .@limit$ ), atoi( .@zeny$ ), MAX_ZENY - Zeny );
        mes "["+ strnpcinfo(0) +"]";
        if ( !.@num ) {
            mes "Transaction cancelled";
            close;
        }
        mes "Are you sure you want to withdraw";
        mes F_InsertComma(.@num) +" Zeny";
        mes "from the bank account?";
        next;
        select "Yes";
        mes "["+ strnpcinfo(0) +"]";
        Zeny += .@num;
        query_sql "update zeny_bank set zeny = zeny - "+ .@num +", daily_withdraw = daily_withdraw + "+ .@num +", last_access = now() where account_id = "+ getcharid(3);
        mes "You have successfully withdraw "+ F_InsertComma(.@num) +" Zeny from the bank account.";
        close;
    case 3:
        query_sql "delete from zeny_bank where account_id = "+ getcharid(3);
        mes "This account has close forcefully.";
    }
    close;
L_Open_Account:
    mes "Do you wish to open a bank account?\r";
    for ( .@i = 0; .@i < .total; ++.@i ) {
        mes "^0000FF"+ .bank_type$[.@i] +"^000000 - ^FF0000Fee^000000 -> "+ F_InsertComma(.bank_fees$[.@i]);
        mes "- Deposit Limit -> "+ F_InsertComma(.bank_depo$[.@i]);
        mes "- Withdraw Limit -> "+ F_InsertComma(.bank_with$[.@i]);
    }
    next;
    .@s = select ( implode( .bank_type$, ":" ) ) -1;
    mes "["+ strnpcinfo(0) +"]";
    mes "Select type -> ^0000FF"+ .bank_type$[.@s] +"^000000?";
    mes "The Fee is "+ F_InsertComma(.bank_fees$[.@s]) +" Zeny";
    next;
    select "Open a ^0000FF"+ .bank_type$[.@s] +"^000000";
    mes "["+ strnpcinfo(0) +"]";
    if ( Zeny < atoi( .bank_fees$[.@s] ) ) {
        mes "You don't have enough Zeny to open this account.";
        close;
    }
    Zeny -= atoi( .bank_fees$[.@s] );
    query_sql "insert into zeny_bank values ("+ getcharid(3) +", '"+ .bank_enum$[.@s] +"', 0, 0, 0, now() )";
    mes "Your bank account has successfully created";
    close;
OnInit:
    callsub L_Bank_Type, "Basic Account", "B", "1000000", "100000000", "10000000";
    callsub L_Bank_Type, "Premium Account", "P", "5000000", "1000000000", "100000000";
    callsub L_Bank_Type, "Wicked Account", "W", "10000000", "5000000000", "1000000000";
    .total = 0;
    end;
L_Bank_Type:
    ++.total;
    .bank_type$[.total] = getarg(0);
    .bank_enum$[.total] = getarg(1);
    .bank_fees$[.total] = getarg(2);
    .bank_depo$[.total] = getarg(3);
    .bank_with$[.total] = getarg(4);
    return;
}
Viewed 893 times, submitted by AnnieRuru.