Jump to content
  • 0
rakuzas

(SOLVED!) Custom script not properly working if put more than 1 in input

Question

Hello,

Today Im just trying to make custom script.. When player input number, he will get the item..

It suppose to work like this :

1 Red Herb
1 Empty Bottle

Will get 1 Red Potion

So.. If they had 20 Red Herb and 19 Empty Bottle, they can input 1-19 for Red Potion.. But my current script only working when they input 1 only.. More than that, it will shows my Error message.. IDK which part I do wrong.. Please help me.. 


 

			set .@amountBottle, (countitem (713)); 		//Empty Bottle
			set .@amountHerb, (countitem (507));	//Red Herb

// Player input
input .@amountPotion;
			
			// 1st Error Message if Input is ZERO 
			if (.@amountPotion == 0) {
				mes "ERROR!";
				close2;
				end;
				}
			
			// 2nd Error if Input is larger than both item required
			if ((.@amountPotion) > ((.@amountBottle) || (.@amountHerb))){
				mes "ERROR! Input bigger than item amount!";
				close2;
				end;
				}
					

					// Player will get item if no problem but now stuck with 1 potion only, if input 2 or more will shows the 2nd error.
					delitem 507, .@amountPotion;
					delitem 713, .@amountPotion;
					close2;
					getitem 	503,	.@amountPotion; // Yellow Potion
					end;

But if I removed the 2nd error line, it work perfectly.. But player able to get free item as server cannot delitem the required item and shows console error.. I tried use && and || but both shows same result.

Edited by rakuzas
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
17 hours ago, Normynator said:

The if statement should look like this:

if ((.@amountPotion > .@amountBottle) || ([email protected] > .@amountHerb))

 

 

Thank you! Finally solved my hours of problem.. /no1 

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...

Important Information

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