viewing paste Unknown #45628 | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
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;
}
Viewed 952 times, submitted by Guest.