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 (.@i = 0; .@i < .@b; .@i++) {
if (.@chance - .@item_rate[.@i] <= 0) break;
}
getitem .@item_list[.@i], 1;
if (getarg(0))
delitem getarg(0), 1;
for (.@d = 0; .@d < .@c; .@d++)
if (.@item_list[.@i] == .@item_announce[.@d])
announce strcharinfo(0)+" Got a "+getitemname(.@item_list[.@i])+" from Random Box.",0;
end;
}