Jump to content
  • 0
Sign in to follow this  
Zephy

Banker

Question

This is the first script I'm going to release to the public for Hercules. I'm still new to Hercules but I think I've got it down for the most part. This NPC a versatile Banker that allows for storage and exchanging (item ---> zeny, and vice versa) of an item (made for bank notes, but they can be anything really) without using a SQL databse. I've noticed this type of NPC has been scarce around all the Athena emulators, so I decided to make one :x. I made this during my break in between classes so it has NOT been tested yet. Over the next few days I'll be testing it and changing it, but for now, here is the initial release.

 

I will fully support this script so if something is wrong, let me know.

 

I would also love some input on this script. What should I do differently, is it a clean script, does it work, are there any shortcuts I should know about? Let me know!

 

EDIT: I have tested it, fixed it up and added some things. The new script can be found here.

Edited by Zephy

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

 

Finally home so I can now test it properly. Thanks for moving, didn't know about that rule :x.

deposit items just like kafra @storage? or different?

 

does it suport multiple deposit of items? 

 

line 65:

if (@banknotewithdraw =< 0) { // Checks if the player enters a number less than or equal to 0

 

should be:

if (@banknotewithdraw <= 0) { // Checks if the player enters a number less than or equal to 0

 

It does not support multiple deposit of items. It's more like a banker exchanging an item (Bank note) to zeny or vice versa. It also allows storage of the item.

Share this post


Link to post
Share on other sites
  • 0

Some Mistakes:

Line 37(Also on line 65)

			if (@banknotedeposit =< 0) { // Checks if the player enters a number less than or equal to 0

Should be

			if (@banknotedeposit <= 0) { // Checks if the player enters a number less than or equal to 0

Line 92(same with line 128):

mes "Please input the amount of zeny to exchange for "+ getitiemname(.note_id) +"s,"; 

Should be 

mes "Please input the amount of zeny to exchange for "+ getitemname(.note_id) +"s,"; 

 

Line 142:

 

Zeny =+ @priceb; // Gives player zeny 

 

Should be

 

Zeny += @priceb; // Gives player zeny  

and finally line 172:

 

prontera,150,150,3	duplicate(Banker)	Banker#prt	4_m_khkyel 

 

Should be(its case sensitive, so capital)

 

prontera,150,150,3	duplicate(Banker)	Banker#prt	4_M_KHKYEL 

This all were map-server errors, haven't tested ingame.

Share this post


Link to post
Share on other sites
  • 0

Moving to Script Support for the following reason:

[*]Code-based releases must be tested and error-free on Hercules emulators.

I made this during my break in between classes so it has NOT been tested yet. Over the next few days I'll be testing it and changing it, but for now, here is the initial release.

 

 

I encourage you to make a new topic when your script is complete, tested, and fully functional. I have codeboxed your script below for quick referencing. Thanks for your contribution!

 

/*==================================================Bankerby Zephy====================================================Description: A banker NPC for exchanging an item for zeny,vice versa, and storage of said item withoutusing a SQL database.====================================================Additional Notes: - Make sure you take into consideration your   input_max_value in /conf/script.conf.====================================================Changelog:	1.0 - Initial Release==================================================*/ -	script	Banker	-1,{	 mes .npc_name$;	mes "You currently have "+ #banknote +" "+ getitemname(.note_id) +"s in your account.";	mes " ";	mes "What would you like to do?";	next;		// Main Menu	switch(select("Deposit "+ getitemname(.note_id) +"s:Withdraw "+ getitemname(.note_id) +"s:Exchange "+ getitemname(.note_id) +"s:Cancel")) {		 case 1: // Deposit item			mes .npc_name$;			mes "How many "+ getitemname(.note_id) +"s would you like to deposit?";			 input @banknotedeposit; // Input amount to be stored			 if (@banknotedeposit =< 0) { // Checks if the player enters a number less than or equal to 0				 mes .npc_name$;				mes "Please enter a number greater than zero.";				close;			}			 if (@banknotedeposit > countitem(.note_id)) { // Checks if the player has item amount				 mes .npc_name$;				mes "You do not have enough "+ getitemname(.note_id) +"s.";				close;			}			 #banknote = #banknote+@banknotedeposit; // Adds amount to current storage amount			delitem .note_id,@banknotedeposit; // Deletes items						mes .npc_name$;			mes "I have deposited your "+ getitemname(.note_id) +"s.";			mes "Come again soon.";			close;		 case 2: // Withdraw item			mes .npc_anme$;			mes "How many "+ getitemname(.note_id) +"s would you like to withdraw?";			 input @banknotewithdraw; // Input amount to be withdrawn			 if (@banknotewithdraw =< 0) { // Checks if the player enters a number less than or equal to 0				 mes .npc_name$;				mes "Please enter a number greater than zero.";				close;			}			 if (@banknotewithdraw > #banknote) { // Checks if the player has enough of the item in the storage				 mes .npc_name$;				mes "You only have "+ #banknote +" "+ getitemname(.note_id) +"s in your account.";				close;			}			 #banknote = #banknote-@banknotewithdraw; // Reduces storage amount by amount withdrawn			getitem .note_id,@banknotewithdraw; // Receive item			 mes .npc_name$;			mes "I have withdrawn "+ @banknotewithdraw +" "+ getitemname(.note_id) +"s from your account.";			mes "Come again soon.";			close;		 case 3: // Exchange items			switch(select("Zeny ---> "+ getitemname(.note_id) +":"+ getitemname(.note_id) +" ---> Zeny:Back")) {				 case 1: // Zeny to item					mes .npc_name$;					mes "Please input the amount of zeny to exchange for "+ getitiemname(.note_id) +"s,";					 input @zenyexchange; // Input amount of zeny					 if (@zenyexchange < .note_price) { // Checks if amount entered is less than the set .note_price						 mes .npc_name$;						mes "The exchange rate is "+ .note_price +" zeny per "+ .note_id +".";						close;					}					 if (Zeny < @zenyexchange) { // Checks if player has enough zeny											mes .npc_name$;						mes "Please come back with more zeny or enter another value.";						close;					}					 Zeny =- @zenyexchange; // Reduces zeny by amount inputted					@pricea = @zenyexchange/.note_price; // Sets note amount					getitem .note_id,@pricea; // Gives player notes					 mes .npc_name$;					mes "I have exchanged "+ @zenyexchange +" zeny for "+ @pricea +" "+ getitemname(.note_id) +"s.";					mes "Come again soon.";					close;				 case 2: // Item to zeny					mes .npc_name$;					mes "Please input the amount of "+ getitemname(.note_id) +"s you would like to exchange for zeny.";					 input @noteexchange; // Input amount of items					 if (@noteexchange < countitem(.note_id)) { // Checks if player has enough of the item											mes .npc_name$;						mes "Please come back with more "+ getitemanme(.note_id) +" or enter another value.";						close;					}					 if ((@noteexchange*.note_price)+Zeny > @maxzeny) { // Checks if the player will reach their max zeny											mes .npc_name$;						mes "Sorry, but you can not exchange this number of "+ getitemname(.note_id) +"s ";						mes "because you will exceed the maximum amount of zeny you can hold.";						close;					}					 delitem .note_id,@noteexchange; // Deletes notes by amount inputted					@priceb = @noteexchange*.noteprice; // Sets zeny amount					Zeny =+ @priceb; // Gives player zeny										next;					 mes .npc_name$;					mes "I have exchanged "+ @noteexchange +" "+ getitemname(.note_id) +"s for "+ @priceb +" zeny.";					mes "Come again soon.";					close;				 case 3:					break;			}		 case 4: // Cancel			mes .npc_name$;			mes "Come again soon.";			close;	}	 // Configuration	OnInit:		.npc_name$ = "[^0000CCBanker^000000]"; // NPC name				.note_id = 0; // Bank note ID		.note_price = 0; // Bank note price, in zeny		.maxzeny = 2000000000; // Maximum amount of zeny a player can hold in your server} // Duplicates//===============================================================prontera,150,150,3	duplicate(Banker)	Banker#prt	4_m_khkyel

Share this post


Link to post
Share on other sites
  • 0

Finally home so I can now test it properly. Thanks for moving, didn't know about that rule :x.

deposit items just like kafra @storage? or different?

 

does it suport multiple deposit of items? 

 

line 65:

if (@banknotewithdraw =< 0) { // Checks if the player enters a number less than or equal to 0

 

should be:

if (@banknotewithdraw <= 0) { // Checks if the player enters a number less than or equal to 0

Edited by kerbiii

Share this post


Link to post
Share on other sites
  • 0

Some Mistakes:

Line 37(Also on line 65)

			if (@banknotedeposit =< 0) { // Checks if the player enters a number less than or equal to 0

Should be

			if (@banknotedeposit <= 0) { // Checks if the player enters a number less than or equal to 0

Line 92(same with line 128):

mes "Please input the amount of zeny to exchange for "+ getitiemname(.note_id) +"s,"; 

Should be 

mes "Please input the amount of zeny to exchange for "+ getitemname(.note_id) +"s,"; 

 

Line 142:

 

Zeny =+ @priceb; // Gives player zeny 

 

Should be

 

Zeny += @priceb; // Gives player zeny  

and finally line 172:

 

prontera,150,150,3	duplicate(Banker)	Banker#prt	4_m_khkyel 

 

Should be(its case sensitive, so capital)

 

prontera,150,150,3	duplicate(Banker)	Banker#prt	4_M_KHKYEL 

This all were map-server errors, haven't tested ingame.

 

-                    Zeny =- @zenyexchange; // Reduces zeny by amount inputted
+                    Zeny =- @zenyexchange; // Reduces zeny by amount inputted

(-)Delete

(+)Add

Share this post


Link to post
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.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.