Replace your zp50_deathmatch with this and try..
PHP Code:
/*================================================================================
-----------------------
-*- [ZP] Deathmatch -*-
-----------------------
This plugin is part of Zombie Plague Mod and is distributed under the
terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
================================================================================*/
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <cs_ham_bots_api>
#include <zp50_gamemodes>
#define TASK_RESPAWN 100
#define ID_RESPAWN (taskid - TASK_RESPAWN)
// Custom Forwards
enum _:TOTAL_FORWARDS
{
FW_USER_RESPAWN_PRE = 0
}
new g_Forwards[TOTAL_FORWARDS]
new g_ForwardResult
new g_MaxPlayers
new g_GameModeStarted
new cvar_deathmatch, cvar_respawn_delay
new cvar_respawn_zombies, cvar_respawn_humans
new cvar_respawn_on_suicide
new g_GameModeSwarmID, g_GameModeInfectionID, g_GameModeMultiID
public plugin_init()
{
register_plugin("[ZP] Deathmatch", ZP_VERSION_STRING, "ZP Dev Team")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
RegisterHamBots(Ham_Spawn, "fw_PlayerSpawn_Post", 1)
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled_Post", 1)
RegisterHamBots(Ham_Killed, "fw_PlayerKilled_Post", 1)
cvar_deathmatch = register_cvar("zp_deathmatch", "0")
cvar_respawn_delay = register_cvar("zp_respawn_delay", "5")
cvar_respawn_zombies = register_cvar("zp_respawn_zombies", "1")
cvar_respawn_humans = register_cvar("zp_respawn_humans", "1")
cvar_respawn_on_suicide = register_cvar("zp_respawn_on_suicide", "0")
g_MaxPlayers = get_maxplayers()
g_Forwards[FW_USER_RESPAWN_PRE] = CreateMultiForward("zp_fw_deathmatch_respawn_pre", ET_CONTINUE, FP_CELL)
}
public plugin_cfg()
{
g_GameModeSwarmID = zp_gamemodes_get_id("Swarm Mode")
g_GameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
g_GameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
}
// Ham Player Spawn Post Forward
public fw_PlayerSpawn_Post(id)
{
// Not alive or didn't join a team yet
if (!is_user_alive(id) || !cs_get_user_team(id))
return;
// Remove respawn task
remove_task(id+TASK_RESPAWN)
}
// Ham Player Killed Post Forward
public fw_PlayerKilled_Post(victim, attacker, shouldgib)
{
// Respawn if deathmatch is enabled
if (get_pcvar_num(cvar_deathmatch))
{
// Respawn on suicide?
if (!get_pcvar_num(cvar_respawn_on_suicide) && (victim == attacker || !is_user_connected(attacker)))
return;
// Respawn if human/zombie?
if ((zp_core_is_zombie(victim) && !get_pcvar_num(cvar_respawn_zombies)) || (!zp_core_is_zombie(victim) && !get_pcvar_num(cvar_respawn_humans)))
return;
if(zp_gamemodes_get_current() == g_GameModeInfectionID || zp_gamemodes_get_current() == g_GameModeMultiID || zp_gamemodes_get_current() == g_GameModeSwarmID)
{
// Set the respawn task
set_task(get_pcvar_float(cvar_respawn_delay), "respawn_player_task", victim+TASK_RESPAWN)
}
}
}
// Respawn Player Task (deathmatch)
public respawn_player_task(taskid)
{
// Already alive or round ended
if (is_user_alive(ID_RESPAWN) || zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
return;
// Get player's team
new CsTeams:team = cs_get_user_team(ID_RESPAWN)
// Player moved to spectators
if (team == CS_TEAM_SPECTATOR || team == CS_TEAM_UNASSIGNED)
return;
// Allow other plugins to decide whether player can respawn or not
ExecuteForward(g_Forwards[FW_USER_RESPAWN_PRE], g_ForwardResult, ID_RESPAWN)
if (g_ForwardResult >= PLUGIN_HANDLED)
return;
// Respawn as zombie?
if (get_pcvar_num(cvar_deathmatch) == 2 || (get_pcvar_num(cvar_deathmatch) == 3 && random_num(0, 1)) || (get_pcvar_num(cvar_deathmatch) == 4 && zp_core_get_zombie_count() < GetAliveCount()/2))
{
// Only allow respawning as zombie after a game mode started
if (g_GameModeStarted) zp_core_respawn_as_zombie(ID_RESPAWN, true)
}
respawn_player_manually(ID_RESPAWN)
}
// Respawn Player Manually (called after respawn checks are done)
respawn_player_manually(id)
{
// Respawn!
ExecuteHamB(Ham_CS_RoundRespawn, id)
}
public client_disconnect(id)
{
// Remove tasks on disconnect
remove_task(id+TASK_RESPAWN)
}
public zp_fw_gamemodes_start()
{
g_GameModeStarted = true
}
public zp_fw_gamemodes_end()
{
g_GameModeStarted = false
// Stop respawning after game mode ends
new id
for (id = 1; id <= g_MaxPlayers; id++)
remove_task(id+TASK_RESPAWN)
}
// Get Alive Count -returns alive players number-
GetAliveCount()
{
new iAlive, id
for (id = 1; id <= g_MaxPlayers; id++)
{
if (is_user_alive(id))
iAlive++
}
return iAlive;
}
or this (another plugin and disable zp normal respawn to work properly):
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <zp50_core>
#include <hamsandwich>
#include <cs_ham_bots_api>
#include <zp50_gamemodes>
#define PLUGIN "[ZP50] Addon: C.A.T Respawn System"
#define VERSION "1.1"
#define AUTHOR "Catastrophe"
new crs_starting_lives, crs_resp_delay
new lives[33]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_cvar("CAT_RESP","1",(FCVAR_SERVER|FCVAR_SPONLY))
register_event("HLTV", "event_newround", "a", "1=0", "2=0")
RegisterHam(Ham_Killed, "player", "fw_killed")
RegisterHamBots(Ham_Killed, "fw_killed")
crs_starting_lives = register_cvar("crs_starting_lives", "2")
crs_resp_delay = register_cvar("crs_resp_delay", "5.0")
}
public event_newround()
{
for(new i = 1; i < get_maxplayers(); i++)
{
if(is_user_connected(i))
{
lives[i] = -1
}
}
}
public zp_fw_core_cure_post(id, attacker)
{
lives[id] = -1
}
public zp_fw_core_infect_post(id, attacker)
{
if(zp_gamemodes_get_current() == zp_gamemodes_get_id("Nemesis Mode")
|| zp_gamemodes_get_current() == zp_gamemodes_get_id("Survivor Mode")
|| zp_gamemodes_get_current() == zp_gamemodes_get_id("Plague Mode")
|| zp_gamemodes_get_current() == zp_gamemodes_get_id("Armageddon Mode"))
return;
if(lives[id] == -1)
{
lives[attacker] += get_pcvar_num(crs_starting_lives)
}
}
public fw_killed(victim, attacker, shouldgib)
{
if (is_user_connected(victim) && lives[victim] > 0 && zp_core_is_zombie(victim))
{
lives[victim] -= 1
set_task(get_pcvar_float(crs_resp_delay), "respawn", victim)
}
}
public respawn(id)
{
if(zp_gamemodes_get_current() == zp_gamemodes_get_id("Nemesis Mode")
|| zp_gamemodes_get_current() == zp_gamemodes_get_id("Survivor Mode")
|| zp_gamemodes_get_current() == zp_gamemodes_get_id("Plague Mode")
|| zp_gamemodes_get_current() == zp_gamemodes_get_id("Armageddon Mode"))
return;
if(is_user_connected(id))
{
if(get_user_team(id) == 0 || get_user_team(id) == 3)
return;
zp_core_respawn_as_zombie(id, true)
ExecuteHamB(Ham_CS_RoundRespawn, id)
}
}