viewing paste rA-115606-z Bank0.3 | 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
/*
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", ( .@t < 3 )? "Upgrade 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, MAX_ZENY;
        mes "["+ strnpcinfo(0) +"]";
        if ( !.@num ) {
            mes "Transaction cancelled";
            close;
        }
        .@min_value = min( Zeny, atoi( .@limit$ ) );
        if ( .@num > .@min_value ) {
            mes "Your Input value has shrink into";
            mes F_InsertComma(.@min_value) +" Zeny";
            if ( .@min_value == Zeny )
                mes "because you are carrying that amount of Zeny.";
            else if ( .@min_value == atoi( .@limit$ ) )
                mes "because of the daily deposit limit.";
            mes "Continue ?";
            next;
            select "OK";
            .@num = .@min_value;
            mes "["+ strnpcinfo(0) +"]";
        }
        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, MAX_ZENY;
        mes "["+ strnpcinfo(0) +"]";
        if ( !.@num ) {
            mes "Transaction cancelled";
            close;
        }
        .@min_value = min( atoi( .@limit$ ), atoi( .@zeny$ ), MAX_ZENY - Zeny );
        if ( .@num > .@min_value ) {
            mes "Your Input value has shrink into";
            mes F_InsertComma(.@min_value) +" Zeny";
            if ( .@min_value == atoi( .@limit$ ) )
                mes "because of the daily withdrawal limit.";
            else if ( .@min_value == atoi( .@zeny$ ) )
                mes "because that is the amount of Zeny left in the bank.";
            else if ( .@min_value == MAX_ZENY - Zeny )
                mes "because that is the maximum amount of Zeny you can hold.";
            mes "Continue ?";
            next;
            select "OK";
            .@num = .@min_value;
            mes "["+ strnpcinfo(0) +"]";
        }
        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:
        mes "Select the type of banking account you like to make an upgrade.";
        next;
        for ( .@i = 0; .@i <= .total; ++.@i )
            .@menu$ += ( ( .@i > .@t )? "^0000FF"+ .bank_type$[.@i] +"^000000" : "" )+ ":";
        .@s = select( .@menu$ ) -1;
        mes "["+ strnpcinfo(0) +"]";
        if ( Zeny < atoi( .bank_fees$[.@s] ) && atoi( .@zeny$ ) < atoi( .bank_fees$[.@s] ) ) {
            mes "You don't have enough Zeny to upgrade into this account.";
            close;
        }
        mes "Select the payment type";
        mes "The Fee is "+ F_InsertComma(.bank_fees$[.@s]) +" Zeny";
        next;
        switch ( select ( (Zeny < atoi( .bank_fees$[.@s] ))? "" : "Pay with Zeny", (atoi( .@zeny$ ) < atoi( .bank_fees$[.@s] ))? "" : "Pay from the bank" ) ) {
        mes "["+ strnpcinfo(0) +"]";
        case 1:
            Zeny -= atoi( .bank_fees$[.@s] );
            query_sql "update zeny_bank set bank_type = '"+ .bank_enum$[.@s] +"' where account_id = "+ getcharid(3);
            break;
        case 2:
            query_sql "update zeny_bank set zeny = zeny - "+ .bank_fees$[.@s] +", bank_type = '"+ .bank_enum$[.@s] +"' where account_id = "+ getcharid(3);
        }
        mes "Your account has successfully upgrade into";
        mes "^0000FF"+ .bank_type$[.@s] +"^000000?";
    }
    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";
    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 1041 times, submitted by AnnieRuru.