Make something like this:
Code:
new const gWeaponLimits[] = {
// no limit, allow all weapons
0,
// limit 1 = M249
(1<<CSW_M249),
// limit 2 = scout, awp, sg550, g3sg1
(1<<CSW_SCOUT)|(1<<CSW_AWP)|(1<<CSW_SG550)|(1<<CSW_G3SG1),
// limit 3 = galil, famas, m4a1, ak47, aug, sg552
(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_M4A1)|(1<<CSW_AK47)|(1<<CSW_AUG)|(1<<CSW_SG551),
// limit 4 = mac10, tmp, mp5, ump45, p90
(1<<CSW_MAC10)|(1<<CSW_TMP)|(1<<CSW_MP5NAVY)|(1<<CSW_UMP45)|(1<<CSW_P90),
// limit 5 = m3, xm1014
(1<<CSW_M3)|(1<<CSW_XM1014),
// limit 6 = p228, deagle, fiveseven, elites
(1<<CSW_P228)|(1<<CSW_DEAGLE)|(1<<CSW_FIVESEVEN)|(1<<CSW_ELITE),
// limit 7 = usp, glock
(1<<CSW_USP)|(1<<CSW_GLOCK18)
};
Then here's your modified function:
Code:
public client_weapon_pickup(id)
{
new niveau_limitation = pl_limitation[id]
new Weapon = read_data(1);
for (new i = 1; i <= niveau_limitation && i < sizeof(gWeaponLimits); i++)
{
if(gWeaponLimits[i] & (1 << Weapon))
{
new data[3];
data[0] = id;
data[1] = get_user_userid(id);
data[2] = Weapon;
set_task(0.1, "TaskDropWeapon", id, data, sizeof(data));
break;
}
}
}
public TaskDropWeapon(data[])
{
new id = data[0];
if(!is_user_connected(id) || get_user_userid(id) != data[1])
{
return;
}
new Weapon = data[2];
if(!user_has_weapon(id, Weapon))
{
return;
}
new WeaponName[32];
get_weaponname(Weapon, WeaponName, charsmax(WeaponName));
engclient_cmd(id, "drop", WeaponName);
client_print(id, print_center, "%L", id, "LIMITATION_DROP")
}
Much better.
__________________