There should be credits to this e.g. Pain shock free code. I believe it's someone else right?
This is better
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
new cvar_last_human_pain_free, cvar_human_pain_free_swarm
new cached_last_human_pain_free, cached_human_pain_free_swarm
const OFFSET_LINUX = 5
const OFFSET_PAINSHOCK = 108
const PDATA_SAFE = 2
#define PLUGIN "[ZP] Last Human Pain Shock Free"
#define VERSION "0.1"
#define AUTHOR "Dolph_Ziggler"
new g_bitZombiePlayers, g_bitLastHumanPlayers
#define MarkUserZombie(%0) g_bitZombiePlayers |= (1 << (%0 & 31))
#define ClearUserZombie(%0) g_bitZombiePlayers &= ~(1 << (%0 & 31))
#define IsUserZombie(%0) g_bitZombiePlayers & (1 << (%0 & 31))
#define MarkUserLastHuman(%0) g_bitLastHumanPlayers |= (1 << (%0 & 31))
#define ClearUserLastHuman(%0) g_bitLastHumanPlayers &= ~(1 << (%0 & 31))
#define IsUserLastHuman(%0) g_bitLastHumanPlayers & (1 << (%0 & 31))
new bool:bInSwarm
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
RegisterHam(Ham_TakeDamage, "player", "Player_TakeDamage", 1)
cvar_last_human_pain_free = register_cvar("zp_last_human_pain_free", "1")
cvar_human_pain_free_swarm = register_cvar("zp_human_pain_free_in_swarm", "0")
}
public client_disconnect(id)
{
ClearUserZombie(id)
ClearUserLastHuman(id)
}
public event_new_round()
{
cached_last_human_pain_free = get_pcvar_num(cvar_last_human_pain_free)
cached_human_pain_free_swarm = get_pcvar_num(cvar_human_pain_free_swarm)
new iPlayers[32], iNum
get_players(iPlayers, iNum)
for(new i = 0; i < iNum; i++)
{
ClearUserZombie(i)
ClearUserLastHuman(i)
}
}
public Player_TakeDamage(id)
{
if(pev_valid(id) != PDATA_SAFE)
return HAM_IGNORED
if(IsUserZombie(id))
return HAM_IGNORED
if (IsUserLastHuman(id) && cached_last_human_pain_free)
{
set_pdata_float(id, OFFSET_PAINSHOCK, 1.0, OFFSET_LINUX)
}
else if (bInSwarm && cached_human_pain_free_swarm)
{
set_pdata_float(id, OFFSET_PAINSHOCK, 1.0, OFFSET_LINUX)
}
return HAM_IGNORED
}
public zp_round_started(gamemode)
{
if(gamemode == MODE_SWARM)
bInSwarm = true
else
bInSwarm = false // Reset it on a new mode start
}
public zp_user_infected_post(id)
{
MarkUserZombie(id)
}
public zp_user_humanized_post(id)
{
ClearUserZombie(id)
}
public zp_user_last_human(id)
{
MarkUserLastHuman(id)
}