Jump to content
  • 0

Item Box problem. Array just read 2 Item from my list.


mrfizi

Question


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   46
  • Joined:  10/30/12
  • Last Seen:  

Item Box problem. Array just read 2 Item from my list.

function	script	ROMYAngelScroll	{
	setarray .i1[0],13758,12221,7621; // Common Items
	set .i1rand,rand(0,1); 
	
	setarray .i2[0],12259,12437,12412; // Rare Items 11-15%
	set .i2rand,rand(0,1); 
	
	setarray .i3[0],18526,5660; // Rare Items 16-40%
	set .i3rand,rand(0,1); 
	
	setarray .i4[0],19859,20500,5505; // Super Rare Items
	set .i4rand,rand(0,1); 
	
	set .chance, rand(100);

		// Super Rare Item 1-10%
		if (.chance >= 1 && .chance <= 10){
		getitem .i4[ .i4rand ],1;
		announce "["+strcharinfo(0)+"] has just obtained a ["+getitemname(.i4[ .i4rand ])+"] from the Angel Scroll.",0;
		end;
		} 

		// Rare Item 11-15%
		else if (.chance >= 11 && .chance <= 15){
		getitem .i3[ .i3rand ],1;
		end;
		} 		
		
		// Rare Item 16-35%
		else if (.chance >= 16 && .chance <= 35){
		getitem .i2[ .i2rand ],3;
		end;
		} 

		// Common Items
		else if (.chance >= 36 && .chance <= 100) {
		getitem .i1[ .i1rand ],1;
		end; }
}

Above is script that I'm using for my custom box. I got problem with this script. setarray just read only 2 item from my list.

setarray .i1[0],13758,12221,7621;  // <=---- example this line, i put 3 item, but only 2 item 13758 and 12221 i can get from my box. Even I tried 200 times, still not got item 7621.

 

Hope someone can help me about this. Thank you. 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

your rand is only for arrays 0~1 if you have 3 items on your array you need the rand to be 0~2.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   46
  • Joined:  10/30/12
  • Last Seen:  

Just now, crazyarashi said:

your rand is only for arrays 0~1 if you have 3 items on your array you need the rand to be 0~2.

Thank you for your fast reply. It's work now. Thank you so much. /lv

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  626
  • Reputation:   188
  • Joined:  11/19/11
  • Last Seen:  

Also prevent the usage of. Variables, they are permanently saved until server restart.

Better use .@ Variables as they are automatically deleted when the script ends.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   46
  • Joined:  10/30/12
  • Last Seen:  

On 10/22/2018 at 3:03 AM, llchrisll said:

Also prevent the usage of. Variables, they are permanently saved until server restart.

Better use .@ Variables as they are automatically deleted when the script ends.

Thank you.

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