PHP Code:
#include <amxmodx>
#include <fun>
#include <zombie_plague_advance>
#include <hamsandwich>
new const g_chance = 120
new const g_access_flag[] = "a"
new g_gameid, g_maxplayers, cvar_minplayers, cvar_ratio, cvar_sniperhp, cvar_nemhp, g_msg_sync
public plugin_init( )
{
register_plugin( "[ZP] Snipers VS Nemesis Mode","1.0", "zmd94" )
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled_Post", 1)
cvar_minplayers = register_cvar("zp_minplayers", "2")
cvar_sniperhp = register_cvar("zp_sniper_hp", "1.5")
cvar_nemhp = register_cvar("zp_nem_hp", "0.3")
cvar_ratio = register_cvar("zp_svn_inf_ratio", "0.4")
g_maxplayers = get_maxplayers()
g_msg_sync = CreateHudSyncObj()
}
public plugin_natives()
{
register_native("zp_is_svn_round", "native_is_svn_round", 1)
}
public plugin_precache( )
{
new access_flag = read_flags( g_access_flag )
g_gameid = zp_register_game_mode( "Sniper vs Nemesis Mode", access_flag, g_chance, 0, ZP_DM_BALANCE )
}
public fw_PlayerKilled_Post(victim, attacker, shouldgib)
{
if(is_user_connected(victim) && zp_get_current_mode() == g_gameid)
{
set_task(2.0, "xReviveUser", victim)
}
}
public xReviveUser(victim)
{
if(is_user_connected(victim) && zp_get_current_mode() == g_gameid)
{
new x = random_num(0, 1)
zp_respawn_user(victim, x ? ZP_TEAM_SNIPER : ZP_TEAM_NEMESIS)
}
}
public zp_round_started_pre( game )
{
if( game == g_gameid )
{
if( fn_get_alive_players() < get_pcvar_num(cvar_minplayers) )
{
return ZP_PLUGIN_HANDLED
}
start_svn_mode( )
}
return PLUGIN_CONTINUE
}
public zp_round_started( game, id )
{
if( game == g_gameid )
{
set_hudmessage(221, 156, 21, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_msg_sync, "Snipers vs Nemesis Mode!")
}
}
public zp_game_mode_selected( gameid, id )
{
if( gameid == g_gameid )
start_svn_mode( )
return PLUGIN_CONTINUE
}
start_svn_mode( )
{
static i_nemesiss, i_max_nemesiss, id, i_alive
i_alive = fn_get_alive_players()
id = 0
i_max_nemesiss = floatround( ( i_alive * get_pcvar_float( cvar_ratio ) ), floatround_ceil )
i_nemesiss = 0
while (i_nemesiss < i_max_nemesiss)
{
if ( (++id) > g_maxplayers) id = 1
if ( !is_user_alive(id) )
continue;
if (random_num(1, 5) == 1)
{
zp_make_user_nemesis(id)
set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_nemhp)) )
i_nemesiss++
}
}
for (id = 1; id <= g_maxplayers; id++)
{
if ( !is_user_alive(id) || zp_get_user_nemesis(id) )
continue;
zp_make_user_sniper(id)
set_user_health( id, floatround(get_user_health(id) * get_pcvar_float(cvar_sniperhp)) )
}
}
fn_get_alive_players( )
{
static i_alive, id
i_alive = 0
for ( id = 1; id <= g_maxplayers; id++ )
{
if( is_user_alive( id ) )
i_alive++
}
return i_alive;
}
public native_is_svn_round()
{
return zp_get_current_mode() == g_gameid ? true : false
}