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!