i tried but i got errors
- #include <fakemeta>
- #include <engine>
- #include <zombie_escape>
- const chainsaw_ap_cost = 59000
- new const g_sound_buyarmor[] = { "items/tr_kevlar.wav" }
- new g_armor_amount, g_armor_limit, g_hp_amount
- new const chainsaw_viewmodel[] = "models/talrasha/weapons/chainsaw/v_chainsaw.mdl"
- new const chainsaw_playermodel[] = "models/talrasha/weapons/chainsaw/p_chainsaw.mdl"
- new const chainsaw_worldmodel[] = "models/talrasha/weapons/chainsaw/w_chainsaw.mdl"
- new const chainsaw_sounds[][] =
- {
- "talrasha/weapons/chainsaw/chainsaw_deploy.wav",
- "talrasha/weapons/chainsaw/chainsaw_hit1.wav",
- "talrasha/weapons/chainsaw/chainsaw_hit2.wav",
- "talrasha/weapons/chainsaw/chainsaw_hit1.wav",
- "talrasha/weapons/chainsaw/chainsaw_hit2.wav",
- "talrasha/weapons/chainsaw/chainsaw_hitwall.wav",
- "talrasha/weapons/chainsaw/chainsaw_miss.wav",
- "talrasha/weapons/chainsaw/chainsaw_miss.wav",
- "talrasha/weapons/chainsaw/chainsaw_stab.wav"
- }
- new Float:chainsaw_mins[3] = { -2.0, -2.0, -2.0 }
- new Float:chainsaw_maxs[3] = { 2.0, 2.0, 2.0 }
- new g_iItemID, g_msgCurWeapon
- new g_iHasChainsaw[33], g_iCurrentWeapon[33]
- new cvar_enable, cvar_dmgmult, cvar_oneround, cvar_sounds, cvar_dmggore, cvar_dropflags,
- cvar_pattack_rate, cvar_sattack_rate, cvar_pattack_recoil, cvar_sattack_recoil, cvar_body_xplode
- const DROPFLAG_NORMAL = (1<<0)
- const DROPFLAG_INDEATH = (1<<1)
- const DROPFLAG_INFECTED = (1<<2)
- const DROPFLAG_SURVHUMAN = (1<<3)
- const m_pPlayer = 41
- const m_flNextPrimaryAttack = 46
- const m_flNextSecondaryAttack = 47
- const m_flTimeWeaponIdle = 48
- #define PLUG_VERSION "1.0"
- #define PLUG_AUTH "eldon, RLY?"
- #define MIN_PLAYERS 24
- public plugin_init()
- {
- register_plugin("[ZP] Extra: Chainsaw", PLUG_VERSION, PLUG_AUTH)
- register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0")
- register_event("CurWeapon", "event_CurWeapon", "b", "1=1")
- cvar_enable = register_cvar("zp_chainsaw_enable", "1")
- cvar_sounds = register_cvar("zp_chainsaw_custom_sounds", "1")
- cvar_dmgmult = register_cvar("zp_chainsaw_damage_mult", "6.5")
- cvar_dmggore = register_cvar("zp_chainsaw_gore_in_damage", "1")
- cvar_oneround = register_cvar("zp_chainsaw_oneround", "0")
- cvar_dropflags = register_cvar("zp_chainsaw_drop_flags", "abcd")
- cvar_body_xplode = register_cvar("zp_chainsaw_victim_explode", "1")
- cvar_pattack_rate = register_cvar("zp_chainsaw_attack1_rate", "0.6")
- cvar_sattack_rate = register_cvar("zp_chainsaw_attack2_rate", "1.2")
- cvar_pattack_recoil = register_cvar("zp_chainsaw_attack1_recoil", "-5.6")
- cvar_sattack_recoil = register_cvar("zp_chainsaw_attack2_recoil", "-8.0")
- g_armor_amount = register_cvar("zp_armor_amount", "999")
- g_armor_limit = register_cvar("zp_armor_limit", "999")
- g_hp_amount = register_cvar("zp_hp_amount", "2500")
- new szCvar[30]
- formatex(szCvar, charsmax(szCvar), "v%s by %s", PLUG_VERSION, PLUG_AUTH)
- register_cvar("zp_extra_chainsaw", szCvar, FCVAR_SERVER|FCVAR_SPONLY)
- register_forward(FM_EmitSound, "fw_EmitSound")
- register_touch("cs_chainsaw", "player", "fw_Chainsaw_Touch")
- RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
- RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
- RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
- RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fw_Knife_PrimaryAttack_Post", 1)
- RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fw_Knife_SecondaryAttack_Post", 1)
- g_iItemID = ze_register_item("Chainsaw", chainsaw_ap_cost, 0)
- g_msgCurWeapon = get_user_msgid("CurWeapon")
- register_clcmd("drop", "clcmd_drop")
- }
- public plugin_natives ()
- {
- register_native("zp_get_user_chain", "native_get_chain", 1)
- register_native("zp_set_user_chain", "native_set_chain", 1)
- }
- public native_get_chain(param)
- {
- return g_iHasChainsaw[param]
- }
- public native_set_chain(id, param)
- {
- g_iHasChainsaw[id] = true
- set_pev(id, pev_viewmodel2, chainsaw_viewmodel)
- set_pev(id, pev_weaponmodel2, chainsaw_playermodel)
- emit_sound(id, CHAN_WEAPON, "items/gunpickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
- set_pev(id, pev_armorvalue, float(min(pev(id, pev_armorvalue)+get_pcvar_num(g_armor_amount), get_pcvar_num(g_armor_limit))))
- fm_set_user_armor(id, get_pcvar_num(g_armor_amount))
- fm_set_user_health(id, get_pcvar_num(g_hp_amount))
- engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_buyarmor, 1.0, ATTN_NORM, 0, PITCH_NORM)
- reset_user_knife(id)
- }
- public ze_select_item_pre(id, itemid)
- {
- // Return Available and we will block it in Post, So it dosen't affect other plugins
- if (itemid != g_itemid)
- return ZE_ITEM_AVAILABLE
- // Available for Humans only, So don't show it for zombies
- if (ze_is_user_zombie(id))
- return ZE_ITEM_DONT_SHOW
- return ZE_ITEM_AVAILABLE
- }
- public plugin_precache()
- {
- precache_model(chainsaw_viewmodel)
- precache_model(chainsaw_playermodel)
- precache_model(chainsaw_worldmodel)
- for(new i = 0; i < sizeof chainsaw_sounds; i++)
- precache_sound(chainsaw_sounds[i])
- precache_sound("items/gunpickup2.wav")
- precache_sound(g_sound_buyarmor)
- }
- public event_RoundStart()
- {
- remove_entity_name("cs_chainsaw")
- }
- public event_CurWeapon(id)
- {
- if(!is_user_alive(id))
- return PLUGIN_CONTINUE
- g_iCurrentWeapon[id] = read_data(2)
- if(ze_is_user_zombie(id))
- return PLUGIN_CONTINUE
- if(!g_iHasChainsaw[id] || g_iCurrentWeapon[id] != CSW_KNIFE)
- return PLUGIN_CONTINUE
- set_pev(id, pev_viewmodel2, chainsaw_viewmodel)
- set_pev(id, pev_weaponmodel2, chainsaw_playermodel)
- return PLUGIN_CONTINUE
- }
- public clcmd_drop(id)
- {
- if(g_iHasChainsaw[id] && g_iCurrentWeapon[id] == CSW_KNIFE)
- {
- if(check_drop_flag(DROPFLAG_NORMAL))
- {
- drop_chainsaw(id)
- return PLUGIN_HANDLED
- }
- }
- return PLUGIN_CONTINUE
- }
- public drop_chainsaw(id)
- {
- static Float:flAim[3], Float:flOrigin[3]
- VelocityByAim(id, 64, flAim)
- entity_get_vector(id, EV_VEC_origin, flOrigin)
- flOrigin[0] += flAim[0]
- flOrigin[1] += flAim[1]
- new iEnt = create_entity("info_target")
- entity_set_string(iEnt, EV_SZ_classname, "cs_chainsaw")
- entity_set_origin(iEnt, flOrigin)
- entity_set_model(iEnt, chainsaw_worldmodel)
- set_size(iEnt, chainsaw_mins, chainsaw_maxs)
- entity_set_vector(iEnt, EV_VEC_mins, chainsaw_mins)
- entity_set_vector(iEnt, EV_VEC_maxs, chainsaw_maxs)
- entity_set_int(iEnt, EV_INT_solid, SOLID_TRIGGER)
- entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_TOSS)
- g_iHasChainsaw[id] = false
- set_pev(id, pev_body, random_num(0, 3))
- reset_user_knife(id)
- }
- public reset_user_knife(id)
- {
- if(user_has_weapon(id, CSW_KNIFE))
- ExecuteHamB(Ham_Item_Deploy, find_ent_by_owner(-1, "weapon_knife", id))
- engclient_cmd(id, "weapon_knife")
- emessage_begin(MSG_ONE, g_msgCurWeapon, _, id)
- ewrite_byte(1)
- ewrite_byte(CSW_KNIFE)
- ewrite_byte(-1)
- emessage_end()
- }
- public ze_select_item_post(id, itemid)
- {
- if (itemid == g_iItemID)
- {
- if(get_pcvar_num(cvar_enable))
- {
- if (get_playersnum() <= MIN_PLAYERS)
- {
- ChatColor(id, "!g[Darkess-Project, Бензопила] !yÐ”Ð»Ñ Ð¿Ð¾ÐºÑƒÐ¿ÐºÐ¸ бензопилы требуетÑÑ Ð¼Ð¸Ð½Ð¸Ð¼ÑƒÐ¼ !team%d игрока!", MIN_PLAYERS)
- ze_set_escape_coins(id, ze_set_escape_coins(id) + chainsaw_ap_cost)
- return
- }
- if (g_iHasChainsaw[id])
- {
- ze_set_escape_coins(id, ze_set_escape_coins(id) + chainsaw_ap_cost)
- ChatColor(id, "!g[Darkess-Project, Бензопила] !yВы уже имеете !teamбензопилу!")
- }
- else
- {
- engclient_cmd(id, "weapon_knife")
- set_pev(id, pev_body, 6)
- g_iHasChainsaw[id] = true
- set_pev(id, pev_viewmodel2, chainsaw_viewmodel)
- set_pev(id, pev_weaponmodel2, chainsaw_playermodel)
- emit_sound(id, CHAN_WEAPON, "items/gunpickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
- set_pev(id, pev_armorvalue, float(min(pev(id, pev_armorvalue)+get_pcvar_num(g_armor_amount), get_pcvar_num(g_armor_limit))))
- fm_set_user_armor(id, get_pcvar_num(g_armor_amount))
- fm_set_user_health(id, get_pcvar_num(g_hp_amount))
- engfunc(EngFunc_EmitSound, id, CHAN_BODY, g_sound_buyarmor, 1.0, ATTN_NORM, 0, PITCH_NORM)
- ChatColor(id, "!g[Darkess-Project, Бензопила] !yВы купили !teamбензопилу!")
- reset_user_knife(id)
- }
- }
- else
- {
- ze_set_escape_coins(id, ze_set_escape_coins(id) + chainsaw_ap_cost)
- ChatColor(id, "!g[Darkess-Project, Бензопила] !yБензопила была временно !teamотключена!")
- }
- }
- }
- public ze_user_infected(id, iInfector)
- {
- if (g_iHasChainsaw[id])
- {
- if(check_drop_flag(DROPFLAG_INFECTED))
- drop_chainsaw(id)
- else
- {
- g_iHasChainsaw[id] = false
- reset_user_knife(id)
- }
- }
- }
- public client_putinserver(id)
- {
- g_iHasChainsaw[id] = false
- }
- public client_disconnect(id)
- {
- g_iHasChainsaw[id] = false
- }
- public fw_PlayerSpawn_Post(id)
- {
- if(get_pcvar_num(cvar_oneround) || !get_pcvar_num(cvar_enable))
- {
- if(g_iHasChainsaw[id])
- {
- g_iHasChainsaw[id] = false
- reset_user_knife(id)
- }
- }
- }
- public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_bits)
- {
- if(victim == attacker || !attacker)
- return HAM_IGNORED
- if(!is_user_connected(attacker))
- return HAM_IGNORED
- if(g_iHasChainsaw[attacker] && g_iCurrentWeapon[attacker] == CSW_KNIFE)
- {
- if(get_pcvar_num(cvar_dmggore))
- a_lot_of_blood(victim)
- SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmgmult))
- }
- return HAM_IGNORED
- }
- public fw_PlayerKilled(victim, attacker, shouldgib)
- {
- if(victim == attacker || !attacker)
- return HAM_IGNORED
- if(!is_user_connected(attacker))
- return HAM_IGNORED
- if(g_iHasChainsaw[attacker] && g_iCurrentWeapon[attacker] == CSW_KNIFE && get_pcvar_num(cvar_body_xplode))
- SetHamParamInteger(3, 2)
- if(g_iHasChainsaw[victim])
- {
- if(check_drop_flag(DROPFLAG_INDEATH))
- drop_chainsaw(victim)
- else
- {
- g_iHasChainsaw[victim] = false
- reset_user_knife(victim)
- }
- }
- return HAM_IGNORED
- }
- public fw_Chainsaw_Touch(saw, player)
- {
- if(!is_valid_ent(saw) || !is_valid_ent(player))
- return PLUGIN_CONTINUE
- if(!is_user_connected(player))
- return PLUGIN_CONTINUE
- if(!is_user_alive(player) || ze_is_user_zombie(player) || g_iHasChainsaw[player])
- return PLUGIN_CONTINUE
- g_iHasChainsaw[player] = true
- emit_sound(player, CHAN_WEAPON, "items/gunpickup2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
- reset_user_knife(player)
- remove_entity(saw)
- return PLUGIN_CONTINUE
- }
- public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
- {
- if(!is_user_connected(id))
- return FMRES_IGNORED
- if(!is_user_alive(id) || ze_is_user_zombie(id) || !g_iHasChainsaw[id] || !get_pcvar_num(cvar_sounds))
- return FMRES_IGNORED
- if (sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
- {
- if (sample[14] == 'd')
- {
- emit_sound(id, channel, chainsaw_sounds[0], volume, attn, flags, pitch)
- }
- else if (sample[14] == 'h')
- {
- if (sample[17] == 'w')
- {
- emit_sound(id, channel, chainsaw_sounds[3], volume, attn, flags, pitch)
- }
- else
- {
- emit_sound(id, channel, chainsaw_sounds[random_num(1,2)], volume, attn, flags, pitch)
- }
- }
- else
- {
- if (sample[15] == 'l')
- {
- emit_sound(id, channel, chainsaw_sounds[4], volume, attn, flags, pitch)
- }
- else
- {
- emit_sound(id, channel, chainsaw_sounds[5], volume, attn, flags, pitch)
- }
- }
- return FMRES_SUPERCEDE
- }
- return FMRES_IGNORED
- }
- public fw_Knife_PrimaryAttack_Post(knife)
- {
- static id
- id = get_pdata_cbase(knife, m_pPlayer, 4)
- if(is_user_connected(id) && g_iHasChainsaw[id])
- {
- static Float:flRate
- flRate = get_pcvar_float(cvar_pattack_rate)
- set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
- set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
- set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
- static Float:flPunchAngle[3]
- flPunchAngle[0] = get_pcvar_float(cvar_pattack_recoil)
- entity_set_vector(id, EV_VEC_punchangle, flPunchAngle)
- }
- return HAM_IGNORED
- }
- public fw_Knife_SecondaryAttack_Post(knife)
- {
- static id
- id = get_pdata_cbase(knife, m_pPlayer, 4)
- if(is_user_connected(id) && g_iHasChainsaw[id])
- {
- static Float:flRate
- flRate = get_pcvar_float(cvar_sattack_rate)
- set_pdata_float(knife, m_flNextPrimaryAttack, flRate, 4)
- set_pdata_float(knife, m_flNextSecondaryAttack, flRate, 4)
- set_pdata_float(knife, m_flTimeWeaponIdle, flRate, 4)
- static Float:flPunchAngle[3]
- flPunchAngle[0] = get_pcvar_float(cvar_sattack_recoil)
- entity_set_vector(id, EV_VEC_punchangle, flPunchAngle)
- }
- return HAM_IGNORED
- }
- check_drop_flag(flag)
- {
- new szFlags[10]
- get_pcvar_string(cvar_dropflags, szFlags, charsmax(szFlags))
- if(read_flags(szFlags) & flag)
- return true
- return false
- }
- a_lot_of_blood(id)
- {
- static iOrigin[3]
- get_user_origin(id, iOrigin)
- message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
- write_byte(TE_BLOODSTREAM)
- write_coord(iOrigin[0])
- write_coord(iOrigin[1])
- write_coord(iOrigin[2]+10)
- write_coord(random_num(-360, 360))
- write_coord(random_num(-360, 360))
- write_coord(-10)
- write_byte(70)
- write_byte(random_num(50, 100))
- message_end()
- for (new j = 0; j < 4; j++)
- {
- message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
- write_byte(TE_WORLDDECAL)
- write_coord(iOrigin[0]+random_num(-100, 100))
- write_coord(iOrigin[1]+random_num(-100, 100))
- write_coord(iOrigin[2]-36)
- write_byte(random_num(190, 197))
- message_end()
- }
- }
- stock ChatColor(const id, const input[], any:...)
- {
- new count = 1, players[32]
- static msg[191]
- vformat(msg, 190, input, 3)
- replace_all(msg, 190, "!g", "^4")
- replace_all(msg, 190, "!y", "^1")
- replace_all(msg, 190, "!team", "^3")
- if (id) players[0] = id; else get_players(players, count, "ch")
- {
- for (new i = 0; i < count; i++)
- {
- if (is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
- }