function script Rnd_Item {
setarray .@item_list, 501, 502;
setarray .@item_rate, 100, 1;
setarray .@item_announce, 501, 502;
.@a = getarraysize(.@item_list);
.@b = getarraysize(.@item_rate);
.@c = getarraysize(.@item_announce);
if (.@a != .@b) {
message strcharinfo(0),"Error! Tell Administrator. Source: Rnd_Item";
end;
}
for (.@i = 0; .@i < .@b; .@i++)
.@count_temp = .@count_temp + .@item_rate[.@i];
.@chance = rand(.@count_temp);
for (.@x = 0; .@x < .@b; .@x++) {
.@chance = .@chance - .@item_rate[.@x];
if (.@chance <= 0) break;
}
getitem .@item_list[.@x], 1;
if (getarg(0))
delitem getarg(0), 1;
for (.@d = 0; .@d < .@c; .@d++)
if (.@item_list[.@x] == .@item_announce[.@d])
announce strcharinfo(0)+" Got a "+getitemname(.@item_list[.@i])+" from Random Box.",0;
end;
}