Jump to content
  • 0

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


Question

Posted (edited)

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

4 answers to this question

Recommended Posts

  • 0
Posted
17 hours ago, Normynator said:

The if statement should look like this:


if ((.@amountPotion > .@amountBottle) || (.@amountPotion > .@amountHerb))

 

 

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

  • 0
Posted

you could also use this too.

// Player input
input .@amountPotion, 0, min(.@amountBottle, .@amountHerb);

limit the max value of input from player.

  • 0
Posted
On 4/23/2019 at 2:35 PM, Emistry said:

you could also use this too.


// Player input
input .@amountPotion, 0, min(.@amountBottle, .@amountHerb);

limit the max value of input from player.

Thank you! I will try it.. ^_^

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...