This plugin is not mine. All credits goes to jc980.
PHP Code:
/*-------------------------------------------------------------------------------------------------*
[ Zombie Plague 4.3 Plugin Addon: ZP CSO Theme's Respawn Method ]
[ By jc980 ]
[ Request By louistds ]
*-------------------------------------------------------------------------------------------------*/
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
new const ZP_CSO_PLUGIN_NAME[] = "[ZP] CSO In-Game Theme"
new const ZP_CSO_PLUGIN_VERSION[] = "4.0"
new const ZP_CSO_PLUGIN_AUTHOR[] = "jc980"
new zp_cso_roundstarted, zp_center_textmsg, zp_cso_round, zp_cso_humanswins, zp_cso_zombieswins, zp_cso_hud_sync1
new zp_cso_total_spawn = 0, bool:zp_cso_first_spawn[33]
new Float: zp_cso_spawn_vec[60][3], Float: zp_cso_spawn_angle[60][3], Float: zp_cso_spawn_v_angle[60][3]
new zp_cso_respawnspr, zp_cso_respawnwait[33]
new zp_cso_cvar_enablerespawn, zp_cso_cvar_delayrespawn
new const zp_cso_zombierespawn[][] =
{
"zombie_plague/cso/zombi_comeback.wav"
}
new zp_cso_respawnsprite[][] =
{
"sprites/zombie_plague/cso/zp_zbrespawn.spr"
}
public plugin_init()
{
register_plugin(ZP_CSO_PLUGIN_NAME, ZP_CSO_PLUGIN_VERSION, ZP_CSO_PLUGIN_AUTHOR)
register_event("HLTV", "zp_cso_round_start", "a", "1=0", "2=0")
register_event("DeathMsg", "zp_cso_death", "a")
zp_cso_cvar_enablerespawn = register_cvar("zp_csotheme_enable_respawn", "1")
zp_cso_cvar_delayrespawn = register_cvar("zp_csotheme_delay_respawn", "5.0")
zp_center_textmsg = get_user_msgid("TextMsg")
server_cmd("exec addons/amxmodx/configs/zp_cso_theme.cfg")
csdm_respawn()
}
public plugin_precache()
{
register_dictionary("zp_cso_theme.txt")
new i
for(i = 0; i < sizeof zp_cso_zombierespawn; i++)
engfunc(EngFunc_PrecacheSound, zp_cso_zombierespawn[i])
for(i = 0; i < sizeof zp_cso_respawnsprite; i++)
zp_cso_respawnspr = engfunc(EngFunc_PrecacheModel, zp_cso_respawnsprite[i])
}
public zp_cso_round_start()
{
zp_cso_round += 1
}
csdm_respawn()
{
new zp_map[32], zp_config[32], zp_mapfile[64]
get_mapname(zp_map, 31)
get_configsdir(zp_config, 31)
format(zp_mapfile, 63, "%s\csdm\%s.spawns.cfg", zp_config, zp_map)
zp_cso_total_spawn = 0
if (file_exists(zp_mapfile))
{
new zp_new_data[124], zp_len
new zp_line = 0
new zp_pos[12][8]
while(zp_cso_total_spawn < 60 && (zp_line = read_file(zp_mapfile , zp_line, zp_new_data, 123, zp_len)) != 0)
{
if (strlen(zp_new_data) < 2 || zp_new_data[0] == '[')
continue
parse(zp_new_data, zp_pos[1], 7, zp_pos[2], 7, zp_pos[3], 7, zp_pos[4], 7, zp_pos[5], 7, zp_pos[6], 7, zp_pos[7], 7, zp_pos[8], 7, zp_pos[9], 7, zp_pos[10], 7)
zp_cso_spawn_vec[zp_cso_total_spawn][0] = str_to_float(zp_pos[1])
zp_cso_spawn_vec[zp_cso_total_spawn][1] = str_to_float(zp_pos[2])
zp_cso_spawn_vec[zp_cso_total_spawn][2] = str_to_float(zp_pos[3])
zp_cso_spawn_angle[zp_cso_total_spawn][0] = str_to_float(zp_pos[4])
zp_cso_spawn_angle[zp_cso_total_spawn][1] = str_to_float(zp_pos[5])
zp_cso_spawn_angle[zp_cso_total_spawn][2] = str_to_float(zp_pos[6])
zp_cso_spawn_v_angle[zp_cso_total_spawn][0] = str_to_float(zp_pos[8])
zp_cso_spawn_v_angle[zp_cso_total_spawn][1] = str_to_float(zp_pos[9])
zp_cso_spawn_v_angle[zp_cso_total_spawn][2] = str_to_float(zp_pos[10])
zp_cso_total_spawn += 1
}
if (zp_cso_total_spawn >= 2 && get_pcvar_num(zp_cso_cvar_enablerespawn) == 1)
{
RegisterHam(Ham_Spawn, "player", "zp_cso_zombie_spawn", 1)
}
}
return 1
}
public zp_cso_zombie_spawn(id)
{
if (!is_user_alive(id) || !zp_get_user_zombie(id))
return PLUGIN_CONTINUE
if (zp_cso_first_spawn[id])
{
zp_cso_first_spawn[id] = false
return PLUGIN_CONTINUE
}
new zp_list[60]
new zp_num = 0
new zp_final = -1
new zp_total = 0
new zp_players[32], zp_no, zp_xo = 0
new Float:zp_location[32][3], zp_locnum
get_players(zp_players,zp_num)
for (new i=0; i<zp_num; i++)
{
if (is_user_alive(zp_players[i]) && zp_players[i] != id)
{
pev(zp_players[i], pev_origin, zp_location[zp_locnum])
zp_locnum++
}
}
zp_num = 0
while (zp_num <= zp_cso_total_spawn)
{
if (zp_num == zp_cso_total_spawn)
break
zp_no = random_num(0, zp_cso_total_spawn - 1)
if (!zp_list[zp_no])
{
zp_list[zp_no] = 1
zp_num += 1
}
else
{
zp_total += 1
if (zp_total > 100)
break
continue
}
if (zp_locnum < 1)
{
zp_final = zp_no
break
}
zp_final = zp_no
for (zp_xo = 0; zp_xo < zp_locnum; zp_xo++)
{
new Float: zp_distance = get_distance_f(zp_cso_spawn_vec[zp_no], zp_location[zp_xo])
if (zp_distance < 250.0)
{
zp_final = -1
break
}
}
if (zp_final != -1)
break
}
if (zp_final != -1)
{
new Float:mins[3], Float:maxs[3]
pev(id, pev_mins, mins)
pev(id, pev_maxs, maxs)
engfunc(EngFunc_SetSize, id, mins, maxs)
engfunc(EngFunc_SetOrigin, id, zp_cso_spawn_vec[zp_final])
set_pev(id, pev_fixangle, 1)
set_pev(id, pev_angles, zp_cso_spawn_angle[zp_final])
set_pev(id, pev_v_angle, zp_cso_spawn_v_angle[zp_final])
set_pev(id, pev_fixangle, 1)
}
return PLUGIN_CONTINUE
}
public zp_cso_death()
{
new iKiller = read_data(1)
new iVictim = read_data(2)
new iHeadshot = read_data(3)
new Float: iDelay
if(iKiller == iVictim)
return PLUGIN_CONTINUE
if(zp_get_user_zombie(iVictim))
{
if(!iHeadshot)
{
iDelay = get_pcvar_float(zp_cso_cvar_delayrespawn)
set_task(iDelay,"zp_cso_zombie_respawner", iVictim)
zp_cso_respawnwait[iVictim] = get_pcvar_num(zp_cso_cvar_delayrespawn)
zp_zbrespawn(iVictim)
zp_zbrespawn_msg(iVictim)
}
else
{
zp_zbrespawn_msg2(iVictim)
}
}
return PLUGIN_CONTINUE
}
public zp_zbrespawn(iVictim)
{
if (zp_cso_roundstarted == 0 || !is_user_connected(iVictim) || is_user_alive(iVictim))
return PLUGIN_CONTINUE
zp_effect_respawn(iVictim)
set_task(2.0, "zp_zbrespawn", iVictim)
return PLUGIN_CONTINUE
}
public zp_zbrespawn_msg(iVictim)
{
if (zp_cso_roundstarted == 0 || !is_user_connected(iVictim))
return PLUGIN_CONTINUE
new iText[64]
format(iText, charsmax(iText), "%L", LANG_PLAYER, "ZP_CSO_ZOMBIERESPAWN_MSG", zp_cso_respawnwait[iVictim])
zp_clientcenter_text(iVictim, iText)
zp_cso_respawnwait[iVictim] -= 1
if(zp_cso_respawnwait[iVictim] >= 1)
{
set_task(1.0, "zp_zbrespawn_msg", iVictim)
}
return PLUGIN_CONTINUE
}
public zp_zbrespawn_msg2(iVictim)
{
if (zp_cso_roundstarted == 0 || !is_user_connected(iVictim) || is_user_alive(iVictim))
return PLUGIN_CONTINUE
new iText[64]
format(iText, charsmax(iText), "%L", LANG_PLAYER, "ZP_CSO_ZOMBIERESPAWN_MSG2")
zp_clientcenter_text(iVictim, iText)
return PLUGIN_CONTINUE
}
public zp_cso_auto_on(id)
{
set_task(1.0,"zp_cso_hud_score", id, _, _, "b")
}
public zp_cso_hud_score(id)
{
if(!is_user_alive(id))
return PLUGIN_CONTINUE
new iMsg[600], zp_hmnum, zp_zbnum, zp_roundnum
zp_hmnum = zp_get_human_count()
zp_zbnum = zp_get_zombie_count()
zp_roundnum = zp_cso_round
set_hudmessage( 0, 250, 0, -1.0, 0.0, 0, 6.0, 1.1, 0.0, 0.0, -1)
format(iMsg, charsmax(iMsg), "/ %L \^n( HM [ %L ] | %02i | [ %L %02i ] | %02i | [ %L ] ZB )^n\ | %02i | [ VS ] | %02i | /", LANG_PLAYER, "ZP_CSO_TITLE", LANG_PLAYER, "ZP_CSO_HUMANS", zp_cso_humanswins, LANG_PLAYER, "ZP_CSO_ROUNDS", zp_roundnum, zp_cso_zombieswins, LANG_PLAYER, "ZP_CSO_ZOMBIES", zp_hmnum, zp_zbnum)
ShowSyncHudMsg(id, zp_cso_hud_sync1, iMsg)
return PLUGIN_CONTINUE
}
zp_effect_respawn(iVictim)
{
static Float: zp_origin[3]
pev(iVictim, pev_origin, zp_origin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_EXPLOSION)
write_coord(floatround(zp_origin[0]))
write_coord(floatround(zp_origin[1]))
write_coord(floatround(zp_origin[2]))
write_short(zp_cso_respawnspr)
write_byte(10)
write_byte(20)
write_byte(14)
message_end()
}
public zp_cso_zombie_respawner(iVictim)
{
if(get_pcvar_num(zp_cso_cvar_enablerespawn) == 1)
{
new iSound, iSpeak[64]
ExecuteHamB(Ham_CS_RoundRespawn, iVictim)
iSound = random_num(0, charsmax(zp_cso_zombierespawn))
copy(iSpeak, charsmax(iSpeak), zp_cso_zombierespawn[iSound])
client_cmd(0, "speak ^"%s^"", iSpeak)
zp_infect_user(iVictim)
}
}
public zp_round_started()
{
zp_cso_roundstarted = 1
}
public zp_round_ended()
{
if(zp_get_human_count() == 0)
{
zp_cso_zombieswins += 1
}
else
{
zp_cso_humanswins += 1
}
zp_cso_roundstarted = 0
}
public client_putinserver(id)
{
zp_cso_auto_on(id)
}
stock zp_clientcenter_text(id, zp_message[])
{
new dest
if (id) dest = MSG_ONE
else dest = MSG_ALL
message_begin(dest, zp_center_textmsg, {0,0,0}, id)
write_byte(4)
write_string(zp_message)
message_end()
}