Jump to content
  • 0

Simple bank sql base thanks a lot


Jayz

Question


  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  395
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

can i request a simple bank sql base deposit and withdrawal only

Menu:
    Deposit -> Can deposit any amount ( 2% tax ) if possible the 2% tax will go to the "tax" field under the "login table" just to find out how much the player's tax contribution is when using this bank
    Withdraw -> Can withdraw upto 1b only
    Balance -> Can check their balance
    

The database I will use is the login table, I created a new field whose name is deposit, thank you very much

 

image.png.afab186b826583a7b57d33969a2baa19.png

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

prontera,155,181,5	script	Simple Bank	757,{
	
	query_sql("SELECT `deposit`, `tax` FROM `login` WHERE `account_id` = "+getcharid(3)+" LIMIT 1", .@total_zeny, .@total_tax);
	mes "You have "+F_InsertComma(.@total_zeny)+" Zeny.";
	mes "You contributed "+F_InsertComma(.@total_tax)+" Zeny of Tax.";
	mes " ";
	switch(select(
		"Deposit Zeny",
		"Withdraw Zeny"
	)) {
		case 1:
			input .@amount, 0, Zeny;
			if (.@amount < 100) {
				mes "You cant deposit less than 100 Zeny.";
			}
			else if ((MAX_ZENY - .@total_zeny) < .@amount) {
				mes "Your bank can't hold that much of Zeny.";
			}
			else {
				mes "You have deposited "+F_InsertComma(.@amount)+" Zeny.";
				Zeny -= .@amount;
				query_sql("UPDATE `login` SET `deposit` = (`deposit` + "+.@amount+" - "+((.@amount / 100) * 2)+"), `tax` = (`tax` + "+((.@amount / 100) * 2)+") WHERE `account_id` = "+getcharid(3)+" LIMIT 1");
			}
			break;
		case 2:
			input .@amount, 0, min(.@total_zeny, 1000000000);
			if (.@amount <= 0) {
				mes "You cant deposit 0 Zeny.";
			}
			else if ((MAX_ZENY - Zeny) < .@amount) {
				mes "You can't hold that much of Zeny.";
			}
			else {
				mes "You have withdraw "+F_InsertComma(.@amount)+" Zeny.";
				Zeny += .@amount;
				query_sql("UPDATE `login` SET `deposit` = (`deposit` - "+.@amount+") WHERE `account_id` = "+getcharid(3)+" LIMIT 1");
			}
			break;
	}
	close;
}

since tax value doesn't have limit, you probably should create the column with bigger datatype to support more than 2.1b value.

Edited by Emistry
fix tax
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  21
  • Topics Per Day:  0.01
  • Content Count:  130
  • Reputation:   70
  • Joined:  09/03/14
  • Last Seen:  

I think this npc can help you

 

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  395
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

9 minutes ago, Mihael said:

I think this npc can help you

 

 

Thank you i already check this before making post, but i want more simplier like on my description

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  395
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

3 hours ago, Emistry said:

prontera,155,181,5	script	Simple Bank	757,{
	
	query_sql("SELECT `deposit`, `tax` FROM `login` WHERE `account_id` = "+getcharid(3)+" LIMIT 1", .@total_zeny, .@total_tax);
	mes "You have "+F_InsertComma(.@total_zeny)+" Zeny.";
	mes "You contributed "+F_InsertComma(.@total_tax)+" Zeny of Tax.";
	mes " ";
	switch(select(
		"Deposit Zeny",
		"Withdraw Zeny"
	)) {
		case 1:
			input .@amount, 0, Zeny;
			if (.@amount < 100) {
				mes "You cant deposit less than 100 Zeny.";
			}
			else if ((MAX_ZENY - .@total_zeny) < .@amount) {
				mes "Your bank can't hold that much of Zeny.";
			}
			else {
				mes "You have deposited "+F_InsertComma(.@amount)+" Zeny.";
				Zeny -= .@amount;
				query_sql("UPDATE `login` SET `deposit` = (`deposit` + "+.@amount+"), `tax` = (`tax` + "+((.@amount / 100) * 2)+") WHERE `account_id` = "+getcharid(3)+" LIMIT 1");
			}
			break;
		case 2:
			input .@amount, 0, min(.@total_zeny, 1000000000);
			if (.@amount <= 0) {
				mes "You cant deposit 0 Zeny.";
			}
			else if ((MAX_ZENY - Zeny) < .@amount) {
				mes "You can't hold that much of Zeny.";
			}
			else {
				mes "You have withdraw "+F_InsertComma(.@amount)+" Zeny.";
				Zeny += .@amount;
				query_sql("UPDATE `login` SET `deposit` = (`deposit` - "+.@amount+") WHERE `account_id` = "+getcharid(3)+" LIMIT 1");
			}
			break;
	}
	close;
}

since tax value doesn't have limit, you probably should create the column with bigger datatype to support more than 2.1b value.

work perfect!

I'll just open it again, because I noticed that the tax percentage works but the tax didn't reduce the zeny deposit

 

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

query_sql("UPDATE `login` SET `deposit` = (`deposit` + "+.@amount+" - "+((.@amount / 100) * 2)+"), `tax` = (`tax` + "+((.@amount / 100) * 2)+") WHERE `account_id` = "+getcharid(3)+" LIMIT 1");

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  58
  • Topics Per Day:  0.01
  • Content Count:  395
  • Reputation:   53
  • Joined:  07/24/12
  • Last Seen:  

9 minutes ago, Emistry said:
query_sql("UPDATE `login` SET `deposit` = (`deposit` + "+.@amount+" - "+((.@amount / 100) * 2)+"), `tax` = (`tax` + "+((.@amount / 100) * 2)+") WHERE `account_id` = "+getcharid(3)+" LIMIT 1");

 

thanks it work perfect now

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...