Jump to content
  • 0

Adding an item amount for this box


Question

Posted

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!

3 answers to this question

Recommended Posts

Posted (edited)

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
Posted


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
Posted

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

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