Jump to content
  • 0

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


rakuzas

Question


  • Group:  Members
  • Topic Count:  152
  • Topics Per Day:  0.04
  • Content Count:  459
  • Reputation:   6
  • Joined:  06/29/12
  • Last Seen:  

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

  • 1

  • Group:  Developer
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   199
  • Joined:  05/03/13
  • Last Seen:  

The if statement should look like this:

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

 

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  152
  • Topics Per Day:  0.04
  • Content Count:  459
  • Reputation:   6
  • Joined:  06/29/12
  • Last Seen:  

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 

Link to comment
Share on other sites

  • 0

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

you could also use this too.

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

limit the max value of input from player.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  152
  • Topics Per Day:  0.04
  • Content Count:  459
  • Reputation:   6
  • Joined:  06/29/12
  • Last Seen:  

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

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