PHP Code:
public doDamage(id){
if (get_cvar_num("sv_xweapons")==0){
return PLUGIN_CONTINUE
}
new plrDmg = read_data(2)
new plrWeap
new plrPartHit
new plrAttacker = get_user_attacker(id, plrWeap, plrPartHit)
if (!xmp5_carrier[plrAttacker] && !xm3_carrier[plrAttacker] && !xarmor_carrier[plrAttacker] && !xkevlar_carrier[plrAttacker] && !xknife_carrier[plrAttacker] && !xrevolver_carrier[plrAttacker]){
return PLUGIN_CONTINUE
}
if (!is_user_alive(id)){
return PLUGIN_CONTINUE
}
new plrHealth = get_user_health(id)
new plrNewDmg
new headshot
if (plrPartHit==1){
headshot=1
}else{
headshot=0
}
//
// plrDmg is set to how much damage was done to the victim
// plrHealth is set to how much health the victim has
// plrAttacker is set to the id of the person doing the shooting
//
// Could have put the above on one line, didn't for learning purposes (nubs may read this!) lol
// Example: new plrWeap, plrPartHit, plrAttacker = get_user_attacker( .. etc etc
//
if (plrWeap == CSW_MP5NAVY && xmp5_carrier[plrAttacker]){
// If the victim is still alive.. (should be)
plrDmg = floatround(float(plrDmg) * weapdamg[Uweapid[plrAttacker]])
plrNewDmg = (plrHealth - plrDmg)
//
// Make the new damage their current health - plrDmg..
// This is actually damage 2x, becuase when they did the damage
// lets say it was 10, now this is subtracting 10 from current heatlh
// doing 20, so thats 2 times =D
//
if(plrNewDmg < 1){
// If the new damage will kill the player..
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0)
// Start a death message, so it doesnt just say "Player Died",
// the killer will get the credit
write_byte(plrAttacker)
// Write KILLER ID
write_byte(id)
// Write VICTIM ID
write_byte(headshot)
// Write HEAD SHOT or not
write_string("mp5navy")
// Write the weapon VICTIM ID was killed with..
message_end()
// End the message..
fm_set_user_frags(id, get_user_frags(id)+1)
fm_set_user_frags(plrAttacker, get_user_frags(plrAttacker)+1)
}
fm_set_user_health(id, plrNewDmg)
// Then set the health, even if it will kill the player
}
if (plrWeap == CSW_M3 && xm3_carrier[plrAttacker]){
plrDmg = floatround(float(plrDmg) * weapdamg[Uweapid[plrAttacker]])
plrNewDmg = (plrHealth - plrDmg)
if(plrNewDmg < 1){
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0)
write_byte(plrAttacker)
write_byte(id)
write_byte(headshot)
write_string("m3")
message_end()
fm_set_user_frags(id, get_user_frags(id)+1)
fm_set_user_frags(plrAttacker, get_user_frags(plrAttacker)+1)
}
fm_set_user_health(id, plrNewDmg)
// Then set the health, even if it will kill the player
}
if (plrWeap == CSW_KNIFE && xknife_carrier[plrAttacker]){
plrDmg = floatround(float(plrDmg) * weapdamg[Uweapid[plrAttacker]])
plrNewDmg = (plrHealth - plrDmg)
if(plrNewDmg < 1){
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0)
write_byte(plrAttacker)
write_byte(id)
write_byte(headshot)
write_string("knife")
message_end()
fm_set_user_frags(id, get_user_frags(id)+1)
fm_set_user_frags(plrAttacker, get_user_frags(plrAttacker)+1)
}
fm_set_user_health(id, plrNewDmg)
// Then set the health, even if it will kill the player
}
if (plrWeap == CSW_DEAGLE && xrevolver_carrier[plrAttacker]){
if(random_num(1,99) <= LOKO_BULLET){
new origin[3]
get_user_origin(plrAttacker,origin)
// random explosions
message_begin( MSG_PVS, SVC_TEMPENTITY, origin )
write_byte( TE_EXPLOSION) // This just makes a dynamic light now
write_coord( origin[0] + random_num( -100, 100 ))
write_coord( origin[1] + random_num( -100, 100 ))
write_coord( origin[2] + random_num( -50, 50 ))
write_short( g_sModelFireball )
write_byte( random_num(0,20) + 20 ) // scale * 10
write_byte( 12 ) // framerate
write_byte( TE_EXPLFLAG_NONE )
message_end()
// lots of smoke
message_begin( MSG_PVS, SVC_TEMPENTITY, origin )
write_byte( TE_SMOKE )
write_coord( origin[0] + random_num( -100, 100 ))
write_coord( origin[1] + random_num( -100, 100 ))
write_coord( origin[2] + random_num( -50, 50 ))
write_short( g_sModelSmoke )
write_byte( 60 ) // scale * 10
write_byte( 10 ) // framerate
message_end()
new randomdamage = get_user_health(plrAttacker) - random_num( 60, 120 )
fm_set_user_health(plrAttacker, randomdamage)
client_print(plrAttacker,print_chat,"[KPS-X] Hey, that crazy bullet just tore your head off!")
}
plrDmg = floatround(float(plrDmg) * weapdamg[Uweapid[plrAttacker]])
plrNewDmg = (plrHealth - plrDmg)
if(plrNewDmg < 1){
message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0)
write_byte(plrAttacker)
write_byte(id)
write_byte(headshot)
write_string("deagle")
message_end()
fm_set_user_frags(id, get_user_frags(id)+1)
fm_set_user_frags(plrAttacker, get_user_frags(plrAttacker)+1)
}
fm_set_user_health(id, plrNewDmg)
// Then set the health, even if it will kill the player
}
if (xarmor_carrier[plrAttacker] && get_user_armor(id) >= 1){
new armordmg
armordmg = floatround(float(plrDmg) * MOD_ARMOR)
fm_set_user_armor(id,get_user_armor(id)-armordmg)
}
if (xkevlar_carrier[id] && is_user_alive(id)){
new kevldmg
kevldmg = floatround((float(plrDmg) * MOD_KEVLAR)+float(plrHealth))
fm_set_user_health(id, kevldmg)
}
return PLUGIN_CONTINUE
}