CSX module required.
Code:
//
#include <amxmodx>
#include <csx>
public plugin_init() {
register_plugin("SHoot Gun out of hand / throw gun", "0.1b2", "VEN")
register_event("CurWeapon", "event_clip_empty", "be", "1=1", "3=0")
}
public client_damage(attacker, victim, damage, wpnindex, hitplace, TA) {
if ((hitplace != HIT_RIGHTARM && hitplace != HIT_LEFTARM)
|| !attacker || !victim || !is_user_alive(victim))
return
new clip, ammo, wid = get_user_weapon(victim, clip, ammo)
if (wid != CSW_HEGRENADE && wid != CSW_SMOKEGRENADE
&& wid != CSW_FLASHBANG && wid != CSW_KNIFE)
drop_weapon(victim, wid, "Your hand is damaged!")
}
public event_clip_empty(id) {
new clip, ammo, wid = get_user_weapon(id, clip, ammo)
if (!ammo)
drop_weapon(id, wid, "Your gun is out of ammo!")
}
stock drop_weapon(id, wid, reason[]) {
new weapon[20]
get_weaponname(wid, weapon, 19)
engclient_cmd(id, "drop", weapon)
client_print(id, print_center, reason)
}