here, I made this for you:
<map>,<x>,<y>,<dir> script <name> <sprite>,{
mes("Hi there.");
mes("Can I help you?");
next();
select("claim reward");
mes("...");
next();
for (.@i = 0; .@i < .reward_len; .@i += 3) {
if (rand(100) < .reward[.@i + 2]) {
getitem(.reward[.@i], .reward[.@i + 1]);
mesf("You obtained %i %s.", .reward[.@i + 1], getitemname(.reward[.@i]));
.@reward = true; // got at least one reward
next();
}
}
if (.@reward != true) {
mes("It seems you're out of luck.");
next();
}
mes("Come back anytime!");
close;
OnInit:
setarray(.reward[0],
//ID,QTY,%
607, 5, 50,
608, 6, 52,
678, 4, 50,
672, 1, 2);
.reward_len = getarraysize(.reward);
}
hope it helps
UPDATE: added reward_len (sorry, forgot that)
.@rnd = rand(154);
if (.@rnd < 50) {
getitem(607, 5);
} else if (.@rnd < 102) {
getitem(608, 6);
} else if (.@rnd < 152) {
getitem(678, 4);
} else {
getitem(672, 1);
}
Yes i only want player to get any 1 items of the list with chance sir thanks a lotYou want the player to get only one item? Your percents make a total of 154% ...
list of items,qty / Chance
607,5 50%
608,6 52%
678,4 50%
672,1 2%
Try this:
.@rnd = rand(154);
if (.@rnd < 50) {
getitem(607, 5);
} else if (.@rnd < 102) {
getitem(608, 6);
} else if (.@rnd < 152) {
getitem(678, 4);
} else {
getitem(672, 1);
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.