Jump to content
  • 0

Adding an item amount for this box


Dori

Question


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  332
  • Reputation:   15
  • Joined:  12/11/11
  • Last Seen:  

I found this script on another topic made by Capuche. I want to be able to add an amount to the items received from the box.

 

So for example: Apple x2

                          Orange x1

                          Red Potion x3

 

Here is the script:

 

function	script	rewardchest	{
	setarray .@reward,  20103, 60,
						20104, 10,
						20105, 10,
						20106, 10,
						20106, 5,
						20107, 5;
	.@size = getarraysize( .@reward );
	for( set .@i, 1; .@i < .@size; .@i += 2 )
		.@percent[.@i] += .@reward[.@i];
	.@r = rand( .@percent[ .@size -1 ] +1 );
	for( set .@i, 1; .@i < .@size; .@i += 2 )
		if( .@percent[.@i] > .@r )
			break;
	getitem .@reward[ .@i-1 ], 1;
	return;
}
Thanks in advance for any help!
Link to comment
Share on other sites

3 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  332
  • Reputation:   15
  • Joined:  12/11/11
  • Last Seen:  

I tried it out, but I keep getting the first item on the list. I don't get any of the other items.
Here is what I have:
 

function	script	rewardchest	{
	setarray .@reward,  501,1, 60,
						502,2, 40,
						503,1, 40,
						504,4, 30,
						505,1, 20,
						506,2, 10;
	.@size = getarraysize( .@reward );
	for( set .@i, 2; .@i < .@size; .@i += 3 )
		.@percent[.@i] += .@reward[.@i];
	.@r = rand( .@percent[ .@size -1 ] +1 );
	for( set .@i, 2; .@i < .@size; .@i += 3 )
		if( .@percent[.@i] > .@r )
			break;
	getitem .@reward[ .@i-2 ], .@reward[ .@i-1 ];
	return;
}

EDIT: Nevermind, I found a better way of doing this using the item_package.txt Thanks anyways Capuche!

Edited by Phenex
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  


function script rewardchest {

setarray .@reward, 20103,1, 60,

20104,1, 10,

20105,1, 10,

20106,1, 10,

20106,1, 5,

20107,1, 5;

.@size = getarraysize( .@reward );

for( set .@i, 2; .@i < .@size; .@i += 3 )

.@percent[.@i] += .@reward[.@i];

.@r = rand( .@percent[ .@size -1 ] +1 );

for( set .@i, 2; .@i < .@size; .@i += 3 )

if( .@percent[.@i] > .@r )

break;

getitem .@reward[ .@i-2 ], .@reward[ .@i-1 ];

return;

}

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

EDIT: Nevermind, I found a better way of doing this using the item_package.txt Thanks anyways Capuche!

meh I just want to say it, try use item package /heh
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...