It happens when u switch to spectator.Spec player its respawned,i want to know how to fix that.
So i asked for ur help.
Here is the code
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>
#define PLUGIN "Respawn"
#define VERSION "1.0"
#define AUTHOR "#8 SickneSS"
/* pCvars */
new enable
new delay
new prefix
/* String */
new szPrefix[32]
/* Boolean */
new bool:respawn[33]
//====================[*REGISTRATIONS*]===========================//
public plugin_init()
{
/* Plugin Registration */
register_plugin(PLUGIN, VERSION, AUTHOR)
/* Ham Registrations */
RegisterHam(Ham_Spawn, "player", "Ham_Spawn_player", 1)
RegisterHam(Ham_Killed, "player", "Ham_Killed_player", 1)
/* pCvar */
enable = register_cvar("amx_respawn","1")
delay = register_cvar("amx_respawn_delay","3")
prefix = register_cvar("amx_prefix","[AMXX]")
/* String */
get_pcvar_string(prefix,szPrefix,31)
/* Commands */
register_clcmd("say /respawn","cmdRespawn")
register_clcmd("say_team /respawn","cmdRespawn")
}
//====================[*RESPAWN*]===========================//
public client_putinserver(id)
{
respawn[id] = false
}
//----------------------------------------------------------//
public cleint_disconnect(id)
{
respawn[id] = false
}
//----------------------------------------------------------//
public cmdRespawn(id)
{
if(get_pcvar_num(enable) == 1)
{
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
{
ColorChat(id,GREEN,"%s^x01 This command is disabled for spectators.",szPrefix)
}
if(cs_get_user_team(id) == CS_TEAM_T || cs_get_user_team(id) == CS_TEAM_CT)
{
respawn[id] = !respawn[id]
ColorChat(id, GREEN,"%s^x01 You have been %sable your respawn.",szPrefix,respawn[id] ? "en" : "dis")
if(!is_user_alive(id) || respawn[id])
{
set_task(get_pcvar_float(delay),"cmdRespawns",id)
}
}
}
return PLUGIN_HANDLED
}
//----------------------------------------------------------//
public Ham_Killed_player(id)
{
if(get_pcvar_num(enable) == 1)
{
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
{
respawn[id] = false
}
if(respawn[id])
{
ColorChat(id, GREEN,"%s^x01 You have respawn in^x03 %d^x01 seconds.",szPrefix,get_pcvar_num(delay))
ColorChat(id, GREEN,"%s^x01 To disable your respawn,type^x03 /respawn^x01.",szPrefix)
set_task(get_pcvar_float(delay),"cmdRespawns",id)
}
else
{
ColorChat(id, GREEN,"%s^x01 To enable your respawn,type^x03 /respawn^x01.",szPrefix)
return HAM_IGNORED
}
}
return HAM_IGNORED
}
//----------------------------------------------------------//
public Ham_Spawn_player(id)
{
if(is_user_alive(id))
remove_task(id)
}
//----------------------------------------------------------//
public cmdRespawns(id)
{
if(!is_user_alive(id))
ExecuteHamB(Ham_CS_RoundRespawn,id)
}
I leave u a demo with ilustration of the bug.
Sorry for my bad english,im from Argentina.