or, on your custom item, inside { Script }, give callfunc that call your function to give random item to player.
itemid,,,,,,,,,,,,,,,,,,,{ callfunc CustomRand; }
function%tab%script%tab%CustomRand%tab%{
switch(rand(2)){
case 0: getitem 501; break;
case 1: getitem 502; break;
}
}