Falldmg is 100% for both teams (I need to lose a bit of time trying to figure this out)
PHP Code:
/* AMX Mod X script.
****************************************************************************
*
* Version 1.0 - Date: 16/05/2016
*
****************************************************************************
*
* Admin Commands:
*
* hns_tknives - Toggles Throwing Knives On and Off
*
* Client Commands:
*
* throw_knife - This is the command for everyone to throw knives
* say /knifehelp - Brings up knifehelp menu to help players bind keys
* say /throwingknives - Same as /knifehelp
*
* CVARs: Paste the following into your amxx.cfg to change defaults.
* must uncomment cvar lines for them to take effect
*
****************************************************************************
* CVAR CONFIG BEGIN
****************************************************************************
// ****************** Throwing Knives Setup ******************
//Toggles Throwing Knives on and off (default 0) ( 1 or 0 )
//hns_throwknives 1
//The amount of ammo to be given at roundstart (default 5) ( 1 or higher )
//hns_knifeammo 1
//Force at which knives are thrown (default 1200) ( 200 or higher )
//hns_knifetossforce 1200
//Maximum amount of knives allowed at once (default 10) ( hns_knifeammo or higher )
//hns_maxknifeammo 1
//Damage dealt on a knife hit (default 25) ( 1 or higher )
//hns_knifedmg 25
//Toggles knife dropping on death on and off (default 1) ( 1 or 0 )
//hns_dropknives 1
//Toggles autoswitching to knife when bind is pressed (default 1) ( 1 or 0 )
//hns_knifeautoswitch 1
//Toggles logging kill as "throwing_knife" or "knife" (default 0) (1 = throwing_knife, 0 = knife)
//hns_tknifelog 1
****************************************************************************
* CVAR CONFIG END
*****************************************************************************/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fun>
#include <fakemeta_util>
#include <hamsandwich>
// THROW KNIVES
new bool:knifeout[33]
new bool:roundfreeze
new Float:tossdelay[33]
new knifeammo[33]
new holdammo[33]
// HP ON KILL
new health_add_t
new health_hs_add_t
new health_add_ct
new health_hs_add_ct
new health_max
new nKiller
new nKiller_hp
new nHp_add
new nHp_max
/************************************************************
* CORE PLUGIN FUNCTIONS
************************************************************/
public plugin_init()
{
register_plugin("HNS VIP","1.0","quilhos")
register_event("ResetHUD","new_spawn","b")
register_event("CurWeapon","check_knife","b","1=1")
register_event("DeathMsg", "player_death", "a")
register_logevent("round_start", 2, "1=Round_Start")
register_logevent("round_end", 2, "1=Round_End")
register_clcmd("throw_knife","command_knife",0,"- throws a knife if the plugin is enabled")
register_concmd("hns_tknives","admin_tknife",ADMIN_LEVEL_C,"- toggles throwing knives on/off")
register_clcmd("say /knifehelp","knife_help")
register_clcmd("say /throwingknives","knife_help")
register_clcmd("say","HandleSay")
register_cvar("hns_throwknives","1",FCVAR_SERVER)
register_cvar("hns_knifeammo","1")
register_cvar("hns_knifetossforce","1200")
register_cvar("hns_maxknifeammo","1")
register_cvar("hns_knifedmg","25")
register_cvar("hns_dropknives","1")
register_cvar("hns_knifeautoswitch","1")
register_cvar("hns_tknifelog","0")
health_add_t = register_cvar("hns_vampire_hp", "40")
health_hs_add_t = register_cvar("amx_vampire_hp_hs", "40")
health_add_ct = register_cvar("hns_vampire_hp", "20")
health_hs_add_ct = register_cvar("hns_vampire_hp_hs", "20")
health_max = register_cvar("hns_vampire_max_hp", "100")
RegisterHam(Ham_TakeDamage, "player", "OnCBasePlayer_TakeDamage")
RegisterHam(Ham_Spawn, "player", "PlayerSpawnPost", 1);
check_cvars()
}
public plugin_precache()
{
precache_sound("weapons/knife_hitwall1.wav")
precache_sound("weapons/knife_hit4.wav")
precache_sound("weapons/knife_deploy1.wav")
precache_model("models/w_knifepack.mdl")
precache_model("models/w_throwingknife.mdl")
}
public check_cvars()
{
if (get_cvar_num("hns_knifeammo") > get_cvar_num("hns_maxknifeammo"))
{
server_print("[HNS] hns_knifeammo can not be greater than hns_maxknifeammo, adjusting hns_maxknifeammo")
set_cvar_num("hns_maxknifeammo",get_cvar_num("hns_knifeammo"))
}
if (get_cvar_num("hns_knifedmg") < 1 )
{
server_print("[HNS] hns_knifedmg can not be set lower than 1, setting cvar to 1 now.")
set_cvar_num("hns_knifedmg",0)
}
if (get_cvar_num("hns_knifetossforce") < 200 )
{
server_print("[HNS] hns_knifetossforce can not be set lower than 200, setting cvar to 200 now.")
set_cvar_num("hns_knifetossforce",200)
}
}
public plugin_modules()
{
require_module("fun")
require_module("engine")
}
public player_death()
{
new victim = read_data(2)
knife_drop(victim)
respawn_function(victim)
// HP ON KILL
nKiller = read_data(1)
nHp_max = get_pcvar_num (health_max)
if(get_user_flags(nKiller) & ADMIN_LEVEL_H )
{
if(cs_get_user_team(nKiller) == CS_TEAM_T)
{
if ( (read_data(3) == 1) && (read_data(5) == 0) )
{
nHp_add = get_pcvar_num (health_hs_add_t)
}
else
{
nHp_add = get_pcvar_num (health_add_t)
}
}
if(cs_get_user_team(nKiller) == CS_TEAM_CT)
{
if ( (read_data(3) == 1) && (read_data(5) == 0) )
{
nHp_add = get_pcvar_num (health_hs_add_ct)
}
else
{
nHp_add = get_pcvar_num (health_add_ct)
}
}
// Updating Killer HP
nKiller_hp = get_user_health(nKiller)
nKiller_hp += nHp_add
// Maximum HP check
if (nKiller_hp > nHp_max) nKiller_hp = nHp_max
set_user_health(nKiller, nKiller_hp)
// Hud message "Healed +15/+40 hp"
set_hudmessage(0, 255, 0, -1.0, 0.15, 0, 1.0, 1.0, 0.1, 0.1, -1)
show_hudmessage(nKiller, "Healed +%d hp", nHp_add)
}
}
public respawn_function(id)
{
if(get_user_flags(id) & ADMIN_LEVEL_H )
{
if(random_num(0, 100) <= 10)
{
ExecuteHamB(Ham_CS_RoundRespawn, id)
client_print(id,print_chat, "[HNS] Congratulations, you got another life (1/10)")
}
else
{
client_print(id,print_chat, "[HNS] You run out of luck and didnt get a respawn (1/10)")
}
}
}
public HandleSay(id)
{
new Speech[192]
read_args(Speech,192)
remove_quotes(Speech)
if(!equal(Speech, "vote",4) && ((containi(Speech, "knife") != -1) || (containi(Speech, "knives") != -1)))
{
if(get_cvar_num("hns_throwknives") == 1)
{
client_print(id,print_chat, "[HNS] Throwing Knives are ON - For help say /knifehelp")
}
else
{
client_print(id,print_chat, "[HNS] Throwing Knives are OFF")
}
}
}
public new_spawn(id)
{
if(knifeammo[id] < get_cvar_num("hns_knifeammo")) knifeammo[id] = get_cvar_num("hns_knifeammo")
if(knifeammo[id] > get_cvar_num("hns_maxknifeammo")) knifeammo[id] = get_cvar_num("hns_maxknifeammo")
tossdelay[id] = 0.0
}
public client_connect(id)
{
knifeammo[id] = get_cvar_num("hns_knifeammo")
holdammo[id] = 0
tossdelay[id] = 0.0
knifeout[id] = false
}
public client_disconnect(id)
{
knifeammo[id] = 0
holdammo[id] = 0
tossdelay[id] = 0.0
knifeout[id] = false
}
public round_start()
{
roundfreeze = false
}
public round_end()
{
roundfreeze = true
kill_all_entity("throwing_knife")
kill_all_entity("knife_pickup")
}
public PlayerSpawnPost(id)
{
if(is_user_alive(id))
{
if(get_user_flags(id) & ADMIN_LEVEL_H )
{
if(cs_get_user_team(id) == CS_TEAM_T)
{
GiveItem( id, "weapon_hegrenade", CSW_HEGRENADE, 2 );
}
if(cs_get_user_team(id) == CS_TEAM_CT)
{
GiveItem( id, "weapon_hegrenade", CSW_HEGRENADE, 1 );
}
set_user_footsteps(id,1)
}
}
}
stock GiveItem( const index, Class[], Index = 0, Ammo = 0 )
{
fm_give_item( index, Class );
if ( equali( Class, "weapon_knife" ) )
return 1;
cs_set_user_bpammo( index, Index, Ammo );
return 1;
}
// NO FALL DMG
public OnCBasePlayer_TakeDamage( id, iInflictor, iAttacker, Float:flDamage, bitsDamageType ) // return int
{
if( bitsDamageType & DMG_FALL )
{
if (get_user_flags(id) & ADMIN_LEVEL_H)
{
return HAM_SUPERCEDE
}
}
return HAM_IGNORED
}
///////////////////////
// THROW KNIFE START //
///////////////////////
public knife_drop(id)
{
if(!get_cvar_num("hns_dropknives") || knifeammo[id] <= 0 || !get_cvar_num("hns_throwknives")) return
new Float: Origin[3], Float: Velocity[3]
entity_get_vector(id, EV_VEC_origin, Origin)
new knifedrop = create_entity("info_target")
if(!knifedrop) return
entity_set_string(knifedrop, EV_SZ_classname, "knife_pickup")
entity_set_model(knifedrop, "models/w_knifepack.mdl")
new Float:MinBox[3] = {-1.0, -1.0, -1.0}
new Float:MaxBox[3] = {1.0, 1.0, 1.0}
entity_set_vector(knifedrop, EV_VEC_mins, MinBox)
entity_set_vector(knifedrop, EV_VEC_maxs, MaxBox)
entity_set_origin(knifedrop, Origin)
entity_set_int(knifedrop, EV_INT_effects, 32)
entity_set_int(knifedrop, EV_INT_solid, 1)
entity_set_int(knifedrop, EV_INT_movetype, 6)
entity_set_edict(knifedrop, EV_ENT_owner, id)
VelocityByAim(id, 400 , Velocity)
entity_set_vector(knifedrop, EV_VEC_velocity ,Velocity)
holdammo[id] = knifeammo[id]
knifeammo[id] = 0
}
public check_knife(id)
{
if(!get_cvar_num("hns_throwknives")) return
new weapon = read_data(2)
if(weapon == CSW_KNIFE)
{
knifeout[id] = true
/*if(knifeammo[id] > 1) {
client_print(id, print_center,"You have %d knives",knifeammo[id])
}
else if(knifeammo[id] == 1) {
client_print(id, print_center,"You have %d knife",knifeammo[id])
}*/
if (get_user_flags(id) & ADMIN_LEVEL_H)
{
if(cs_get_user_team(id) == CS_TEAM_T)
{
client_print(id, print_center,"You have %d throwing %s",knifeammo[id], knifeammo[id] == 1 ? "knife" : "knives")
}
}
}
else
{
knifeout[id] = false
}
}
public kill_all_entity(classname[])
{
new iEnt = find_ent_by_class(-1, classname)
new tEnt
while(iEnt > 0)
{
tEnt = iEnt
iEnt = find_ent_by_class(iEnt, classname)
remove_entity(tEnt)
}
}
public vexd_pfntouch(pToucher, pTouched)
{
if ( !is_valid_ent(pToucher) ) return
if (!get_cvar_num("hns_throwknives")) return
new Classname[32]
entity_get_string(pToucher, EV_SZ_classname, Classname, 31)
new owner = entity_get_edict(pToucher, EV_ENT_owner)
new Float:kOrigin[3]
entity_get_vector(pToucher, EV_VEC_origin, kOrigin)
if(equal(Classname,"knife_pickup"))
{
if ( !is_valid_ent(pTouched) ) return
check_cvars()
new Class2[32]
entity_get_string(pTouched, EV_SZ_classname, Class2, 31)
if(!equal(Class2,"player") || knifeammo[pTouched] >= get_cvar_num("hns_maxknifeammo")) return
if((knifeammo[pTouched] + holdammo[owner]) > get_cvar_num("hns_maxknifeammo")) {
holdammo[owner] -= get_cvar_num("hns_maxknifeammo") - knifeammo[pTouched]
knifeammo[pTouched] = get_cvar_num("hns_maxknifeammo")
emit_sound(pToucher, CHAN_ITEM, "weapons/knife_deploy1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
else {
knifeammo[pTouched] += holdammo[owner]
emit_sound(pToucher, CHAN_ITEM, "weapons/knife_deploy1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_entity(pToucher)
}
client_print(pTouched, print_center,"You have %i knives",knifeammo[pTouched])
}
else if(equal(Classname,"throwing_knife")) {
check_cvars()
if(is_user_alive(pTouched)) {
new movetype = entity_get_int(pToucher, EV_INT_movetype)
if(movetype == 0 && knifeammo[pTouched] < get_cvar_num("hns_maxknifeammo")) {
if(knifeammo[pTouched] < get_cvar_num("hns_maxknifeammo")) knifeammo[pTouched] += 1
client_print(pTouched,print_center,"You have %i knives",knifeammo[pTouched])
emit_sound(pToucher, CHAN_ITEM, "weapons/knife_deploy1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_entity(pToucher)
}
else if (movetype != 0) {
if(owner == pTouched) return
remove_entity(pToucher)
if(get_cvar_num("mp_friendlyfire") == 0 && get_user_team(pTouched) == get_user_team(owner)) return
new pTdead[33]
entity_set_float(pTouched, EV_FL_dmg_take, get_cvar_num("hns_knifedmg") * 1.0)
if((get_user_health(pTouched) - get_cvar_num("hns_knifedmg")) <= 0) {
pTdead[pTouched] = 1
}
else {
set_user_health(pTouched, get_user_health(pTouched) - get_cvar_num("hns_knifedmg"))
}
if(get_user_team(pTouched) == get_user_team(owner)) {
new name[33]
get_user_name(owner,name,32)
client_print(0,print_chat,"%s attacked a teammate",name)
}
emit_sound(pTouched, CHAN_ITEM, "weapons/knife_hit4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
if(pTdead[pTouched]) {
if(get_user_team(pTouched) == get_user_team(owner)) {
set_user_frags(owner, get_user_frags(owner) - 1)
client_print(owner,print_center,"You killed a teammate")
}
else {
set_user_frags(owner, get_user_frags(owner) + 1)
}
new gmsgScoreInfo = get_user_msgid("ScoreInfo")
new gmsgDeathMsg = get_user_msgid("DeathMsg")
//Kill the victim and block the messages
set_msg_block(gmsgDeathMsg,BLOCK_ONCE)
set_msg_block(gmsgScoreInfo,BLOCK_ONCE)
user_kill(pTouched,1)
//Update killers scorboard with new info
message_begin(MSG_ALL,gmsgScoreInfo)
write_byte(owner)
write_short(get_user_frags(owner))
write_short(get_user_deaths(owner))
write_short(0)
write_short(get_user_team(owner))
message_end()
//Update victims scoreboard with correct info
message_begin(MSG_ALL,gmsgScoreInfo)
write_byte(pTouched)
write_short(get_user_frags(pTouched))
write_short(get_user_deaths(pTouched))
write_short(0)
write_short(get_user_team(pTouched))
message_end()
//Replaced HUD death message
message_begin(MSG_ALL,gmsgDeathMsg,{0,0,0},0)
write_byte(owner)
write_byte(pTouched)
write_byte(0)
write_string("knife")
message_end()
new tknifelog[16]
if (get_cvar_num("hns_tknifelog")) tknifelog = "throwing_knife"
else tknifelog = "knife"
new namea[32], authida[35], teama[32]
new namev[32], authidv[35], teamv[32]
get_user_name(owner,namea,31)
get_user_authid(owner,authida,34)
get_user_team(owner,teama,31)
get_user_name(pTouched,namev,31)
get_user_authid(pTouched,authidv,34)
get_user_team(pTouched,teamv,31)
log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^"",
namea,get_user_userid(owner),authida,teama,namev,get_user_userid(pTouched),authidv,teamv,tknifelog)
}
}
}
else {
entity_set_int(pToucher, EV_INT_movetype, 0)
emit_sound(pToucher, CHAN_ITEM, "weapons/knife_hitwall1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
}
}
public command_knife(id)
{
if (get_user_flags(id) & ADMIN_LEVEL_H)
{
if(cs_get_user_team(id) == CS_TEAM_T)
{
if(!is_user_alive(id) || !get_cvar_num("hns_throwknives") || roundfreeze)
return PLUGIN_HANDLED
if(get_cvar_num("hns_knifeautoswitch"))
{
knifeout[id] = true
//engclient_cmd(id,"weapon_knife")
client_cmd(id,"weapon_knife")
}
if(!knifeammo[id])
client_print(id,print_center,"You are out of knives",knifeammo[id])
if(!knifeout[id] || !knifeammo[id])
return PLUGIN_HANDLED
if(tossdelay[id] > get_gametime() - 0.5)
return PLUGIN_HANDLED
else
tossdelay[id] = get_gametime()
knifeammo[id]--
if (knifeammo[id] == 1)
{
client_print(id,print_center,"You have %i knife",knifeammo[id])
}
else
{
client_print(id,print_center,"You have %i knives",knifeammo[id])
}
new Float: Origin[3], Float: Velocity[3], Float: vAngle[3], Ent
entity_get_vector(id, EV_VEC_origin , Origin)
entity_get_vector(id, EV_VEC_v_angle, vAngle)
Ent = create_entity("info_target")
if (!Ent) return PLUGIN_HANDLED
entity_set_string(Ent, EV_SZ_classname, "throwing_knife")
entity_set_model(Ent, "models/w_throwingknife.mdl")
new Float:MinBox[3] = {-1.0, -7.0, -1.0}
new Float:MaxBox[3] = {1.0, 7.0, 1.0}
entity_set_vector(Ent, EV_VEC_mins, MinBox)
entity_set_vector(Ent, EV_VEC_maxs, MaxBox)
vAngle[0] -= 90
entity_set_origin(Ent, Origin)
entity_set_vector(Ent, EV_VEC_angles, vAngle)
entity_set_int(Ent, EV_INT_effects, 2)
entity_set_int(Ent, EV_INT_solid, 1)
entity_set_int(Ent, EV_INT_movetype, 6)
entity_set_edict(Ent, EV_ENT_owner, id)
VelocityByAim(id, get_cvar_num("hns_knifetossforce") , Velocity)
entity_set_vector(Ent, EV_VEC_velocity ,Velocity)
return PLUGIN_HANDLED
}
else
{
client_print(id,print_center,"You have to be a terrorist to be able to throw a knife.")
}
return PLUGIN_HANDLED
}
else
{
client_print(id,print_center,"You have to be VIP to be able to throw a knife.")
}
return PLUGIN_HANDLED
}
public admin_tknife(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new authid[35],name[32]
get_user_authid(id,authid,34)
get_user_name(id,name,31)
if(get_cvar_num("hns_throwknives") == 0){
set_cvar_num("hns_throwknives",1)
client_print(0,print_chat,"[HNS] Admin has enabled throwing knives")
console_print(id,"[HNS] You have enabled throwing knives")
log_amx("Admin: ^"%s<%d><%s><>^" enabled throwing knives",name,get_user_userid(id),authid)
}
else {
set_cvar_num("hns_throwknives",0)
client_print(0,print_chat,"[HNS] Admin has disabled throwing knives")
console_print(id,"[HNS] You have disabled throwing knives")
log_amx("Admin: ^"%s<%d><%s><>^" disabled throwing knives",name,get_user_userid(id),authid)
}
return PLUGIN_HANDLED
}
/************************************************************
* MOTD Popups
************************************************************/
public knife_help(id)
{
new len = 1024
new buffer[1025]
new n = 0
#if !defined NO_STEAM
n += copy(buffer[n],len-n,"<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</style></head><body><pre>")
#endif
n += copy( buffer[n],len-n,"To use your knives have to bind a key to:^n^n throw_knife^n^n")
n += copy( buffer[n],len-n,"In order to bind a key you must open your console and use the bind command: ^n^n")
n += copy( buffer[n],len-n,"bind ^"key^" ^"command^" ^n^n")
n += copy( buffer[n],len-n,"In this case the command is ^"throw_knife^". Here are some examples:^n^n")
n += copy( buffer[n],len-n," bind f throw_knife bind MOUSE3 throw_knife^n^n")
n += copy( buffer[n],len-n,"- If a knife is thrown, you may pick it up when it stops moving ^n")
n += copy( buffer[n],len-n,"- Knives are FF sensitive, you can hurt your teammates if FF is on^n")
n += copy( buffer[n],len-n,"- Your knife ammo will show in the center of your screen^n")
n += copy( buffer[n],len-n,"- You will get credit for knife kills on the scoreboard^n^n")
n += copy( buffer[n],len-n,"Start your knifing and Have fun!")
#if !defined NO_STEAM
n += copy( buffer[n],len-n,"</pre></body></html>")
#endif
show_motd(id,buffer ,"Throwing Knife Help:")
return PLUGIN_CONTINUE
}
/////////////////////
// THROW KNIFE END //
/////////////////////