use my function its much easier
21031,Caja_1,Caja de Nivel,2,0,,0,,,,,0xFFFFFFFF,63,2,,,70,,2000,{ callfunc "F_RandWeight",501,1,502,1503,1,504,1; },{},{}
the chance will be item weight/total weight, in the above example each potion has a 1 weight with 4 total items meaning 1/4 chance