· 8 years ago · May 21, 2018, 06:16 PM
1//===== rAthena Script =======================================
2//= Super Banker
3//===== By: ==================================================
4//= pajodex
5//===== Current Version: =====================================
6//= 1.0
7//===== Compatible With: =====================================
8//= rAthena Project (pajodex)
9//===== Description: =========================================
10/*
11
12https://rathena.org/board/topic/115606-zeny-in-separate-table/
13
14*/
15//=====******** Note ********=================================
16//= if you find bugs or problem, please do tell DM me at
17//= Discord (pajodex#1328) or rAthena (pajodex)
18//= open for suggestions
19//===== Additional Comments: =================================
20// 1.0 - Initial release
21//===== Credits goes to: =====================================
22//= AnnieRuru
23//=============================================================
24prontera,150,185,0 script Super Banker 100,{
25function F_OpenBankAcc;
26 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$);
27 if ( .@acc_type == 0 ) {
28 mes "Do you want to open a bank account?";
29 next;
30 if(select("Yes","Nope") == 2) close;
31 mes "What bank account type do you wish to open?";
32 next;
33 switch(select("Information","Basic Account","Premium Account","Wicked Account","I changed my mind")) {
34 case 1:
35 mes "Info here...";
36 close;
37
38 case 2:
39 // F_OpenBankAcc ( <Account Type>, <Fee>, <Account Type Name>, <Daily Deposit Limit>, <Daily Withdraw Limit>)
40 F_OpenBankAcc ( 1, 1000000, "Basic Account", "100000000", "10000000" ); break;
41
42 case 3:
43 F_OpenBankAcc ( 2, 5000000, "Premium Account", "1000000000", "100000000" ); break;
44
45 case 4:
46 F_OpenBankAcc ( 3, 10000000, "Wicked Account", "5000000000", "1000000000" ); break;
47
48 default: close;
49 }
50 } else {
51 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$);
52 .@i = atoi( gettime(DT_YEAR) +""+ gettime(DT_DAYOFYEAR) );
53 if( #BANKRESET != .@i ) {
54 #BANKRESET = .@i;
55 query_sql "UPDATE `s_bank` SET `daily_deposit`="+.@max_deposit$+", `daily_withdraw`="+.@max_withdraw$+" WHERE `account_id`="+getcharid(3);
56 }
57 mes "Current Zeny:";
58 mes F_InsertComma(.@zeny$) +"z";
59 mes " ";
60 mes "Deposit Limit:";
61 mes F_InsertComma(.@daily_deposit$) +"z";
62 mes " ";
63 mes "Withdrawal Limit:";
64 mes F_InsertComma(.@daily_withdraw$) +"z";
65 mes " ";
66 mes "What would you like to do?";
67 next;
68 switch(select("Deposit","Withdraw","^ff0000Cancel Account^000000","Nothing")) {
69 case 1:
70 if( .@daily_deposit$ == "0" ) {
71 mes "Sorry, it seems you've reached your maximum daily deposit limit";
72 close;
73 }
74 mes "You currently have:";
75 mes F_InsertComma(.@zeny$) +"z";
76 mes " ";
77 mes "How much zeny will be deposited in your bank account?";
78 input .@amount, 1, 1000000000;
79 if( Zeny < .@amount ) {
80 mes "You dont have enough Zeny to make this transaction";
81 close;
82 }
83 if( query_sql("SELECT `daily_deposit` FROM `s_bank` WHERE `daily_deposit`<="+.@amount+" AND `account_id`="+getcharid(3))) {
84 mes "You can only deposit "+.@daily_deposit$ +"z for today.";
85 close;
86 }
87 mes "Are you sure you want to deposit "+ F_InsertComma(.@amount) +"z?";
88 next;
89 if(select("Yes","No") == 2) close;
90 Zeny -= .@amount;
91 query_sql "UPDATE `s_bank` SET `zeny`=`zeny`+"+.@amount+", `daily_deposit`=`daily_deposit`-"+.@amount+" WHERE `account_id`="+getcharid(3);
92 mes "You have deposited "+ F_InsertComma( .@amount )+"z in your bank account";
93 close;
94
95 case 2:
96 if( .@daily_withdraw$ == "0" ) {
97 mes "Sorry, it seems you've reached your maximum daily withdrawal limit";
98 close;
99 }
100 mes "You currently have:";
101 mes F_InsertComma(.@zeny$) +"z";
102 mes " ";
103 mes "How much zeny you wish to withdraw?";
104 input .@amount, 1, .@max_withdraw$;
105 if(.@amount > (MAX_ZENY - Zeny)) {
106 mes "You cant hold that much Zeny";
107 close;
108 }
109 if( query_sql("SELECT `daily_withdraw` FROM `s_bank` WHERE `daily_withdraw`<="+.@amount+" AND `account_id`="+getcharid(3))) {
110 mes "You can only withdraw "+.@daily_withdraw$ +"z for today.";
111 close;
112 }
113 if( query_sql("SELECT `zeny` FROM `s_bank` WHERE `zeny`<="+.@amount+" AND `account_id`="+getcharid(3))) {
114 mes "You dont have enough Zeny in your bank to withdraw.";
115 close;
116 }
117 mes "Are you sure you want to withdraw "+ F_InsertComma(.@amount) +"z?";
118 next;
119 if(select("Yes","No") == 2) close;
120 Zeny += .@amount;
121 query_sql "UPDATE `s_bank` SET `zeny`=`zeny`-"+.@amount+", `daily_withdraw`=`daily_withdraw`-"+.@amount+" WHERE `account_id`="+getcharid(3);
122 mes "You have withdrawn "+ F_InsertComma( .@amount )+"z in your bank account";
123 close;
124
125 case 3:
126 if( query_sql("SELECT `zeny` FROM `s_bank` WHERE `zeny`<=1 AND `account_id`="+getcharid(3))) {
127 mes "You still have "+ .@zeny$ +"z left in your account";
128 mes " ";
129 mes "Make sure you've withdrawn all your zeny before cancelling your account";
130 mes " ";
131 mes "Or else, all of the remaining zeny will be deleted.";
132 next;
133 }
134 mes "Are you sure you want to cancel your account??";
135 next;
136 if(select("Yes","No") == 2) close;
137 query_sql("DELETE FROM `s_bank` WHERE `account_id`="+ getcharid(3));
138 mes "Your bank account has been deleted";
139 close;
140
141 default: close;
142 }
143 }
144 end;
145
146OnInit:
147 .@string$ = "CREATE TABLE IF NOT EXISTS `s_bank` (";
148 .@string$ += "`account_id` int(11) unsigned NOT NULL DEFAULT '0',";
149 .@string$ += "`account_type` int(11) unsigned NOT NULL DEFAULT '0',";
150 .@string$ += "`zeny` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
151 .@string$ += "`deposit_limit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
152 .@string$ += "`withdraw_limit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
153 .@string$ += "`daily_deposit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
154 .@string$ += "`daily_withdraw` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0',";
155 .@string$ += "PRIMARY KEY (`account_id`)) ENGINE=InnoDB";
156 query_sql(.@string$);
157 end;
158
159 function F_OpenBankAcc {
160 mes "Are you sure you want to open a ^ff0000"+ getarg(2) +"^000000?";
161 mes "Total cost:";
162 mes F_InsertComma( getarg(1) )+"z";
163 next;
164 if(select("Sure","Nope") == 2) close;
165 if(Zeny < getarg(1)) {
166 mes "Sorry, you dont have enough Zeny to open a ^ff0000"+ getarg(2) +"^000000";
167 close;
168 }
169 Zeny -= getarg(1);
170 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)+"')");
171 mes "You have successfully created a ^ff0000"+ getarg(2) +"^000000";
172 close;
173 }
174}