#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <reapi>
#define PLUGIN "[DR] Knifes"
#define VERSION "1.0"
#define AUTHOR "BiZoN"
#define ADMIN_FLAG ADMIN_BAN // Ôëàã Àäìèíà
#define VIP_FLAG ADMIN_LEVEL_H // Ôëàã Âèïà
#define DIAMOND_FLAG ADMIN_LEVEL_D // Ôëàã Diamond player
#define REGENERATION_DELAY 1.0 // Âðåìÿ äî ðåãåíåðàöèè
#define REGENERATION_STEP 1 // Íàñêîëüêî óâåëè÷èâàòü HP
#define REGENERATION_MAX 100 // Ìàêñèìàëüíîå êîë-âî HP
#define Ham_CS_Player_ResetMaxSpeed Ham_Item_PreFrame
new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_0
new szTwoJump[33]
new szTwoJumpNum[33]
new szDoTwoJump[33]
new KnifeId[33]
public plugin_precache()
{
precache_model("models/v_knife.mdl")
precache_model("models/knifes/v_gravit.mdl")
precache_model("models/knifes/v_skoros.mdl")
precache_model("models/knifes/v_molot.mdl")
precache_model("models/knifes/v_vip.mdl")
precache_model("models/knifes/v_admin.mdl")
precache_model("models/p_knife.mdl")
precache_model("models/knifes/p_gravit.mdl")
precache_model("models/knifes/p_skoros.mdl")
precache_model("models/knifes/p_molot.mdl")
precache_model("models/knifes/p_vip.mdl")
precache_model("models/knifes/p_admin.mdl")
precache_sound("knifes/health.wav")
precache_sound("knifes/blink_hitwall1.wav")
precache_sound("knifes/katana_hitwall1.wav")
precache_sound("knifes/ibuki_hitwall1.wav")
precache_sound("knifes/ibuki_slash1.wav")
precache_sound("knifes/ibuki_deploy1.wav")
precache_sound("knifes/balrog9_hit1.wav")
precache_sound("knifes/ferrane_hitwall1.wav")
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_menu("Menu 1", keys, "menu_knife")
register_clcmd("say /knife", "knife_menu")
register_clcmd("say_team /knife", "knife_menu")
register_clcmd("knife", "knife_menu")
register_clcmd("knifes", "knife_menu")
register_clcmd("noz", "knifead")
RegisterHam(Ham_CS_Player_ResetMaxSpeed, "player", "OnCBasePlayer_ResetMaxSpeed_P", true);
RegisterHam(Ham_Item_Deploy, "weapon_knife", "SetKnife", 1)
RegisterHam(Ham_Item_Holster, "weapon_knife", "KnifeSet", 1)
RegisterHam(Ham_TakeDamage, "player", "EventDamage", 0)
RegisterHam(Ham_TakeDamage, "player", "TakeDamage", .Post = true)
RegisterHam(Ham_Killed, "player", "KilledPost", .Post = true)
RegisterHam(Ham_Player_Jump, "player", "PreTwoJump")
register_forward(FM_EmitSound, "EmitSound")
}
public client_connect(id)
{
KnifeId[id] = 6
}
public client_disconnected(nClientIndex)
{
remove_task(nClientIndex)
}
public knife_menu(id)
{
static menu[650], iLen
iLen = 0
iLen = formatex(menu[iLen], charsmax(menu) - iLen, "\yÌåíþ \rÍîæåé^n^n")
if(!is_user_connected(id))
return PLUGIN_CONTINUE
if(get_user_flags(id) & DIAMOND_FLAG)
{
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1. \yThanantos 9 \d(\r2 ðåæèìà + 2 ïðûæêà\d) [\rDiamond\d]^n")
keys |= MENU_KEY_1
}else{
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r1. \dThanantos 9 (\r2 ðåæèìà + 2 ïðûæêà\d) [\rDiamond\d]^n")
}
if(get_user_flags(id) & ADMIN_FLAG)
{
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r2. \yBlink \d(\râñå àáèëèòè\d) [\rÀäìèí\d]^n")
keys |= MENU_KEY_2
}else{
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r2. \dBlink (\râñå àáèëèòè\d) [\rÀäìèí\d]^n")
}
if(get_user_flags(id) & VIP_FLAG)
{
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r3. \yKatana \d(\r2õ ïðûæîê\d) [\rV.I.P\d]^n")
keys |= MENU_KEY_3
}else{
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r3. \dKatana (\r2õ ïðûæîê\d) [\rV.I.P\d]^n")
}
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r4. \yIbuki \d(\r2õ óðîí\d)^n")
keys |= MENU_KEY_4
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r5. \yTerari \d(\rñêîðîñòü +\d)^n")
keys |= MENU_KEY_5
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r6. \yFerrane \d(\rãðàâèòàöèÿ -\d)^n")
keys |= MENU_KEY_5
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r7. \yStandart \d(\rðåãåíåðàöèÿ HP\d)^n^n")
keys |= MENU_KEY_4
iLen += formatex(menu[iLen], charsmax(menu) - iLen, "\r0. \wÂûõîä^n")
keys |= MENU_KEY_0
show_menu(id, keys, menu, -1, "Menu 1")
return PLUGIN_HANDLED
}
public menu_knife(id, key)
{
switch(key)
{
case 0:
{
if(get_user_flags(id) & DIAMOND_FLAG)
{
KnifeId[id] = 0
ColorChat(id, GREEN, "[^4Thanantos 9^1] Ñïîñîáíîñòü: ^4 2 ðåæèìà + 2 ïðûæêà + ãðàâèòàöèÿ")
}
}
case 1:
{
if(get_user_flags(id) & ADMIN_FLAG)
{
KnifeId[id] = 1
ColorChat(id, GREEN, "[^4Blink^1] Ñïîñîáíîñòü: ^4âñå àáèëèòè")
}
}
case 2:
{
if(get_user_flags(id) & VIP_FLAG)
{
KnifeId[id] = 2
ColorChat(id, GREEN, "[^4Katana^1] Ñïîñîáíîñòü: ^4äâîéíîé ïðûæîê")
}
}
case 3:
{
KnifeId[id] = 3
ColorChat(id, GREEN, "[^4Ibuki^1] Ñïîñîáíîñòü: ^4äâîéíîé óðîí")
}
case 4:
{
KnifeId[id] = 4
ColorChat(id, GREEN, "[^4Terari^1] Ñïîñîáíîñòü: ^4ïîâûøåííàÿ ñêîðîñòü")
}
case 5:
{
KnifeId[id] = 5
ColorChat(id, GREEN, "[^4Ferrane^1] Ñïîñîáíîñòü: ^4ïîíèæåííàÿ ãðàâèòàöèÿ")
}
case 6:
{
KnifeId[id] = 6
ColorChat(id, GREEN, "[^4Standart^1] Ñïîñîáíîñòü: ^4ðåãåíåðàöèÿ HP")
}
}
return PLUGIN_HANDLED
}
public SetKnife(weapon)
{
new id = get_pdata_cbase(weapon, 41, 4)
if(!is_user_connected(id))
return PLUGIN_CONTINUE
if(KnifeId[id] == 0)
{
client_cmd(id,"give_elite")
set_pev(id, pev_gravity, 0.8)
szTwoJump[id] = true
}
if(KnifeId[id] == 1)
{
set_pev(id, pev_viewmodel2, "models/knifes/v_admin.mdl")
set_pev(id, pev_weaponmodel2, "models/knifes/p_admin.mdl")
set_pdata_float(weapon, 58, 400.0)
set_pev(id, pev_gravity, 0.8)
szTwoJump[id] = true
set_user_maxspeed(id, 260.0)
}
if(KnifeId[id] == 2)
{
set_pev(id, pev_viewmodel2, "models/knifes/v_vip.mdl")
set_pev(id, pev_weaponmodel2, "models/knifes/p_vip.mdl")
set_pdata_float(weapon, 58, 250.0)
set_pev(id, pev_gravity, 1.0)
szTwoJump[id] = true
}
if(KnifeId[id] == 3)
{
set_pev(id, pev_viewmodel2, "models/knifes/v_molot.mdl")
set_pev(id, pev_weaponmodel2, "models/knifes/p_molot.mdl")
set_pdata_float(weapon, 58, 220.0)
set_pev(id, pev_gravity, 1.0)
szTwoJump[id] = false
}
if(KnifeId[id] == 4)
{
set_pev(id, pev_viewmodel2, "models/knifes/v_skoros.mdl")
set_pev(id, pev_weaponmodel2, "models/knifes/p_skoros.mdl")
set_pdata_float(weapon, 58, 380.0)
set_pev(id, pev_gravity, 1.0)
szTwoJump[id] = false
set_user_maxspeed(id, 260.0)
}
if(KnifeId[id] == 5)
{
set_pev(id, pev_viewmodel2, "models/knifes/v_gravit.mdl")
set_pev(id, pev_weaponmodel2, "models/knifes/p_gravit.mdl")
set_pdata_float(weapon, 58, 250.0)
set_pev(id, pev_gravity, 0.7)
szTwoJump[id] = false
}
if(KnifeId[id] == 6)
{
set_pev(id, pev_viewmodel2, "models/v_knife.mdl")
set_pev(id, pev_weaponmodel2, "models/p_knife.mdl")
set_pdata_float(weapon, 58, 250.0)
set_pev(id, pev_gravity, 1.0)
szTwoJump[id] = false
}
return PLUGIN_HANDLED
}
public KnifeSet(ent)
{
set_pev(get_pdata_cbase(ent, 41, 4), pev_gravity, 1.0)
}
public TakeDamage(nClientIndex)
{
if(is_user_alive(nClientIndex))
{
if (!task_exists(nClientIndex))
set_task(REGENERATION_DELAY, "StartRegeneration" , nClientIndex, _, _, "b")
}
}
public KilledPost(nClientIndex)
{
remove_task(nClientIndex)
}
public StartRegeneration(nClientIndex)
{
static Float:g_iHealthPoint; pev(nClientIndex, pev_health, g_iHealthPoint);
if (g_iHealthPoint >= REGENERATION_MAX)
{
remove_task(nClientIndex);
return PLUGIN_HANDLED;
}
if(get_user_weapon(nClientIndex) == CSW_KNIFE && (KnifeId[nClientIndex] == 1 || KnifeId[nClientIndex] == 6))
{
set_pev(nClientIndex, pev_health, g_iHealthPoint + REGENERATION_STEP);
set_hudmessage(255, 0, 0, -1.0, 0.10, 1, 6.0, 1.0, 0.1, 1.0, 1)
show_hudmessage(nClientIndex, "Ðåãåíåðàöèÿ [+ %i HP]", REGENERATION_STEP)
client_cmd(nClientIndex, "spk knifes/health")
}
return PLUGIN_CONTINUE;
}
public EventDamage(victim, inflicator, attacker, Float:damage)
{
if(!is_user_connected(attacker))
return PLUGIN_HANDLED;
if(victim == attacker || !victim)
return PLUGIN_HANDLED;
if(get_user_team(attacker) != get_user_team (victim) && attacker != victim && get_user_weapon(attacker) == CSW_KNIFE && (KnifeId[attacker] == 1 || KnifeId[attacker] == 3))
SetHamParamFloat(4, damage * 2.0)
return PLUGIN_HANDLED;
}
public PreTwoJump(id)
{
if(szTwoJump[id] && get_user_weapon(id) == CSW_KNIFE)
{
new szButton = pev(id, pev_button)
new szOldButton = pev(id, pev_oldbuttons)
if((szButton & IN_JUMP) && !(pev(id, pev_flags) & FL_ONGROUND) && !(szOldButton & IN_JUMP))
{
if(szTwoJumpNum[id] < 1)
{
szDoTwoJump[id] = true
szTwoJumpNum[id]++
PostTwoJump(id)
return PLUGIN_CONTINUE
}
}
if((szButton & IN_JUMP) && (pev(id, pev_flags) & FL_ONGROUND))
{
szTwoJumpNum[id] = 0
}
}
return PLUGIN_CONTINUE
}
public PostTwoJump(id)
{
if(szTwoJump[id])
{
if(!is_user_alive(id))
return PLUGIN_CONTINUE
if(szDoTwoJump[id])
{
new Float:szVelocity[3]
pev(id, pev_velocity, szVelocity)
szVelocity[2] = random_float(295.0,305.0)
set_pev(id, pev_velocity, szVelocity)
szDoTwoJump[id] = false
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
public OnCBasePlayer_ResetMaxSpeed_P(id)
{
if(!is_user_connected(id))
return PLUGIN_CONTINUE
if(KnifeId[id] == 0)
if(KnifeId[id] == 1)
{
set_pdata_float(id, 58, 400.0)
set_user_maxspeed(id, 260.0)
}
if(KnifeId[id] == 2)
{
set_pdata_float(id, 58, 250.0)
}
if(KnifeId[id] == 3)
{
set_pdata_float(id, 58, 220.0)
}
if(KnifeId[id] == 4)
{
set_user_maxspeed(id, 260.0)
}
if(KnifeId[id] == 5)
{
set_pdata_float(id, 58, 250.0)
}
if(KnifeId[id] == 6)
{
set_pdata_float(id, 58, 250.0)
}
return PLUGIN_HANDLED
}
public EmitSound(id, channel, const sound[])
{
if(equal(sound, "weapons/knife_hitwall1.wav"))
{
if(KnifeId[id] == 1)
{
emit_sound(id, channel, "knifes/blink_hitwall1.wav", 1.0, 1.0, 0, 100)
return FMRES_SUPERCEDE
}
else if(KnifeId[id] == 2)
{
emit_sound(id, channel, "knifes/katana_hitwall1.wav", 1.0, 1.0, 0, 100)
return FMRES_SUPERCEDE
}
else if(KnifeId[id] == 3)
{
emit_sound(id, channel, "knifes/ibuki_hitwall1.wav", 1.0, 1.0, 0, 100)
return FMRES_SUPERCEDE
}
else if(KnifeId[id] == 4)
{
emit_sound(id, channel, "knifes/balrog9_hit1.wav", 1.0, 1.0, 0, 100)
return FMRES_SUPERCEDE
}
else if(KnifeId[id] == 5)
{
emit_sound(id, channel, "knifes/ferrane_hitwall1.wav", 1.0, 1.0, 0, 100)
return FMRES_SUPERCEDE
}else{
return HAM_IGNORED
}
}
if(equal(sound, "weapons/knife_slash1.wav") || equal(sound, "weapons/knife_slash2.wav"))
{
if(KnifeId[id] == 3)
{
emit_sound(id, channel, "knifes/ibuki_slash1.wav", 1.0, 1.0, 0, 100)
return FMRES_SUPERCEDE
}else{
return HAM_IGNORED
}
}
if(equal(sound, "weapons/knife_deploy1.wav"))
{
if(KnifeId[id] == 4)
{
emit_sound(id, channel, "knifes/ibuki_deploy1.wav", 1.0, 1.0, 0, 100)
return FMRES_SUPERCEDE
}else{
return HAM_IGNORED
}
}
return HAM_IGNORED
}
public knifead(id)
{
if(!is_user_alive(id)) return;
rg_remove_item(id, "weapon_knife");
}