· 8 years ago · May 21, 2018, 05:58 PM
1prontera,150,185,0 script Super Banker 100,{
2function F_OpenBankAcc;
3 query_sql("SELECT `account_type`, `zeny`, `deposit_limit`, `withdraw_limit`, `daily_deposit`, `daily_withdraw` FROM `s_bank` WHERE `account_id`="+ getcharid(3), .@acc_type, .@zeny$, .@max_deposit$, .@max_withdraw$, .@daily_deposit$, .@daily_withdraw$);
4 if ( .@acc_type == 0 ) {
5 mes "Do you want to open a bank account?";
6 next;
7 if(select("Yes","Nope") == 2) close;
8 mes "What bank account type do you wish to open?";
9 next;
10 switch(select("Information","Basic Account","Premium Account","Wicked Account","I changed my mind")) {
11 case 1:
12 mes "Info here...";
13 close;
14
15 case 2:
16 F_OpenBankAcc ( 1, 1000000, "Basic Account", "100000000", "10000000" ); break;
17
18 case 3:
19 F_OpenBankAcc ( 2, 5000000, "Premium Account", "1000000000", "100000000" ); break;
20
21 case 4:
22 F_OpenBankAcc ( 3, 10000000, "Wicked Account", "5000000000", "1000000000" ); break;
23
24 default: close;
25 }
26 } else {
27 query_sql("SELECT `account_type`, `zeny`, `deposit_limit`, `withdraw_limit`, `daily_deposit`, `daily_withdraw` FROM `s_bank` WHERE `account_id`="+ getcharid(3), .@acc_type, .@zeny$, .@max_deposit$, .@max_withdraw$, .@daily_deposit$, .@daily_withdraw$);
28 .@i = atoi( gettime(DT_YEAR) +""+ gettime(DT_DAYOFYEAR) );
29 if( #BANKRESET != .@i ) {
30 #BANKRESET = .@i;
31 query_sql "UPDATE `s_bank` SET `daily_deposit`="+.@max_deposit$+", `daily_withdraw`="+.@max_withdraw$+" WHERE `account_id`="+getcharid(3);
32 }
33 mes "Current Zeny:";
34 mes F_InsertComma(.@zeny$) +"z";
35 mes "";
36 mes "Deposit Limit:";
37 mes F_InsertComma(.@daily_deposit$) +"z";
38 mes "";
39 mes "Withdrawal Limit:";
40 mes F_InsertComma(.@daily_withdraw$) +"z";
41 mes "";
42 mes "What would you like to do?";
43 next;
44 switch(select("Deposit","Withdraw","^ff0000Cancel Account^000000","Nothing")) {
45 case 1:
46 if( .@daily_deposit$ == "0" ) {
47 mes "Sorry, it seems you've reached your maximum daily deposit limit";
48 close;
49 }
50 mes "How much zeny will be deposited in your bank account?";
51 input .@amount, 1, 1000000000;
52 if( Zeny < .@amount ) {
53 mes "You dont have enough Zeny to make this transaction";
54 close;
55 }
56 if( query_sql("SELECT `daily_deposit` FROM `s_bank` WHERE `daily_deposit`<="+.@amount+" AND `account_id`="+getcharid(3))) {
57 mes "You can only deposit "+.@daily_deposit$ +"z for today.";
58 close;
59 }
60 Zeny -= .@amount;
61 query_sql "UPDATE `s_bank` SET `zeny`=`zeny`+"+.@amount+", `daily_deposit`=`daily_deposit`-"+.@amount+" WHERE `account_id`="+getcharid(3);
62 mes "You have deposited "+ F_InsertComma( .@amount )+"z in your bank account";
63 close;
64
65 case 2:
66 if( .@daily_withdraw$ == "0" ) {
67 mes "Sorry, it seems you've reached your maximum daily withdrawal limit";
68 close;
69 }
70 mes "How much zeny you wish to withdraw?";
71 input .@amount, 1, .@max_withdraw$;
72 if(.@amount > (MAX_ZENY - Zeny)) {
73 mes "You cant hold that much Zeny";
74 close;
75 }
76 if( query_sql("SELECT `daily_withdraw` FROM `s_bank` WHERE `daily_withdraw`<="+.@amount+" AND `account_id`="+getcharid(3))) {
77 mes "You can only withdraw "+.@daily_withdraw$ +"z for today.";
78 close;
79 }
80 if( query_sql("SELECT `zeny` FROM `s_bank` WHERE `zeny`<="+.@amount+" AND `account_id`="+getcharid(3))) {
81 mes "You dont have enough Zeny in your bank to withdraw.";
82 close;
83 }
84 Zeny += .@amount;
85 query_sql "UPDATE `s_bank` SET `zeny`=`zeny`-"+.@amount+", `daily_withdraw`=`daily_withdraw`-"+.@amount+" WHERE `account_id`="+getcharid(3);
86 mes "You have withdrawn "+ F_InsertComma( .@amount )+"z in your bank account";
87 close;
88
89 case 3:
90 query_sql("TRUNCATE TABLE `s_bank`"); break;
91
92 default: close;
93 }
94 }
95 end;
96
97OnInit:
98 .@string$ = "CREATE TABLE IF NOT EXISTS `s_bank` (";
99 .@string$ += "`account_id` int(11) unsigned NOT NULL DEFAULT '0',";
100 .@string$ += "`account_type` int(11) unsigned NOT NULL DEFAULT '0',";
101 .@string$ += "`zeny` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
102 .@string$ += "`deposit_limit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
103 .@string$ += "`withdraw_limit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
104 .@string$ += "`daily_deposit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
105 .@string$ += "`daily_withdraw` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
106 .@string$ += "PRIMARY KEY (`account_id`)) ENGINE=InnoDB";
107 query_sql(.@string$);
108 end;
109
110 function F_OpenBankAcc {
111 mes "Are you sure you want to open a ^ff0000"+ getarg(2) +"^000000?";
112 mes "Total cost:";
113 mes F_InsertComma( getarg(1) )+"z";
114 next;
115 if(select("Sure","Nope") == 2) close;
116 if(Zeny < getarg(1)) {
117 mes "Sorry, you dont have enough Zeny to open a ^ff0000"+ getarg(2) +"^000000";
118 close;
119 }
120 Zeny -= getarg(1);
121 query_sql("INSERT INTO `s_bank` (`account_id`,`account_type`,`deposit_limit`,`withdraw_limit`,`daily_deposit`,`daily_withdraw`) VALUES ('"+getcharid(3)+"', '"+getarg(0)+"', '"+getarg(3)+"', '"+getarg(4)+"', '"+getarg(3)+"', '"+getarg(4)+"')");
122 mes "You have successfully created a ^ff0000"+ getarg(2) +"^000000";
123 close;
124 }
125}