i want to set damage, dealt to the enemy, if hit into the head or in other body part. if it would be shot into the head, it would deduct 150 from victim's health and then set the damage that attacker did to victim to 150. same if other part of body than head would be hit, only the number is different. code:
Code:
public plugin_init() {
register_cvar( "amx_zombiebot_hsdamage", "150" )
register_cvar( "amx_zombiebot_damage", "10" )
register_event( "Damage", "ZombieDamage", "be" )
}
public ZombieDamage( id, hitplace, headshot ) {
if( get_cvar_num("amx_zombiebot") != 1 ) {
return PLUGIN_HANDLED
}
new hsdamage, damage, victim, vichealth, attacker, weap, attfrags, dmgtype
hsdamage = get_cvar_num( "amx_zombiebot_hsdamage" )
damage = get_cvar_num( "amx_zombiebot_damage" )
victim = id
vichealth = get_user_health( victim )
attacker = get_user_attacker( victim, weap )
attfrags = get_user_frags( attacker )
dmgtype = read_data( 3 )
if( !is_user_connected( attacker ) || !is_user_alive( victim )) {
return PLUGIN_HANDLED
}
if( is_user_bot( victim )) {
if( damage > 0 ){
if( hitplace == HIT_HEAD ) {
set_user_health( victim, vichealth - get_cvar_num("amx_zombiebot_hsdamage"))
switch(weap) {
case CSW_AK47: {
fakedamage( victim, "weapon_ak47", float(hsdamage), dmgtype )
}
// ...
case CSW_XM1014: {
fakedamage( victim, "weapon_xm1014", float(hsdamage), dmgtype )
}
}
}
if( hitplace != HIT_HEAD ) {
set_user_health( victim, vichealth - get_cvar_num("amx_zombiebot_damage"))
switch(weap) {
case CSW_AK47: {
fakedamage( victim, "weapon_ak47", float(damage), dmgtype )
}
// ...
case CSW_XM1014: {
fakedamage( victim, "weapon_xm1014", float(damage), dmgtype )
}
}
}
}
if( damage > vichealth ) {
switch(weap) {
case CSW_AK47: {
user_silentkill( victim )
make_deathmsg( attacker, victim, headshot, "ak47" )
}
// ...
case CSW_XM1014: {
user_silentkill( victim )
make_deathmsg( attacker, victim, headshot, "xm1014" )
}
}
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}