UP,also
PHP Code:
chance(plr, maxcount, percent, sClass[], CSW_type=0, sName[]="") {
if( !maxcount || !percent ) {
return 0;
}
new count;
for( new i = 0; i < maxcount; i++ ) {
if( random_num(1, 100) <= percent )
{
if( count == 0 )
{
fm_give_item(plr, sClass);
}
count++;
}
}
if( count && CSW_type )
{
if( percent < 100 )
{
client_print(plr,print_chat, "You received %i %s%s! (%i%% chance)", count, sName, (count == 1) ? g_sBlank : g_sS, percent);
}
cs_set_user_bpammo(plr, CSW_type, count);
}
return 1;
}
chance(plr, get_pcvar_num(hns_grenades[team]), get_pcvar_num(hns_grenades_percent[team]),"weapon_hegrenade", CSW_HEGRENADE, "HE Grenade");
chance(plr, get_pcvar_num(hns_flashbangs[team]), get_pcvar_num(hns_flashbangs_percent[team]), "weapon_flashbang", CSW_FLASHBANG, "Flashbang");
chance(plr, get_pcvar_num(hns_smokegren[team]), get_pcvar_num(hns_smokegren_percent[team]), "weapon_smokegrenade", CSW_SMOKEGRENADE, "Smoke Grenade");