viewing paste Unknown #45626 | 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
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;
}
Viewed 1046 times, submitted by Guest.