Raised This Month: $119 Target: $400
 29% 

[ZP4.3] Admin, Armor, Reload, Source / Code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pe4enko
New Member
Join Date: Nov 2020
Old 11-13-2020 , 06:57   [ZP4.3] Admin, Armor, Reload, Source / Code.
Reply With Quote #1

Hello. I need help. Help me please.
I am doing a zombie mod namely "zp4.3" and I need help getting my server up and running. I will describe my questions in great detail so that everyone would understand everything.

1) Admin. How to make it so that the server admin does not turn into a zombie at the beginning of
the round. I'm tired of turning myself back into a human every time through the admin menu. I do
not know by what principle the first zombies are selected and whether it is possible to weed out the
admin from this random, leaving only ordinary players and bots at the mercy of the so-called
random. I looked at the source of "zombie_plague40" and still didn't get it. At the end of the call I
will insert the source code "zombie_plague40"

2) Armor. "first, the armor is removed and only then the health will be removed" You did not
understand anything? I'll explain now. There is an "infection" mode and in this mode the armor
works, first the armor is taken away and only then a person without armor becomes infected,
turning instantly into a zombie, and there is a "plague" mode where zombies do not infect people,
but kill them and in this mode the armor does not work , in this mode, the armor is completely
ignored and the zombies attacking people immediately take away their health from them bypassing
the armor. How to fix it? There is a plug-in that makes the swearing defend the last person in the
"infection" mode, and the same plug-in works in the "plague" mode, protecting the last person who
survived. So how do you get the armor to protect people in plague mode? Armor is reduced first and
then health.

3) Recharge. How to make sure that the reloading of the weapon was strictly on the R key? When
the magazine runs out of cartridges, the weapon automatically reloads, and I need it not to be
there. You shoot from the EMC with a clamp, holding the left mouse button, then the cartridges run
out and you still hold the left mouse button down and the weapon starts to "click", but as soon as
you remove your finger from the mouse button, automatic reloading occurs right there! How to fix
it? Any incomprehensible console commands like "+ reload" or "-reload" do not help. And it is better
that these changes with manual reloading were from the side of the user and not the server.
THANKS

This plugin protects the last person of abuse.

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <engine>
#include <zombieplague>

// Sounds
new const sound_armorhit[] = "player/bhit_helmet-1.wav"

// Cvar pointers
new cvar_lasthumanarmor

// Plug info.
#define PLUG_VERSION "0.1"
#define PLUG_AUTH "meTaLiCroSS"

/*================================================================================
 [Init and Precache]
=================================================================================*/

public plugin_init() 
{
    
// Plugin info
    
register_plugin("[ZP] Addon: Last Human Armor Re-Enabler"PLUG_VERSIONPLUG_AUTH)
    
    
// Cvars
    
cvar_lasthumanarmor register_cvar("zp_last_human_armor""1")
    
    static 
szCvar[30]
    
formatex(szCvarcharsmax(szCvar), "v%s by %s"PLUG_VERSIONPLUG_AUTH)
    
register_cvar("zp_addon_lharmor"szCvarFCVAR_SERVER|FCVAR_SPONLY
}

public 
plugin_precache()
{
    
// Hamsandwich Forwards
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
    
// Sounds
    
precache_sound(sound_armorhit)
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_bits)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_connected(attacker))
        return 
HAM_IGNORED;
    
    
// Does last human armor need to be reduced before infecting?
    
if (get_pcvar_num(cvar_lasthumanarmor) && zp_get_user_last_human(victim) && !zp_get_user_zombie(victim))
    {
        
// Get victim armor
        
static Float:flArmor
        flArmor 
entity_get_float(victimEV_FL_armorvalue)
        
        
// Block the attack if he has some
        
if (flArmor 0.0)
        {
            
emit_sound(victimCHAN_BODYsound_armorhit1.0ATTN_NORM0PITCH_NORM)
            
entity_set_float(victimEV_FL_armorvaluefloatmax(0.0flArmor damage))
            return 
HAM_SUPERCEDE;
        }
    }
    
    return 
HAM_IGNORED

It seems this piece of code is responsible for randomness.

PHP Code:
/*================================================================================
 [Main Functions]
=================================================================================*/

// Make Zombie Task
public make_zombie_task()
{
    
// Call make a zombie with no specific mode
    
make_a_zombie(MODE_NONE0)
}

// Make a Zombie Function
make_a_zombie(modeid)
{
    
// Get alive players count
    
static iPlayersnum
    iPlayersnum 
fnGetAlive()
    
    
// Not enough players, come back later!
    
if (iPlayersnum 1)
    {
        
set_task(2.0"make_zombie_task"TASK_MAKEZOMBIE)
        return;
    }
    
    
// Round started!
    
g_newround false
    
    
// Set up some common vars
    
static forward_idsound[64], iZombiesiMaxZombies
    
    
if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_SURVIVOR) && random_num(1get_pcvar_num(cvar_survchance)) == get_pcvar_num(cvar_surv) && iPlayersnum >= get_pcvar_num(cvar_survminplayers)) || mode == MODE_SURVIVOR)
    {
        
// Survivor Mode
        
g_survround true
        g_lastmode 
MODE_SURVIVOR
        
        
// Choose player randomly?
        
if (mode == MODE_NONE)
            
id fnGetRandomAlive(random_num(1iPlayersnum))
        
        
// Remember id for calling our forward later
        
forward_id id
        
        
// Turn player into a survivor
        
humanme(id10)
        
        
// Turn the remaining players into zombies
        
for (id 1id <= g_maxplayersid++)
        {
            
// Not alive
            
if (!g_isalive[id])
                continue;
            
            
// Survivor or already a zombie
            
if (g_survivor[id] || g_zombie[id])
                continue;
            
            
// Turn into a zombie
            
zombieme(id0010)
        }
        
        
// Play survivor sound
        
ArrayGetString(sound_survivorrandom_num(0ArraySize(sound_survivor) - 1), soundcharsmax(sound))
        
PlaySound(sound);
        
        
// Show Survivor HUD notice
        
set_hudmessage(2020255HUD_EVENT_XHUD_EVENT_Y10.05.01.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_SURVIVOR"g_playername[forward_id])
        
        
// Mode fully started!
        
g_modestarted true
        
        
// Round start forward
        
ExecuteForward(g_fwRoundStartg_fwDummyResultMODE_SURVIVORforward_id);
    }
    else if ((
mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_SWARM) && random_num(1get_pcvar_num(cvar_swarmchance)) == get_pcvar_num(cvar_swarm) && iPlayersnum >= get_pcvar_num(cvar_swarmminplayers)) || mode == MODE_SWARM)
    {        
        
// Swarm Mode
        
g_swarmround true
        g_lastmode 
MODE_SWARM
        
        
// Make sure there are alive players on both teams (BUGFIX)
        
if (!fnGetAliveTs())
        {
            
// Move random player to T team
            
id fnGetRandomAlive(random_num(1iPlayersnum))
            
remove_task(id+TASK_TEAM)
            
fm_cs_set_user_team(idFM_CS_TEAM_T)
            
fm_user_team_update(id)
        }
        else if (!
fnGetAliveCTs())
        {
            
// Move random player to CT team
            
id fnGetRandomAlive(random_num(1iPlayersnum))
            
remove_task(id+TASK_TEAM)
            
fm_cs_set_user_team(idFM_CS_TEAM_CT)
            
fm_user_team_update(id)
        }
        
        
// Turn every T into a zombie
        
for (id 1id <= g_maxplayersid++)
        {
            
// Not alive
            
if (!g_isalive[id])
                continue;
            
            
// Not a Terrorist
            
if (fm_cs_get_user_team(id) != FM_CS_TEAM_T)
                continue;
            
            
// Turn into a zombie
            
zombieme(id0010)
        }
        
        
// Play swarm sound
        
ArrayGetString(sound_swarmrandom_num(0ArraySize(sound_swarm) - 1), soundcharsmax(sound))
        
PlaySound(sound);
        
        
// Show Swarm HUD notice
        
set_hudmessage(2025520HUD_EVENT_XHUD_EVENT_Y10.05.01.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_SWARM")
        
        
// Mode fully started!
        
g_modestarted true
        
        
// Round start forward
        
ExecuteForward(g_fwRoundStartg_fwDummyResultMODE_SWARM0);
    }
    else if ((
mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_MULTI) && random_num(1get_pcvar_num(cvar_multichance)) == get_pcvar_num(cvar_multi) && floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil) >= && floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil) < iPlayersnum && iPlayersnum >= get_pcvar_num(cvar_multiminplayers)) || mode == MODE_MULTI)
    {
        
// Multi Infection Mode
        
g_lastmode MODE_MULTI
        
        
// iMaxZombies is rounded up, in case there aren't enough players
        
iMaxZombies floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil)
        
iZombies 0
        
        
// Randomly turn iMaxZombies players into zombies
        
while (iZombies iMaxZombies)
        {
            
// Keep looping through all players
            
if (++id g_maxplayersid 1
            
            
// Dead or already a zombie
            
if (!g_isalive[id] || g_zombie[id])
                continue;
            
            
// Random chance
            
if (random_num(01))
            {
                
// Turn into a zombie
                
zombieme(id0010)
                
iZombies++
            }
        }
        
        
// Turn the remaining players into humans
        
for (id 1id <= g_maxplayersid++)
        {
            
// Only those of them who aren't zombies
            
if (!g_isalive[id] || g_zombie[id])
                continue;
            
            
// Switch to CT
            
if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT// need to change team?
            
{
                
remove_task(id+TASK_TEAM)
                
fm_cs_set_user_team(idFM_CS_TEAM_CT)
                
fm_user_team_update(id)
            }
        }
        
        
// Play multi infection sound
        
ArrayGetString(sound_multirandom_num(0ArraySize(sound_multi) - 1), soundcharsmax(sound))
        
PlaySound(sound);
        
        
// Show Multi Infection HUD notice
        
set_hudmessage(200500HUD_EVENT_XHUD_EVENT_Y10.05.01.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_MULTI")
        
        
// Mode fully started!
        
g_modestarted true
        
        
// Round start forward
        
ExecuteForward(g_fwRoundStartg_fwDummyResultMODE_MULTI0);
    }
    else if ((
mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_PLAGUE) && random_num(1get_pcvar_num(cvar_plaguechance)) == get_pcvar_num(cvar_plague) && floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil) >= 1
    
&& iPlayersnum-(get_pcvar_num(cvar_plaguesurvnum)+get_pcvar_num(cvar_plaguenemnum)+floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)) >= && iPlayersnum >= get_pcvar_num(cvar_plagueminplayers)) || mode == MODE_PLAGUE)
    {
        
// Plague Mode
        
g_plagueround true
        g_lastmode 
MODE_PLAGUE
        
        
// Turn specified amount of players into Survivors
        
static iSurvivorsiMaxSurvivors
        iMaxSurvivors 
get_pcvar_num(cvar_plaguesurvnum)
        
iSurvivors 0
        
        
while (iSurvivors iMaxSurvivors)
        {
            
// Choose random guy
            
id fnGetRandomAlive(random_num(1iPlayersnum))
            
            
// Already a survivor?
            
if (g_survivor[id])
                continue;
            
            
// If not, turn him into one
            
humanme(id10)
            
iSurvivors++
            
            
// Apply survivor health multiplier
            
fm_set_user_health(idfloatround(float(pev(idpev_health)) * get_pcvar_float(cvar_plaguesurvhpmulti)))
        }
        
        
// Turn specified amount of players into Nemesis
        
static iNemesisiMaxNemesis
        iMaxNemesis 
get_pcvar_num(cvar_plaguenemnum)
        
iNemesis 0
        
        
while (iNemesis iMaxNemesis)
        {
            
// Choose random guy
            
id fnGetRandomAlive(random_num(1iPlayersnum))
            
            
// Already a survivor or nemesis?
            
if (g_survivor[id] || g_nemesis[id])
                continue;
            
            
// If not, turn him into one
            
zombieme(id0100)
            
iNemesis++
            
            
// Apply nemesis health multiplier
            
fm_set_user_health(idfloatround(float(pev(idpev_health)) * get_pcvar_float(cvar_plaguenemhpmulti)))
        }
        
        
// iMaxZombies is rounded up, in case there aren't enough players
        
iMaxZombies floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)
        
iZombies 0
        
        
// Randomly turn iMaxZombies players into zombies
        
while (iZombies iMaxZombies)
        {
            
// Keep looping through all players
            
if (++id g_maxplayersid 1
            
            
// Dead or already a zombie or survivor
            
if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
                continue;
            
            
// Random chance
            
if (random_num(01))
            {
                
// Turn into a zombie
                
zombieme(id0010)
                
iZombies++
            }
        }
        
        
// Turn the remaining players into humans
        
for (id 1id <= g_maxplayersid++)
        {
            
// Only those of them who arent zombies or survivor
            
if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
                continue;
            
            
// Switch to CT
            
if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT// need to change team?
            
{
                
remove_task(id+TASK_TEAM)
                
fm_cs_set_user_team(idFM_CS_TEAM_CT)
                
fm_user_team_update(id)
            }
        }
        
        
// Play plague sound
        
ArrayGetString(sound_plaguerandom_num(0ArraySize(sound_plague) - 1), soundcharsmax(sound))
        
PlaySound(sound);
        
        
// Show Plague HUD notice
        
set_hudmessage(050200HUD_EVENT_XHUD_EVENT_Y10.05.01.01.0, -1)
        
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_PLAGUE")
        
        
// Mode fully started!
        
g_modestarted true
        
        
// Round start forward
        
ExecuteForward(g_fwRoundStartg_fwDummyResultMODE_PLAGUE0);
    }
    else
    {
        
// Single Infection Mode or Nemesis Mode
        
        // Choose player randomly?
        
if (mode == MODE_NONE)
            
id fnGetRandomAlive(random_num(1iPlayersnum))
        
        
// Remember id for calling our forward later
        
forward_id id
        
        
if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_NEMESIS) && random_num(1get_pcvar_num(cvar_nemchance)) == get_pcvar_num(cvar_nem) && iPlayersnum >= get_pcvar_num(cvar_nemminplayers)) || mode == MODE_NEMESIS)
        {
            
// Nemesis Mode
            
g_nemround true
            g_lastmode 
MODE_NEMESIS
            
            
// Turn player into nemesis
            
zombieme(id0100)
        }
        else
        {
            
// Single Infection Mode
            
g_lastmode MODE_INFECTION
            
            
// Turn player into the first zombie
            
zombieme(id0000)
        }
        
        
// Remaining players should be humans (CTs)
        
for (id 1id <= g_maxplayersid++)
        {
            
// Not alive
            
if (!g_isalive[id])
                continue;
            
            
// First zombie/nemesis
            
if (g_zombie[id])
                continue;
            
            
// Switch to CT
            
if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT// need to change team?
            
{
                
remove_task(id+TASK_TEAM)
                
fm_cs_set_user_team(idFM_CS_TEAM_CT)
                
fm_user_team_update(id)
            }
        }
        
        if (
g_nemround)
        {
            
// Play Nemesis sound
            
ArrayGetString(sound_nemesisrandom_num(0ArraySize(sound_nemesis) - 1), soundcharsmax(sound))
            
PlaySound(sound);
            
            
// Show Nemesis HUD notice
            
set_hudmessage(2552020HUD_EVENT_XHUD_EVENT_Y10.05.01.01.0, -1)
            
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_NEMESIS"g_playername[forward_id])
            
            
// Mode fully started!
            
g_modestarted true
            
            
// Round start forward
            
ExecuteForward(g_fwRoundStartg_fwDummyResultMODE_NEMESISforward_id);
        }
        else
        {
            
// Show First Zombie HUD notice
            
set_hudmessage(25500HUD_EVENT_XHUD_EVENT_Y00.05.01.01.0, -1)
            
ShowSyncHudMsg(0g_MsgSync"%L",LANG_PLAYER"NOTICE_FIRST"g_playername[forward_id])
            
            
// Mode fully started!
            
g_modestarted true
            
            
// Round start forward
            
ExecuteForward(g_fwRoundStartg_fwDummyResultMODE_INFECTIONforward_id);
        }
    }
    
    
// Start ambience sounds after a mode begins
    
if ((g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && g_nemround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && g_survround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && g_swarmround) || (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && g_plagueround) || (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_survround && !g_swarmround && !g_plagueround))
    {
        
remove_task(TASK_AMBIENCESOUNDS)
        
set_task(2.0"ambience_sound_effects"TASK_AMBIENCESOUNDS)
    }
}

// Zombie Me Function (player id, infector, turn into a nemesis, silent mode, deathmsg and rewards)
zombieme(idinfectornemesissilentmoderewards)
{
    
// User infect attempt forward
    
ExecuteForward(g_fwUserInfect_attemptg_fwDummyResultidinfectornemesis)
    
    
// One or more plugins blocked the infection. Only allow this after making sure it's
    // not going to leave us with no zombies. Take into account a last player leaving case.
    // BUGFIX: only allow after a mode has started, to prevent blocking first zombie e.g.
    
if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetZombies() > g_lastplayerleaving)
        return;
    
    
// Pre user infect forward
    
ExecuteForward(g_fwUserInfected_preg_fwDummyResultidinfectornemesis)
    
    
// Show zombie class menu if they haven't chosen any (e.g. just connected)
    
if (g_zombieclassnext[id] == ZCLASS_NONE && get_pcvar_num(cvar_zclasses))
        
set_task(0.2"show_menu_zclass"id)
    
    
// Set selected zombie class
    
g_zombieclass[id] = random_num(0ArraySize(g_zclass_name) - 1)
    
// If no class selected yet, use the first (default) one
    
if (g_zombieclass[id] == ZCLASS_NONEg_zombieclass[id] = 0
    
    
// Way to go...
    
g_zombie[id] = true
    g_nemesis
[id] = false
    g_survivor
[id] = false
    g_firstzombie
[id] = false
    
    
// Remove survivor's aura (bugfix)
    
set_pev(idpev_effectspev(idpev_effects) &~ EF_BRIGHTLIGHT)
    
    
// Remove spawn protection (bugfix)
    
g_nodamage[id] = false
    set_pev
(idpev_effectspev(idpev_effects) &~ EF_NODRAW)
    
    
// Reset burning duration counter (bugfix)
    
g_burning_duration[id] = 0
    
    
// Show deathmsg and reward infector?
    
if (rewards && infector)
    {
        
// Send death notice and fix the "dead" attrib on scoreboard
        
SendDeathMsg(infectorid)
        
FixDeadAttrib(id)
        
        
// Reward frags, deaths, health, and ammo packs
        
UpdateFrags(infectoridget_pcvar_num(cvar_fragsinfect), 11)
        
g_ammopacks[infector] += get_pcvar_num(cvar_ammoinfect)
        
fm_set_user_health(infectorpev(infectorpev_health) + get_pcvar_num(cvar_zombiebonushp))
    }
    
    
// Cache speed, knockback, and name for player's class
    
g_zombie_spd[id] = float(ArrayGetCell(g_zclass_spdg_zombieclass[id]))
    
g_zombie_knockback[id] = Float:ArrayGetCell(g_zclass_kbg_zombieclass[id])
    
ArrayGetString(g_zclass_nameg_zombieclass[id], g_zombie_classname[id], charsmax(g_zombie_classname[]))
    
    
// Set zombie attributes based on the mode
    
static sound[64]
    if (!
silentmode)
    {
        if (
nemesis)
        {
            
// Nemesis
            
g_nemesis[id] = true
            
            
// Set health [0 = auto]
            
if (get_pcvar_num(cvar_nemhp) == 0)
            {
                if (
get_pcvar_num(cvar_nembasehp) == 0)
                    
fm_set_user_health(idArrayGetCell(g_zclass_hp0) * fnGetAlive())
                else
                    
fm_set_user_health(idget_pcvar_num(cvar_nembasehp) * fnGetAlive())
            }
            else
                
fm_set_user_health(idget_pcvar_num(cvar_nemhp))
            
            
// Set gravity, unless frozen
            
if (!g_frozen[id]) set_pev(idpev_gravityget_pcvar_float(cvar_nemgravity))
        }
        else if (
fnGetZombies() == 1)
        {
            
// First zombie
            
g_firstzombie[id] = true
            
            
// Set health and gravity, unless frozen
            
fm_set_user_health(idfloatround(float(ArrayGetCell(g_zclass_hpg_zombieclass[id])) * get_pcvar_float(cvar_zombiefirsthp)))
            if (!
g_frozen[id]) set_pev(idpev_gravityFloat:ArrayGetCell(g_zclass_gravg_zombieclass[id]))
            
            
// Infection sound
            
ArrayGetString(zombie_infectrandom_num(0ArraySize(zombie_infect) - 1), soundcharsmax(sound))
            
emit_sound(idCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
        }
        else
        {
            
// Infected by someone
            
            // Set health and gravity, unless frozen
            
fm_set_user_health(idArrayGetCell(g_zclass_hpg_zombieclass[id]))
            if (!
g_frozen[id]) set_pev(idpev_gravityFloat:ArrayGetCell(g_zclass_gravg_zombieclass[id]))
            
            
// Infection sound
            
ArrayGetString(zombie_infectrandom_num(0ArraySize(zombie_infect) - 1), soundcharsmax(sound))
            
emit_sound(idCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
            
            
// Show Infection HUD notice
            
set_hudmessage(25500HUD_INFECT_XHUD_INFECT_Y00.05.01.01.0, -1)
            
            if (
infector// infected by someone?
                
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_INFECT2"g_playername[id], g_playername[infector])
            else
                
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_INFECT"g_playername[id])
        }
    }
    else
    {
        
// Silent mode, no HUD messages, no infection sounds
        
        // Set health and gravity, unless frozen
        
fm_set_user_health(idArrayGetCell(g_zclass_hpg_zombieclass[id]))
        if (!
g_frozen[id]) set_pev(idpev_gravityFloat:ArrayGetCell(g_zclass_gravg_zombieclass[id]))
    }
    
    
// Remove previous tasks
    
remove_task(id+TASK_MODEL)
    
remove_task(id+TASK_BLOOD)
    
remove_task(id+TASK_AURA)
    
remove_task(id+TASK_BURN)
    
    
// Switch to T
    
if (fm_cs_get_user_team(id) != FM_CS_TEAM_T// need to change team?
    
{
        
remove_task(id+TASK_TEAM)
        
fm_cs_set_user_team(idFM_CS_TEAM_T)
        
fm_user_team_update(id)
    }
    
    
// Custom models stuff
    
static currentmodel[32], tempmodel[32], already_has_modeliiRandsize
    already_has_model 
false
    
    
if (g_handle_models_on_separate_ent)
    {
        
// Set the right model
        
if (g_nemesis[id])
        {
            
iRand random_num(0ArraySize(model_nemesis) - 1)
            
ArrayGetString(model_nemesisiRandg_playermodel[id], charsmax(g_playermodel[]))
            if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_nemesisiRand))
        }
        else
        {
            if (
get_pcvar_num(cvar_adminmodelszombie) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
            {
                
iRand random_num(0ArraySize(model_admin_zombie) - 1)
                
ArrayGetString(model_admin_zombieiRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_admin_zombieiRand))
            }
            else
            {
                
iRand random_num(ArrayGetCell(g_zclass_modelsstartg_zombieclass[id]), ArrayGetCell(g_zclass_modelsendg_zombieclass[id]) - 1)
                
ArrayGetString(g_zclass_playermodeliRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_zclass_modelindexiRand))
            }
        }
        
        
// Set model on player model entity
        
fm_set_playermodel_ent(id)
        
        
// Nemesis glow / remove glow on player model entity, unless frozen
        
if (!g_frozen[id])
        {
            if (
g_nemesis[id] && get_pcvar_num(cvar_nemglow))
                
fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell25500kRenderNormal25)
            else
                
fm_set_rendering(g_ent_playermodel[id])
        }
    }
    else
    {
        
// Get current model for comparing it with the current one
        
fm_cs_get_user_model(idcurrentmodelcharsmax(currentmodel))
        
        
// Set the right model, after checking that we don't already have it
        
if (g_nemesis[id])
        {
            
size ArraySize(model_nemesis)
            for (
0sizei++)
            {
                
ArrayGetString(model_nemesisitempmodelcharsmax(tempmodel))
                if (
equal(currentmodeltempmodel)) already_has_model true
            
}
            
            if (!
already_has_model)
            {
                
iRand random_num(0size 1)
                
ArrayGetString(model_nemesisiRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_nemesisiRand))
            }
        }
        else
        {
            if (
get_pcvar_num(cvar_adminmodelszombie) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
            {
                
size ArraySize(model_admin_zombie)
                for (
0sizei++)
                {
                    
ArrayGetString(model_admin_zombieitempmodelcharsmax(tempmodel))
                    if (
equal(currentmodeltempmodel)) already_has_model true
                
}
                
                if (!
already_has_model)
                {
                    
iRand random_num(0size 1)
                    
ArrayGetString(model_admin_zombieiRandg_playermodel[id], charsmax(g_playermodel[]))
                    if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_admin_zombieiRand))
                }
            }
            else
            {
                for (
ArrayGetCell(g_zclass_modelsstartg_zombieclass[id]); ArrayGetCell(g_zclass_modelsendg_zombieclass[id]); i++)
                {
                    
ArrayGetString(g_zclass_playermodelitempmodelcharsmax(tempmodel))
                    if (
equal(currentmodeltempmodel)) already_has_model true
                
}
                
                if (!
already_has_model)
                {
                    
iRand random_num(ArrayGetCell(g_zclass_modelsstartg_zombieclass[id]), ArrayGetCell(g_zclass_modelsendg_zombieclass[id]) - 1)
                    
ArrayGetString(g_zclass_playermodeliRandg_playermodel[id], charsmax(g_playermodel[]))
                    if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_zclass_modelindexiRand))
                }
            }
        }
        
        
// Need to change the model?
        
if (!already_has_model)
        {
            
// An additional delay is offset at round start
            // since SVC_BAD is more likely to be triggered there
            
if (g_newround)
                
set_task(5.0 g_modelchange_delay"fm_user_model_update"id+TASK_MODEL)
            else
                
fm_user_model_update(id+TASK_MODEL)
        }
        
        
// Nemesis glow / remove glow, unless frozen
        
if (!g_frozen[id])
        {
            if (
g_nemesis[id] && get_pcvar_num(cvar_nemglow))
                
fm_set_rendering(idkRenderFxGlowShell25500kRenderNormal25)
            else
                
fm_set_rendering(id)
        }
    }
    
    
// Remove any zoom (bugfix)
    
cs_set_user_zoom(idCS_RESET_ZOOM1)
    
    
// Remove armor
    
set_pev(idpev_armorvalue0.0)
    
    
// Drop weapons when infected
    
drop_weapons(id1)
    
drop_weapons(id2)
    
    
// Strip zombies from guns and give them a knife
    
fm_strip_user_weapons(id)
    
fm_give_item(id"weapon_knife")
    
    
// Fancy effects
    
infection_effects(id)
    
    
// Nemesis aura task
    
if (g_nemesis[id] && get_pcvar_num(cvar_nemaura))
        
set_task(0.1"zombie_aura"id+TASK_AURA__"b")
    
    
// Give Zombies Night Vision?
    
if (get_pcvar_num(cvar_nvggive))
    {
        
g_nvision[id] = true
        
        
if (!g_isbot[id])
        {
            
// Turn on Night Vision automatically?
            
if (get_pcvar_num(cvar_nvggive) == 1)
            {
                
g_nvisionenabled[id] = true
                
                
// Custom nvg?
                
if (get_pcvar_num(cvar_customnvg))
                {
                    
remove_task(id+TASK_NVISION)
                    
set_task(0.1"set_user_nvision"id+TASK_NVISION__"b")
                }
                else
                    
set_user_gnvision(id1)
            }
            
// Turn off nightvision when infected (bugfix)
            
else if (g_nvisionenabled[id])
            {
                if (
get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
                else 
set_user_gnvision(id0)
                
g_nvisionenabled[id] = false
            
}
        }
        else
            
cs_set_user_nvg(id1); // turn on NVG for bots
    
}
    
// Disable nightvision when infected (bugfix)
    
else if (g_nvision[id])
    {
        if (
g_isbot[id]) cs_set_user_nvg(id0// Turn off NVG for bots
        
if (get_pcvar_num(cvar_customnvg)) remove_task(id+TASK_NVISION)
        else if (
g_nvisionenabled[id]) set_user_gnvision(id0)
        
g_nvision[id] = false
        g_nvisionenabled
[id] = false
    
}
    
    
// Set custom FOV?
    
if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
    {
        
message_begin(MSG_ONEg_msgSetFOV_id)
        
write_byte(get_pcvar_num(cvar_zombiefov)) // fov angle
        
message_end()
    }
    
    
// Call the bloody task
    
if (!g_nemesis[id] && get_pcvar_num(cvar_zombiebleeding))
        
set_task(0.7"make_blood"id+TASK_BLOOD__"b")
    
    
// Idle sounds task
    
if (!g_nemesis[id])
        
set_task(random_float(50.070.0), "zombie_play_idle"id+TASK_BLOOD__"b")
    
    
// Turn off zombie's flashlight
    
turn_off_flashlight(id)
    
    
// Post user infect forward
    
ExecuteForward(g_fwUserInfected_postg_fwDummyResultidinfectornemesis)
    
    
// Last Zombie Check
    
fnCheckLastZombie()
}

// Function Human Me (player id, turn into a survivor, silent mode)
humanme(idsurvivorsilentmode)
{
    
// User humanize attempt forward
    
ExecuteForward(g_fwUserHumanize_attemptg_fwDummyResultidsurvivor)
    
    
// One or more plugins blocked the "humanization". Only allow this after making sure it's
    // not going to leave us with no humans. Take into account a last player leaving case.
    // BUGFIX: only allow after a mode has started, to prevent blocking first survivor e.g.
    
if (g_fwDummyResult >= ZP_PLUGIN_HANDLED && g_modestarted && fnGetHumans() > g_lastplayerleaving)
        return;
    
    
// Pre user humanize forward
    
ExecuteForward(g_fwUserHumanized_preg_fwDummyResultidsurvivor)
    
    
// Remove previous tasks
    
remove_task(id+TASK_MODEL)
    
remove_task(id+TASK_BLOOD)
    
remove_task(id+TASK_AURA)
    
remove_task(id+TASK_BURN)
    
remove_task(id+TASK_NVISION)
    
    
// Reset some vars
    
g_zombie[id] = false
    g_nemesis
[id] = false
    g_survivor
[id] = false
    g_firstzombie
[id] = false
    g_canbuy
[id] = true
    g_nvision
[id] = false
    g_nvisionenabled
[id] = false
    
    
// Remove survivor's aura (bugfix)
    
set_pev(idpev_effectspev(idpev_effects) &~ EF_BRIGHTLIGHT)
    
    
// Remove spawn protection (bugfix)
    
g_nodamage[id] = false
    set_pev
(idpev_effectspev(idpev_effects) &~ EF_NODRAW)
    
    
// Reset burning duration counter (bugfix)
    
g_burning_duration[id] = 0
    
    
// Drop previous weapons
    
drop_weapons(id1)
    
drop_weapons(id2)
    
    
// Strip off from weapons
    
fm_strip_user_weapons(id)
    
fm_give_item(id"weapon_knife")
    
    
// Set human attributes based on the mode
    
if (survivor)
    {
        
// Survivor
        
g_survivor[id] = true
        
        
// Set Health [0 = auto]
        
if (get_pcvar_num(cvar_survhp) == 0)
        {
            if (
get_pcvar_num(cvar_survbasehp) == 0)
                
fm_set_user_health(idget_pcvar_num(cvar_humanhp) * fnGetAlive())
            else
                
fm_set_user_health(idget_pcvar_num(cvar_survbasehp) * fnGetAlive())
        }
        else
            
fm_set_user_health(idget_pcvar_num(cvar_survhp))
        
        
// Set gravity, unless frozen
        
if (!g_frozen[id]) set_pev(idpev_gravityget_pcvar_float(cvar_survgravity))
        
        
// Give survivor his own weapon
        
static survweapon[32]
        
get_pcvar_string(cvar_survweaponsurvweaponcharsmax(survweapon))
        
fm_give_item(idsurvweapon)
        
ExecuteHamB(Ham_GiveAmmoidMAXBPAMMO[cs_weapon_name_to_id(survweapon)], AMMOTYPE[cs_weapon_name_to_id(survweapon)], MAXBPAMMO[cs_weapon_name_to_id(survweapon)])
        
        
// Turn off his flashlight
        
turn_off_flashlight(id)
        
        
// Give the survivor a bright light
        
if (get_pcvar_num(cvar_survaura)) set_pev(idpev_effectspev(idpev_effects) | EF_BRIGHTLIGHT)
        
        
// Survivor bots will also need nightvision to see in the dark
        
if (g_isbot[id])
        {
            
g_nvision[id] = true
            cs_set_user_nvg
(id1)
        }
    }
    else
    {
        
// Human taking an antidote
        
        // Set health
        
fm_set_user_health(idget_pcvar_num(cvar_humanhp))
        
        
// Set gravity, unless frozen
        
if (!g_frozen[id]) set_pev(idpev_gravityget_pcvar_float(cvar_humangravity))
        
        
// Show custom buy menu?
        
if (get_pcvar_num(cvar_buycustom))
            
set_task(0.2"show_menu_buy1"id+TASK_SPAWN)
        
        
// Silent mode = no HUD messages, no antidote sound
        
if (!silentmode)
        {
            
// Antidote sound
            
static sound[64]
            
ArrayGetString(sound_antidoterandom_num(0ArraySize(sound_antidote) - 1), soundcharsmax(sound))
            
emit_sound(idCHAN_ITEMsound1.0ATTN_NORM0PITCH_NORM)
            
            
// Show Antidote HUD notice
            
set_hudmessage(00255HUD_INFECT_XHUD_INFECT_Y00.05.01.01.0, -1)
            
ShowSyncHudMsg(0g_MsgSync"%L"LANG_PLAYER"NOTICE_ANTIDOTE"g_playername[id])
        }
    }
    
    
// Switch to CT
    
if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT// need to change team?
    
{
        
remove_task(id+TASK_TEAM)
        
fm_cs_set_user_team(idFM_CS_TEAM_CT)
        
fm_user_team_update(id)
    }
    
    
// Custom models stuff
    
static currentmodel[32], tempmodel[32], already_has_modeliiRandsize
    already_has_model 
false
    
    
if (g_handle_models_on_separate_ent)
    {
        
// Set the right model
        
if (g_survivor[id])
        {
            
iRand random_num(0ArraySize(model_survivor) - 1)
            
ArrayGetString(model_survivoriRandg_playermodel[id], charsmax(g_playermodel[]))
            if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_survivoriRand))
        }
        else
        {
            if (
get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
            {
                
iRand random_num(0ArraySize(model_admin_human) - 1)
                
ArrayGetString(model_admin_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_admin_humaniRand))
            }
            else
            {
                
iRand random_num(0ArraySize(model_human) - 1)
                
ArrayGetString(model_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_humaniRand))
            }
        }
        
        
// Set model on player model entity
        
fm_set_playermodel_ent(id)
        
        
// Set survivor glow / remove glow on player model entity, unless frozen
        
if (!g_frozen[id])
        {
            if (
g_survivor[id] && get_pcvar_num(cvar_survglow))
                
fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell00255kRenderNormal25)
            else
                
fm_set_rendering(g_ent_playermodel[id])
        }
    }
    else
    {
        
// Get current model for comparing it with the current one
        
fm_cs_get_user_model(idcurrentmodelcharsmax(currentmodel))
        
        
// Set the right model, after checking that we don't already have it
        
if (g_survivor[id])
        {
            
size ArraySize(model_survivor)
            for (
0sizei++)
            {
                
ArrayGetString(model_survivoritempmodelcharsmax(tempmodel))
                if (
equal(currentmodeltempmodel)) already_has_model true
            
}
            
            if (!
already_has_model)
            {
                
iRand random_num(0size 1)
                
ArrayGetString(model_survivoriRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_survivoriRand))
            }
        }
        else
        {
            if (
get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
            {
                
size ArraySize(model_admin_human)
                for (
0sizei++)
                {
                    
ArrayGetString(model_admin_humanitempmodelcharsmax(tempmodel))
                    if (
equal(currentmodeltempmodel)) already_has_model true
                
}
                
                if (!
already_has_model)
                {
                    
iRand random_num(0size 1)
                    
ArrayGetString(model_admin_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
                    if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_admin_humaniRand))
                }
            }
            else
            {
                
size ArraySize(model_human)
                for (
0sizei++)
                {
                    
ArrayGetString(model_humanitempmodelcharsmax(tempmodel))
                    if (
equal(currentmodeltempmodel)) already_has_model true
                
}
                
                if (!
already_has_model)
                {
                    
iRand random_num(0size 1)
                    
ArrayGetString(model_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
                    if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_humaniRand))
                }
            }
        }
        
        
// Need to change the model?
        
if (!already_has_model)
        {
            
// An additional delay is offset at round start
            // since SVC_BAD is more likely to be triggered there
            
if (g_newround)
                
set_task(5.0 g_modelchange_delay"fm_user_model_update"id+TASK_MODEL)
            else
                
fm_user_model_update(id+TASK_MODEL)
        }
        
        
// Set survivor glow / remove glow, unless frozen
        
if (!g_frozen[id])
        {
            if (
g_survivor[id] && get_pcvar_num(cvar_survglow))
                
fm_set_rendering(idkRenderFxGlowShell00255kRenderNormal25)
            else
                
fm_set_rendering(id)
        }
    }
    
    
// Restore FOV?
    
if (get_pcvar_num(cvar_zombiefov) != 90 && get_pcvar_num(cvar_zombiefov) != 0)
    {
        
message_begin(MSG_ONEg_msgSetFOV_id)
        
write_byte(90// angle
        
message_end()
    }
    
    
// Disable nightvision
    
if (g_isbot[id]) cs_set_user_nvg(id0)
    else if (!
get_pcvar_num(cvar_customnvg) && g_nvisionenabled[id]) set_user_gnvision(id0)
    
    
// Post user humanize forward
    
ExecuteForward(g_fwUserHumanized_postg_fwDummyResultidsurvivor)
    
    
// Last Zombie Check
    
fnCheckLastZombie()

It seems this piece of code is responsible for the damage taken

PHP Code:
/*================================================================================
 [Main Forwards]
=================================================================================*/

// Entity Spawn Forward
public fw_Spawn(entity)
{
    
// Invalid entity
    
if (!pev_valid(entity)) return FMRES_IGNORED;
    
    
// Get classname
    
new classname[32], objective[32], size ArraySize(g_objective_ents)
    
pev(entitypev_classnameclassnamecharsmax(classname))
    
    
// Check whether it needs to be removed
    
for (new 0sizei++)
    {
        
ArrayGetString(g_objective_entsiobjectivecharsmax(objective))
        
        if (
equal(classnameobjective))
        {
            
engfunc(EngFunc_RemoveEntityentity)
            return 
FMRES_SUPERCEDE;
        }
    }
    
    return 
FMRES_IGNORED;
}

// Sound Precache Forward
public fw_PrecacheSound(const sound[])
{
    
// Block all those unneeeded hostage sounds
    
if (equal(sound"hostage"7))
        return 
FMRES_SUPERCEDE;
    
    return 
FMRES_IGNORED;
}

// Ham Player Spawn Post Forward
public fw_PlayerSpawn_Post(id)
{
    
// Not alive or didn't join a team yet
    
if (!is_user_alive(id) || !fm_cs_get_user_team(id))
        return;
    
    
// Player spawned
    
g_isalive[id] = true
    
    
// Remove previous tasks
    
remove_task(id+TASK_SPAWN)
    
remove_task(id+TASK_MODEL)
    
remove_task(id+TASK_BLOOD)
    
remove_task(id+TASK_AURA)
    
remove_task(id+TASK_BURN)
    
remove_task(id+TASK_CHARGE)
    
remove_task(id+TASK_FLASH)
    
remove_task(id+TASK_NVISION)
    
    
// Spawn at a random location?
    
if (get_pcvar_num(cvar_randspawn)) do_random_spawn(id)
    
    
// Hide money?
    
if (get_pcvar_num(cvar_removemoney))
        
set_task(0.4"task_hide_money"id+TASK_SPAWN)
    
    
// Respawn player if he dies because of a worldspawn kill?
    
if (get_pcvar_num(cvar_respawnworldspawnkill))
        
set_task(2.0"respawn_player_task"id+TASK_SPAWN)
    
    
// Spawn as zombie?
    
if (g_respawn_as_zombie[id] && !g_newround)
    {
        
reset_vars(id0// reset player vars
        
zombieme(id0000// make him zombie right away
        
return;
    }
    
    
// Reset player vars
    
reset_vars(id0)
    
    
// Show custom buy menu?
    
if (get_pcvar_num(cvar_buycustom))
        
set_task(0.2"show_menu_buy1"id+TASK_SPAWN)
    
    
// Set health and gravity
    
fm_set_user_health(idget_pcvar_num(cvar_humanhp))
    
set_pev(idpev_gravityget_pcvar_float(cvar_humangravity))
    
    
// Switch to CT if spawning mid-round
    
if (!g_newround && fm_cs_get_user_team(id) != FM_CS_TEAM_CT// need to change team?
    
{
        
remove_task(id+TASK_TEAM)
        
fm_cs_set_user_team(idFM_CS_TEAM_CT)
        
fm_user_team_update(id)
    }
    
    
// Custom models stuff
    
static currentmodel[32], tempmodel[32], already_has_modeliiRandsize
    already_has_model 
false
    
    
if (g_handle_models_on_separate_ent)
    {
        
// Set the right model
        
if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
        {
            
iRand random_num(0ArraySize(model_admin_human) - 1)
            
ArrayGetString(model_admin_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
            if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_admin_humaniRand))
        }
        else
        {
            
iRand random_num(0ArraySize(model_human) - 1)
            
ArrayGetString(model_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
            if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_humaniRand))
        }
        
        
// Set model on player model entity
        
fm_set_playermodel_ent(id)
        
        
// Remove glow on player model entity
        
fm_set_rendering(g_ent_playermodel[id])
    }
    else
    {
        
// Get current model for comparing it with the current one
        
fm_cs_get_user_model(idcurrentmodelcharsmax(currentmodel))
        
        
// Set the right model, after checking that we don't already have it
        
if (get_pcvar_num(cvar_adminmodelshuman) && (get_user_flags(id) & g_access_flag[ACCESS_ADMIN_MODELS]))
        {
            
size ArraySize(model_admin_human)
            for (
0sizei++)
            {
                
ArrayGetString(model_admin_humanitempmodelcharsmax(tempmodel))
                if (
equal(currentmodeltempmodel)) already_has_model true
            
}
            
            if (!
already_has_model)
            {
                
iRand random_num(0size 1)
                
ArrayGetString(model_admin_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_admin_humaniRand))
            }
        }
        else
        {
            
size ArraySize(model_human)
            for (
0sizei++)
            {
                
ArrayGetString(model_humanitempmodelcharsmax(tempmodel))
                if (
equal(currentmodeltempmodel)) already_has_model true
            
}
            
            if (!
already_has_model)
            {
                
iRand random_num(0size 1)
                
ArrayGetString(model_humaniRandg_playermodel[id], charsmax(g_playermodel[]))
                if (
g_set_modelindex_offsetfm_cs_set_user_model_index(idArrayGetCell(g_modelindex_humaniRand))
            }
        }
        
        
// Need to change the model?
        
if (!already_has_model)
        {
            
// An additional delay is offset at round start
            // since SVC_BAD is more likely to be triggered there
            
if (g_newround)
                
set_task(5.0 g_modelchange_delay"fm_user_model_update"id+TASK_MODEL)
            else
                
fm_user_model_update(id+TASK_MODEL)
        }
        
        
// Remove glow
        
fm_set_rendering(id)
    }
    
    
// Bots stuff
    
if (g_isbot[id])
    {
        
// Turn off NVG for bots
        
cs_set_user_nvg(id0)
        
        
// Automatically buy extra items/weapons after first zombie is chosen
        
if (get_pcvar_num(cvar_extraitems))
        {
            if (
g_newroundset_task(10.0 get_pcvar_float(cvar_warmup), "bot_buy_extras"id+TASK_SPAWN)
            else 
set_task(10.0"bot_buy_extras"id+TASK_SPAWN)
        }
    }
    
    
// Enable spawn protection for humans spawning mid-round
    
if (!g_newround && get_pcvar_float(cvar_spawnprotection) > 0.0)
    {
        
// Do not take damage
        
g_nodamage[id] = true
        
        
// Make temporarily invisible
        
set_pev(idpev_effectspev(idpev_effects) | EF_NODRAW)
        
        
// Set task to remove it
        
set_task(get_pcvar_float(cvar_spawnprotection), "remove_spawn_protection"id+TASK_SPAWN)
    }
    
    
// Set the flashlight charge task to update battery status
    
if (g_cached_customflash)
        
set_task(1.0"flashlight_charge"id+TASK_CHARGE__"b")
    
    
// Replace weapon models (bugfix)
    
static weapon_ent
    weapon_ent 
fm_cs_get_current_weapon_ent(id)
    if (
pev_valid(weapon_ent)) replace_weapon_models(idcs_get_weapon_id(weapon_ent))
    
    
// Last Zombie Check
    
fnCheckLastZombie()
}

// Ham Player Killed Forward
public fw_PlayerKilled(victimattackershouldgib)
{
    
// Player killed
    
g_isalive[victim] = false
    
    
// Enable dead players nightvision
    
set_task(0.1"spec_nvision"victim)
    
    
// Disable nightvision when killed (bugfix)
    
if (get_pcvar_num(cvar_nvggive) == && g_nvision[victim])
    {
        if (
get_pcvar_num(cvar_customnvg)) remove_task(victim+TASK_NVISION)
        else if (
g_nvisionenabled[victim]) set_user_gnvision(victim0)
        
g_nvision[victim] = false
        g_nvisionenabled
[victim] = false
    
}
    
    
// Turn off nightvision when killed (bugfix)
    
if (get_pcvar_num(cvar_nvggive) == && g_nvision[victim] && g_nvisionenabled[victim])
    {
        if (
get_pcvar_num(cvar_customnvg)) remove_task(victim+TASK_NVISION)
        else 
set_user_gnvision(victim0)
        
g_nvisionenabled[victim] = false
    
}
    
    
// Turn off custom flashlight when killed
    
if (g_cached_customflash)
    {
        
// Turn it off
        
g_flashlight[victim] = false
        g_flashbattery
[victim] = 100
        
        
// Remove previous tasks
        
remove_task(victim+TASK_CHARGE)
        
remove_task(victim+TASK_FLASH)
    }
    
    
// Stop bleeding/burning/aura when killed
    
if (g_zombie[victim])
    {
        
remove_task(victim+TASK_BLOOD)
        
remove_task(victim+TASK_AURA)
        
remove_task(victim+TASK_BURN)
    }
    
    
// Nemesis explodes!
    
if (g_nemesis[victim])
        
SetHamParamInteger(32)
    
    
// Get deathmatch mode status and whether the player killed himself
    
static selfkill
    selfkill 
= (victim == attacker || !is_user_valid_connected(attacker)) ? true false
    
    
// Respawn if deathmatch is enabled
    
if (get_pcvar_num(cvar_deathmatch))
    {
        
// Respawn on suicide?
        
if (selfkill && !get_pcvar_num(cvar_respawnonsuicide))
            return;
        
        
// Respawn if only the last human is left?
        
if (!get_pcvar_num(cvar_respawnafterlast) && fnGetHumans() <= 3)
            return;
        
        
// Respawn if human/zombie/nemesis/survivor?
        
if ((g_zombie[victim] && !g_nemesis[victim] && !get_pcvar_num(cvar_respawnzomb)) || (!g_zombie[victim] && !g_survivor[victim] && !get_pcvar_num(cvar_respawnhum)) || (g_nemesis[victim] && !get_pcvar_num(cvar_respawnnem)) || (g_survivor[victim] && !get_pcvar_num(cvar_respawnsurv)))
            return;
        
        
// Respawn as zombie?
        
if (get_pcvar_num(cvar_deathmatch) == || (get_pcvar_num(cvar_deathmatch) == && random_num(01)) || (get_pcvar_num(cvar_deathmatch) == && fnGetZombies() < fnGetAlive()/2))
            
g_respawn_as_zombie[victim] = true
        
        
// Set the respawn task
        
set_task(get_pcvar_float(cvar_spawndelay), "respawn_player_task"victim+TASK_SPAWN)
    }
    
    
// Killed by a non-player entity or self killed
    
if (selfkill) return;
    
    
// Ignore Nemesis/Survivor Frags?
    
if ((g_nemesis[attacker] && get_pcvar_num(cvar_nemignorefrags)) || (g_survivor[attacker] && get_pcvar_num(cvar_survignorefrags)))
        
RemoveFrags(attackervictim)
    
    
// Zombie/nemesis killed human, reward ammo packs
    
if (g_zombie[attacker] && (!g_nemesis[attacker] || !get_pcvar_num(cvar_nemignoreammo)))
        
g_ammopacks[attacker] += get_pcvar_num(cvar_ammoinfect)
    
    
// Human killed zombie, add up the extra frags for kill
    
if (!g_zombie[attacker] && get_pcvar_num(cvar_fragskill) > 1)
        
UpdateFrags(attackervictimget_pcvar_num(cvar_fragskill) - 100)
    
    
// Zombie killed human, add up the extra frags for kill
    
if (g_zombie[attacker] && get_pcvar_num(cvar_fragsinfect) > 1)
        
UpdateFrags(attackervictimget_pcvar_num(cvar_fragsinfect) - 100)
}

// Ham Player Killed Post Forward
public fw_PlayerKilled_Post()
{
    
// Last Zombie Check
    
fnCheckLastZombie()
}

// Ham Take Damage Forward
public fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_valid_connected(attacker))
        return 
HAM_IGNORED;
    
    
// New round starting or round ended
    
if (g_newround || g_endround)
        return 
HAM_SUPERCEDE;
    
    
// Victim shouldn't take damage or victim is frozen
    
if (g_nodamage[victim] || g_frozen[victim])
        return 
HAM_SUPERCEDE;
    
    
// Prevent friendly fire
    
if (g_zombie[attacker] == g_zombie[victim])
        return 
HAM_IGNORED;
    
    
// Attacker is human...
    
if (!g_zombie[attacker])
    {
        
// Armor multiplier for the final damage on normal zombies
        
if (!g_nemesis[victim])
        {
            
damage *= get_pcvar_float(cvar_zombiearmor)
            
SetHamParamFloat(4damage)
        }
        
        
// Reward ammo packs
        
if (!g_survivor[attacker] || !get_pcvar_num(cvar_survignoreammo))
        {
            
// Store damage dealt
            
g_damagedealt[attacker] += floatround(damage)
            
            
// Reward ammo packs for every [ammo damage] dealt
            
while (g_damagedealt[attacker] > get_pcvar_num(cvar_ammodamage))
            {
                
g_ammopacks[attacker]++
                
g_damagedealt[attacker] -= get_pcvar_num(cvar_ammodamage)
            }
        }
        
        return 
HAM_IGNORED;
    }
    
    
// Attacker is zombie...
    
    // Prevent infection/damage by HE grenade (bugfix)
    
if (damage_type DMG_HEGRENADE)
        return 
HAM_SUPERCEDE;
    
    
// Nemesis?
    
if (g_nemesis[attacker])
    {
        
// Ignore nemesis damage override if damage comes from a 3rd party entity
        // (to prevent this from affecting a sub-plugin's rockets e.g.)
        
if (inflictor == attacker)
        {
            
// Set nemesis damage
            
SetHamParamFloat(4get_pcvar_float(cvar_nemdamage))
        }
        
        return 
HAM_IGNORED;
    }
    
    
// Last human or not an infection round
    
if (g_survround || g_nemround || g_swarmround || g_plagueround || fnGetHumans() == 1)
        return 
HAM_IGNORED// human is killed
    
    // Does human armor need to be reduced before infecting?
    
if (get_pcvar_num(cvar_humanarmor))
    {
        
// Get victim armor
        
static Float:armor
        pev
(victimpev_armorvaluearmor)
        
        
// Block the attack if he has some
        
if (armor 0.0)
        {
            
emit_sound(victimCHAN_BODYsound_armorhit1.0ATTN_NORM0PITCH_NORM)
            
set_pev(victimpev_armorvaluefloatmax(0.0armor damage))
            return 
HAM_SUPERCEDE;
        }
    }
    
    
// Infection allowed
    
zombieme(victimattacker001// turn into zombie
    
return HAM_SUPERCEDE;
}

// Ham Take Damage Post Forward
public fw_TakeDamage_Post(victim)
{
    
// --- Check if victim should be Pain Shock Free ---
    
    // Check if proper CVARs are enabled
    
if (g_zombie[victim])
    {
        if (
g_nemesis[victim])
        {
            if (!
get_pcvar_num(cvar_nempainfree)) return;
        }
        else
        {
            switch (
get_pcvar_num(cvar_zombiepainfree))
            {
                case 
0: return;
                case 
2: if (!g_lastzombie[victim]) return;
            }
        }
    }
    else
    {
        if (
g_survivor[victim])
        {
            if (!
get_pcvar_num(cvar_survpainfree)) return;
        }
        else return;
    }
    
    
// Set pain shock free offset
    
set_pdata_float(victimOFFSET_PAINSHOCK1.0OFFSET_LINUX)
}

// Ham Trace Attack Forward
public fw_TraceAttack(victimattackerFloat:damageFloat:direction[3], tracehandledamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_valid_connected(attacker))
        return 
HAM_IGNORED;
    
    
// New round starting or round ended
    
if (g_newround || g_endround)
        return 
HAM_SUPERCEDE;
    
    
// Victim shouldn't take damage or victim is frozen
    
if (g_nodamage[victim] || g_frozen[victim])
        return 
HAM_SUPERCEDE;
    
    
// Prevent friendly fire
    
if (g_zombie[attacker] == g_zombie[victim])
        return 
HAM_IGNORED;
    
    
// Victim isn't a zombie or not bullet damage, nothing else to do here
    
if (!g_zombie[victim] || !(damage_type DMG_BULLET))
        return 
HAM_IGNORED;
    
    
// If zombie hitzones are enabled, check whether we hit an allowed one
    
if (get_pcvar_num(cvar_hitzones) && !g_nemesis[victim] && !(get_pcvar_num(cvar_hitzones) & (1<<get_tr2(tracehandleTR_iHitgroup))))
        return 
HAM_SUPERCEDE;
    
    
// Knockback disabled, nothing else to do here
    
if (!get_pcvar_num(cvar_knockback))
        return 
HAM_IGNORED;
    
    
// Nemesis knockback disabled, nothing else to do here
    
if (g_nemesis[victim] && get_pcvar_float(cvar_nemknockback) == 0.0)
        return 
HAM_IGNORED;
    
    
// Get whether the victim is in a crouch state
    
static ducking
    ducking 
pev(victimpev_flags) & (FL_DUCKING FL_ONGROUND) == (FL_DUCKING FL_ONGROUND)
    
    
// Zombie knockback when ducking disabled
    
if (ducking && get_pcvar_float(cvar_knockbackducking) == 0.0)
        return 
HAM_IGNORED;
    
    
// Get distance between players
    
static origin1[3], origin2[3]
    
get_user_origin(victimorigin1)
    
get_user_origin(attackerorigin2)
    
    
// Max distance exceeded
    
if (get_distance(origin1origin2) > get_pcvar_num(cvar_knockbackdist))
        return 
HAM_IGNORED;
    
    
// Get victim's velocity
    
static Float:velocity[3]
    
pev(victimpev_velocityvelocity)
    
    
// Use damage on knockback calculation
    
if (get_pcvar_num(cvar_knockbackdamage))
        
xs_vec_mul_scalar(directiondamagedirection)
    
    
// Use weapon power on knockback calculation
    
if (get_pcvar_num(cvar_knockbackpower) && kb_weapon_power[g_currentweapon[attacker]] > 0.0)
        
xs_vec_mul_scalar(directionkb_weapon_power[g_currentweapon[attacker]], direction)
    
    
// Apply ducking knockback multiplier
    
if (ducking)
        
xs_vec_mul_scalar(directionget_pcvar_float(cvar_knockbackducking), direction)
    
    
// Apply zombie class/nemesis knockback multiplier
    
if (g_nemesis[victim])
        
xs_vec_mul_scalar(directionget_pcvar_float(cvar_nemknockback), direction)
    else
        
xs_vec_mul_scalar(directiong_zombie_knockback[victim], direction)
    
    
// Add up the new vector
    
xs_vec_add(velocitydirectiondirection)
    
    
// Should knockback also affect vertical velocity?
    
if (!get_pcvar_num(cvar_knockbackzvel))
        
direction[2] = velocity[2]
    
    
// Set the knockback'd victim's velocity
    
set_pev(victimpev_velocitydirection)
    
    return 
HAM_IGNORED;
}

// Ham Use Stationary Gun Forward
public fw_UseStationary(entitycalleractivatoruse_type)
{
    
// Prevent zombies from using stationary guns
    
if (use_type == USE_USING && is_user_valid_connected(caller) && g_zombie[caller])
        return 
HAM_SUPERCEDE;
    
    return 
HAM_IGNORED;
}

// Ham Use Stationary Gun Post Forward
public fw_UseStationary_Post(entitycalleractivatoruse_type)
{
    
// Someone stopped using a stationary gun
    
if (use_type == USE_STOPPED && is_user_valid_connected(caller))
        
replace_weapon_models(callerg_currentweapon[caller]) // replace weapon models (bugfix)
}

// Ham Use Pushable Forward
public fw_UsePushable()
{
    
// Prevent speed bug with pushables?
    
if (get_pcvar_num(cvar_blockpushables))
        return 
HAM_SUPERCEDE;
    
    return 
HAM_IGNORED;
}

// Ham Weapon Touch Forward
public fw_TouchWeapon(weaponid)
{
    
// Not a player
    
if (!is_user_valid_connected(id))
        return 
HAM_IGNORED;
    
    
// Dont pickup weapons if zombie or survivor (+PODBot MM fix)
    
if (g_zombie[id] || (g_survivor[id] && !g_isbot[id]))
        return 
HAM_SUPERCEDE;
    
    return 
HAM_IGNORED;
}

// Ham Weapon Pickup Forward
public fw_AddPlayerItem(idweapon_ent)
{
    
// HACK: Retrieve our custom extra ammo from the weapon
    
static extra_ammo
    extra_ammo 
pev(weapon_entPEV_ADDITIONAL_AMMO)
    
    
// If present
    
if (extra_ammo)
    {
        
// Get weapon's id
        
static weaponid
        weaponid 
cs_get_weapon_id(weapon_ent)
        
        
// Add to player's bpammo
        
ExecuteHamB(Ham_GiveAmmoidextra_ammoAMMOTYPE[weaponid], MAXBPAMMO[weaponid])
        
set_pev(weapon_entPEV_ADDITIONAL_AMMO0)
    }
}

// Ham Weapon Deploy Forward
public fw_Item_Deploy_Post(weapon_ent)
{
    
// Get weapon's owner
    
static owner
    owner 
fm_cs_get_weapon_ent_owner(weapon_ent)
    
    
// Get weapon's id
    
static weaponid
    weaponid 
cs_get_weapon_id(weapon_ent)
    
    
// Store current weapon's id for reference
    
g_currentweapon[owner] = weaponid
    
    
// Replace weapon models with custom ones
    
replace_weapon_models(ownerweaponid)
    
    
// Zombie not holding an allowed weapon for some reason
    
if (g_zombie[owner] && !((1<<weaponid) & ZOMBIE_ALLOWED_WEAPONS_BITSUM))
    {
        
// Switch to knife
        
g_currentweapon[owner] = CSW_KNIFE
        engclient_cmd
(owner"weapon_knife")
    }
}

// WeaponMod bugfix
//forward wpn_gi_reset_weapon(id);
public wpn_gi_reset_weapon(id)
{
    
// Replace knife model
    
replace_weapon_models(idCSW_KNIFE)
}

// Client joins the game
public client_putinserver(id)
{
    
// Plugin disabled?
    
if (!g_pluginenabled) return;
    
    
// Player joined
    
g_isconnected[id] = true
    
    
// Cache player's name
    
get_user_name(idg_playername[id], charsmax(g_playername[]))
    
    
// Initialize player vars
    
reset_vars(id1)
    
    
// Load player stats?
    
if (get_pcvar_num(cvar_statssave)) load_stats(id)
    
    
// Set some tasks for humans only
    
if (!is_user_bot(id))
    {
        
// Set the custom HUD display task
        //set_task(1.0, "ShowHUD", id+TASK_SHOWHUD, _, _, "b")
        
        // Disable minmodels for clients to see zombies properly
        
set_task(5.0"disable_minmodels"id)
    }
    else
    {
        
// Set bot flag
        
g_isbot[id] = true
        
        
// CZ bots seem to use a different "classtype" for player entities
        // (or something like that) which needs to be hooked separately
        
if (!g_hamczbots && cvar_botquota)
        {
            
// Set a task to let the private data initialize
            
set_task(0.1"register_ham_czbots"id)
        }
    }
}

// Client leaving
public fw_ClientDisconnect(id)
{
    
// Check that we still have both humans and zombies to keep the round going
    
if (g_isalive[id]) check_round(id)
    
    
// Temporarily save player stats?
    
if (get_pcvar_num(cvar_statssave)) save_stats(id)
    
    
// Remove previous tasks
    
remove_task(id+TASK_TEAM)
    
remove_task(id+TASK_MODEL)
    
remove_task(id+TASK_FLASH)
    
remove_task(id+TASK_CHARGE)
    
remove_task(id+TASK_SPAWN)
    
remove_task(id+TASK_BLOOD)
    
remove_task(id+TASK_AURA)
    
remove_task(id+TASK_BURN)
    
remove_task(id+TASK_NVISION)
    
//remove_task(id+TASK_SHOWHUD)
    
    
if (g_handle_models_on_separate_ent)
    {
        
// Remove custom model entities
        
fm_remove_model_ents(id)
    }
    
    
// Player left, clear cached flags
    
g_isconnected[id] = false
    g_isbot
[id] = false
    g_isalive
[id] = false
}

// Client left
public fw_ClientDisconnect_Post()
{
    
// Last Zombie Check
    
fnCheckLastZombie()
}

// Client Kill Forward
public fw_ClientKill()
{
    
// Prevent players from killing themselves?
    
if (get_pcvar_num(cvar_blocksuicide))
        return 
FMRES_SUPERCEDE;
    
    return 
FMRES_IGNORED;
}

// Emit Sound Forward
public fw_EmitSound(idchannel, const sample[], Float:volumeFloat:attnflagspitch)
{
    
// Block all those unneeeded hostage sounds
    
if (sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
        return 
FMRES_SUPERCEDE;
    
    
// Replace these next sounds for zombies only
    
if (!is_user_valid_connected(id) || !g_zombie[id])
        return 
FMRES_IGNORED;
    
    static 
sound[64]
    
    
// Zombie being hit
    
if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't')
    {
        if (
g_nemesis[id])
        {
            
ArrayGetString(nemesis_painrandom_num(0ArraySize(nemesis_pain) - 1), soundcharsmax(sound))
            
emit_sound(idchannelsoundvolumeattnflagspitch)
        }
        else
        {
            
ArrayGetString(zombie_painrandom_num(0ArraySize(zombie_pain) - 1), soundcharsmax(sound))
            
emit_sound(idchannelsoundvolumeattnflagspitch)
        }
        return 
FMRES_SUPERCEDE;
    }
    
    
// Zombie attacks with knife
    
if (sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i')
    {
        if (
sample[14] == 's' && sample[15] == 'l' && sample[16] == 'a'// slash
        
{
            
ArrayGetString(zombie_miss_slashrandom_num(0ArraySize(zombie_miss_slash) - 1), soundcharsmax(sound))
            
emit_sound(idchannelsoundvolumeattnflagspitch)
            return 
FMRES_SUPERCEDE;
        }
        if (
sample[14] == 'h' && sample[15] == 'i' && sample[16] == 't'// hit
        
{
            if (
sample[17] == 'w'// wall
            
{
                
ArrayGetString(zombie_miss_wallrandom_num(0ArraySize(zombie_miss_wall) - 1), soundcharsmax(sound))
                
emit_sound(idchannelsoundvolumeattnflagspitch)
                return 
FMRES_SUPERCEDE;
            }
            else
            {
                
ArrayGetString(zombie_hit_normalrandom_num(0ArraySize(zombie_hit_normal) - 1), soundcharsmax(sound))
                
emit_sound(idchannelsoundvolumeattnflagspitch)
                return 
FMRES_SUPERCEDE;
            }
        }
        if (
sample[14] == 's' && sample[15] == 't' && sample[16] == 'a'// stab
        
{
            
ArrayGetString(zombie_hit_stabrandom_num(0ArraySize(zombie_hit_stab) - 1), soundcharsmax(sound))
            
emit_sound(idchannelsoundvolumeattnflagspitch)
            return 
FMRES_SUPERCEDE;
        }
    }
    
    
// Zombie dies
    
if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
    {
        
ArrayGetString(zombie_dierandom_num(0ArraySize(zombie_die) - 1), soundcharsmax(sound))
        
emit_sound(idchannelsoundvolumeattnflagspitch)
        return 
FMRES_SUPERCEDE;
    }
    
    
// Zombie falls off
    
if (sample[10] == 'f' && sample[11] == 'a' && sample[12] == 'l' && sample[13] == 'l')
    {
        
ArrayGetString(zombie_fallrandom_num(0ArraySize(zombie_fall) - 1), soundcharsmax(sound))
        
emit_sound(idchannelsoundvolumeattnflagspitch)
        return 
FMRES_SUPERCEDE;
    }
    
    return 
FMRES_IGNORED;
}

// Forward Set ClientKey Value -prevent CS from changing player models-
public fw_SetClientKeyValue(id, const infobuffer[], const key[])
{
    
// Block CS model changes
    
if (key[0] == 'm' && key[1] == 'o' && key[2] == 'd' && key[3] == 'e' && key[4] == 'l')
        return 
FMRES_SUPERCEDE;
    
    return 
FMRES_IGNORED;
}

// Forward Client User Info Changed -prevent players from changing models-
public fw_ClientUserInfoChanged(id)
{
    
// Cache player's name
    
get_user_name(idg_playername[id], charsmax(g_playername[]))
    
    if (!
g_handle_models_on_separate_ent)
    {
        
// Get current model
        
static currentmodel[32]
        
fm_cs_get_user_model(idcurrentmodelcharsmax(currentmodel))
        
        
// If they're different, set model again
        
if (!equal(currentmodelg_playermodel[id]) && !task_exists(id+TASK_MODEL))
            
fm_cs_set_user_model(id+TASK_MODEL)
    }
}

// Forward Get Game Description
public fw_GetGameDescription()
{
    
// Return the mod name so it can be easily identified
    
forward_return(FMV_STRINGg_modname)
    
    return 
FMRES_SUPERCEDE;
}

// Forward Set Model
public fw_SetModel(entity, const model[])
{
    
// We don't care
    
if (strlen(model) < 8)
        return;
    
    
// Remove weapons?
    
if (get_pcvar_float(cvar_removedropped) > 0.0)
    {
        
// Get entity's classname
        
static classname[10]
        
pev(entitypev_classnameclassnamecharsmax(classname))
        
        
// Check if it's a weapon box
        
if (equal(classname"weaponbox"))
        {
            
// They get automatically removed when thinking
            
set_pev(entitypev_nextthinkget_gametime() + get_pcvar_float(cvar_removedropped))
            return;
        }
    }
    
    
// Narrow down our matches a bit
    
if (model[7] != 'w' || model[8] != '_')
        return;
    
    
// Get damage time of grenade
    
static Float:dmgtime
    pev
(entitypev_dmgtimedmgtime)
    
    
// Grenade not yet thrown
    
if (dmgtime == 0.0)
        return;
    
    
// Get whether grenade's owner is a zombie
    
if (g_zombie[pev(entitypev_owner)])
    {
        if (
model[9] == 'h' && model[10] == 'e' && get_pcvar_num(cvar_extrainfbomb)) // Infection Bomb
        
{
            
// Give it a glow
            
fm_set_rendering(entitykRenderFxGlowShell02000kRenderNormal16);
            
            
// And a colored trail
            
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
            
write_byte(TE_BEAMFOLLOW// TE id
            
write_short(entity// entity
            
write_short(g_trailSpr// sprite
            
write_byte(10// life
            
write_byte(10// width
            
write_byte(0// r
            
write_byte(200// g
            
write_byte(0// b
            
write_byte(200// brightness
            
message_end()
            
            
// Set grenade type on the thrown grenade entity
            
set_pev(entityPEV_NADE_TYPENADE_TYPE_INFECTION)
        }
    }
    else if (
model[9] == 'h' && model[10] == 'e' && get_pcvar_num(cvar_firegrenades)) // Napalm Grenade
    
{
        
// Give it a glow
        
fm_set_rendering(entitykRenderFxGlowShell20000kRenderNormal16);
        
        
// And a colored trail
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_BEAMFOLLOW// TE id
        
write_short(entity// entity
        
write_short(g_trailSpr// sprite
        
write_byte(10// life
        
write_byte(10// width
        
write_byte(200// r
        
write_byte(0// g
        
write_byte(0// b
        
write_byte(200// brightness
        
message_end()
        
        
// Set grenade type on the thrown grenade entity
        
set_pev(entityPEV_NADE_TYPENADE_TYPE_NAPALM)
    }
    else if (
model[9] == 'f' && model[10] == 'l' && get_pcvar_num(cvar_frostgrenades)) // Frost Grenade
    
{
        
// Give it a glow
        
fm_set_rendering(entitykRenderFxGlowShell0100200kRenderNormal16);
        
        
// And a colored trail
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_BEAMFOLLOW// TE id
        
write_short(entity// entity
        
write_short(g_trailSpr// sprite
        
write_byte(10// life
        
write_byte(10// width
        
write_byte(0// r
        
write_byte(100// g
        
write_byte(200// b
        
write_byte(200// brightness
        
message_end()
        
        
// Set grenade type on the thrown grenade entity
        
set_pev(entityPEV_NADE_TYPENADE_TYPE_FROST)
    }
    else if (
model[9] == 's' && model[10] == 'm' && get_pcvar_num(cvar_flaregrenades)) // Flare
    
{
        
// Build flare's color
        
static rgb[3]
        switch (
get_pcvar_num(cvar_flarecolor))
        {
            case 
0// white
            
{
                
rgb[0] = 255 // r
                
rgb[1] = 255 // g
                
rgb[2] = 255 // b
            
}
            case 
1// red
            
{
                
rgb[0] = random_num(50,255// r
                
rgb[1] = // g
                
rgb[2] = // b
            
}
            case 
2// green
            
{
                
rgb[0] = // r
                
rgb[1] = random_num(50,255// g
                
rgb[2] = // b
            
}
            case 
3// blue
            
{
                
rgb[0] = // r
                
rgb[1] = // g
                
rgb[2] = random_num(50,255// b
            
}
            case 
4// random (all colors)
            
{
                
rgb[0] = random_num(50,200// r
                
rgb[1] = random_num(50,200// g
                
rgb[2] = random_num(50,200// b
            
}
            case 
5// random (r,g,b)
            
{
                switch (
random_num(13))
                {
                    case 
1// red
                    
{
                        
rgb[0] = random_num(50,255// r
                        
rgb[1] = // g
                        
rgb[2] = // b
                    
}
                    case 
2// green
                    
{
                        
rgb[0] = // r
                        
rgb[1] = random_num(50,255// g
                        
rgb[2] = // b
                    
}
                    case 
3// blue
                    
{
                        
rgb[0] = // r
                        
rgb[1] = // g
                        
rgb[2] = random_num(50,255// b
                    
}
                }
            }
        }
        
        
// Give it a glow
        
fm_set_rendering(entitykRenderFxGlowShellrgb[0], rgb[1], rgb[2], kRenderNormal16);
        
        
// And a colored trail
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_BEAMFOLLOW// TE id
        
write_short(entity// entity
        
write_short(g_trailSpr// sprite
        
write_byte(10// life
        
write_byte(10// width
        
write_byte(rgb[0]) // r
        
write_byte(rgb[1]) // g
        
write_byte(rgb[2]) // b
        
write_byte(200// brightness
        
message_end()
        
        
// Set grenade type on the thrown grenade entity
        
set_pev(entityPEV_NADE_TYPENADE_TYPE_FLARE)
        
        
// Set flare color on the thrown grenade entity
        
set_pev(entityPEV_FLARE_COLORrgb)
    }
}

// Ham Grenade Think Forward
public fw_ThinkGrenade(entity)
{
    
// Invalid entity
    
if (!pev_valid(entity)) return HAM_IGNORED;
    
    
// Get damage time of grenade
    
static Float:dmgtimeFloat:current_time
    pev
(entitypev_dmgtimedmgtime)
    
current_time get_gametime()
    
    
// Check if it's time to go off
    
if (dmgtime current_time)
        return 
HAM_IGNORED;
    
    
// Check if it's one of our custom nades
    
switch (pev(entityPEV_NADE_TYPE))
    {
        case 
NADE_TYPE_INFECTION// Infection Bomb
        
{
            
infection_explode(entity)
            return 
HAM_SUPERCEDE;
        }
        case 
NADE_TYPE_NAPALM// Napalm Grenade
        
{
            
fire_explode(entity)
            return 
HAM_SUPERCEDE;
        }
        case 
NADE_TYPE_FROST// Frost Grenade
        
{
            
frost_explode(entity)
            return 
HAM_SUPERCEDE;
        }
        case 
NADE_TYPE_FLARE// Flare
        
{
            
// Get its duration
            
static duration
            duration 
pev(entityPEV_FLARE_DURATION)
            
            
// Already went off, do lighting loop for the duration of PEV_FLARE_DURATION
            
if (duration 0)
            {
                
// Check whether this is the last loop
                
if (duration == 1)
                {
                    
// Get rid of the flare entity
                    
engfunc(EngFunc_RemoveEntityentity)
                    return 
HAM_SUPERCEDE;
                }
                
                
// Light it up!
                
flare_lighting(entityduration)
                
                
// Set time for next loop
                
set_pev(entityPEV_FLARE_DURATION, --duration)
                
set_pev(entitypev_dmgtimecurrent_time 5.0)
            }
            
// Light up when it's stopped on ground
            
else if ((pev(entitypev_flags) & FL_ONGROUND) && fm_get_speed(entity) < 10)
            {
                
// Flare sound
                
static sound[64]
                
ArrayGetString(grenade_flarerandom_num(0ArraySize(grenade_flare) - 1), soundcharsmax(sound))
                
emit_sound(entityCHAN_WEAPONsound1.0ATTN_NORM0PITCH_NORM)
                
                
// Set duration and start lightning loop on next think
                
set_pev(entityPEV_FLARE_DURATIONget_pcvar_num(cvar_flareduration)/5)
                
set_pev(entitypev_dmgtimecurrent_time 0.1)
            }
            else
            {
                
// Delay explosion until we hit ground
                
set_pev(entitypev_dmgtimecurrent_time 0.5)
            }
        }
    }
    
    return 
HAM_IGNORED;
}

// Forward CmdStart
public fw_CmdStart(idhandle)
{
    
// Not alive
    
if (!g_isalive[id])
        return;
    
    
// This logic looks kinda weird, but it should work in theory...
    // p = g_zombie[id], q = g_survivor[id], r = g_cached_customflash
    // (p v q v (p ^ r)) <==> p ^ q ^ (p v r)
    
if (!g_zombie[id] && !g_survivor[id] && (g_zombie[id] || !g_cached_customflash))
        return;
    
    
// Check if it's a flashlight impulse
    
if (get_uc(handleUC_Impulse) != IMPULSE_FLASHLIGHT)
        return;
    
    
// Block it I say!
    
set_uc(handleUC_Impulse0)
    
    
// Should human's custom flashlight be turned on?
    
if (!g_zombie[id] && !g_survivor[id] && g_flashbattery[id] > && get_gametime() - g_lastflashtime[id] > 1.2)
    {
        
// Prevent calling flashlight too quickly (bugfix)
        
g_lastflashtime[id] = get_gametime()
        
        
// Toggle custom flashlight
        
g_flashlight[id] = !(g_flashlight[id])
        
        
// Play flashlight toggle sound
        
emit_sound(idCHAN_ITEMsound_flashlight1.0ATTN_NORM0PITCH_NORM)
        
        
// Update flashlight status on the HUD
        
message_begin(MSG_ONEg_msgFlashlight_id)
        
write_byte(g_flashlight[id]) // toggle
        
write_byte(g_flashbattery[id]) // battery
        
message_end()
        
        
// Remove previous tasks
        
remove_task(id+TASK_CHARGE)
        
remove_task(id+TASK_FLASH)
        
        
// Set the flashlight charge task
        
set_task(1.0"flashlight_charge"id+TASK_CHARGE__"b")
        
        
// Call our custom flashlight task if enabled
        
if (g_flashlight[id]) set_task(0.1"set_user_flashlight"id+TASK_FLASH__"b")
    }
}

// Forward Player PreThink
public fw_PlayerPreThink(id)
{
    
// Not alive
    
if (!g_isalive[id])
        return;
    
    
// Silent footsteps for zombies?
    
if (g_cached_zombiesilent && g_zombie[id] && !g_nemesis[id])
        
set_pev(idpev_flTimeStepSoundSTEPTIME_SILENT)
    
    
// Set Player MaxSpeed
    
if (g_frozen[id])
    {
        
set_pev(idpev_velocityFloat:{0.0,0.0,0.0}) // stop motion
        
set_pev(idpev_maxspeed1.0// prevent from moving
        
return; // shouldn't leap while frozen
    
}
    else if (
g_freezetime)
    {
        return; 
// shouldn't leap while in freezetime
    
}
    else
    {
        if (
g_zombie[id])
        {
            if (
g_nemesis[id])
                
set_pev(idpev_maxspeedg_cached_nemspd)
            else
                
set_pev(idpev_maxspeedg_zombie_spd[id])
        }
        else
        {
            if (
g_survivor[id])
                
set_pev(idpev_maxspeedg_cached_survspd)
            else
                
set_pev(idpev_maxspeedg_cached_humanspd)
        }
    }
    
    
// --- Check if player should leap ---
    
    // Check if proper CVARs are enabled and retrieve leap settings
    
static Float:cooldownFloat:current_time
    
if (g_zombie[id])
    {
        if (
g_nemesis[id])
        {
            if (!
g_cached_leapnemesis) return;
            
cooldown g_cached_leapnemesiscooldown
        
}
        else
        {
            switch (
g_cached_leapzombies)
            {
                case 
0: return;
                case 
2: if (!g_firstzombie[id]) return;
                case 
3: if (!g_lastzombie[id]) return;
            }
            
cooldown g_cached_leapzombiescooldown
        
}
    }
    else
    {
        if (
g_survivor[id])
        {
            if (!
g_cached_leapsurvivor) return;
            
cooldown g_cached_leapsurvivorcooldown
        
}
        else return;
    }
    
    
current_time get_gametime()
    
    
// Cooldown not over yet
    
if (current_time g_lastleaptime[id] < cooldown)
        return;
    
    
// Not doing a longjump (don't perform check for bots, they leap automatically)
    
if (!g_isbot[id] && !(pev(idpev_button) & (IN_JUMP IN_DUCK) == (IN_JUMP IN_DUCK)))
        return;
    
    
// Not on ground or not enough speed
    
if (!(pev(idpev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
        return;
    
    static 
Float:velocity[3]
    
    
// Make velocity vector
    
velocity_by_aim(idg_survivor[id] ? get_pcvar_num(cvar_leapsurvivorforce) : g_nemesis[id] ? get_pcvar_num(cvar_leapnemesisforce) : get_pcvar_num(cvar_leapzombiesforce), velocity)
    
    
// Set custom height
    
velocity[2] = g_survivor[id] ? get_pcvar_float(cvar_leapsurvivorheight) : g_nemesis[id] ? get_pcvar_float(cvar_leapnemesisheight) : get_pcvar_float(cvar_leapzombiesheight)
    
    
// Apply the new velocity
    
set_pev(idpev_velocityvelocity)
    
    
// Update last leap time
    
g_lastleaptime[id] = current_time

pe4enko is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:25.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode