I have been dealing with this problem since 2018 I have never been able to solve the JCTF Capture Flag respawn problem everyone knows problem neh ? when the player dies and goes to respawn, when 1 second is missing he changes or autoteambalance changes he is as if he were a spectator but he remains alive killing everyone someone please someone help me
PHP Code:
public player_spawn(id)
{
if(!is_user_alive(id) || (!g_bRestarted[id] && g_bAlive[id]))
return
/* make sure we have team right */
switch(cs_get_user_team(id))
{
case CS_TEAM_T: g_iTeam[id] = TEAM_RED
case CS_TEAM_CT: g_iTeam[id] = TEAM_BLUE
default: return
}
g_bAlive[id] = true
g_bDefuse[id] = false
g_bBuyZone[id] = true
g_bFreeLook[id] = false
g_fLastBuy[id] = Float:{0.0, 0.0, 0.0, 0.0}
task_remove(id - TASK_PROTECTION)
task_remove(id - TASK_EQUIPAMENT)
task_remove(id - TASK_DAMAGEPROTECTION)
task_remove(id - TASK_TEAMBALANCE)
task_remove(id - TASK_ADRENALINE)
task_remove(id - TASK_DEFUSE)
#if FEATURE_BUY == true
if(!Map_Check_Cam)
task_set(0.1, "player_spawnEquipament", id - TASK_EQUIPAMENT)
#endif // FEATURE_BUY
task_set(0.2, "player_checkVitals", id - TASK_CHECKHP)
#if FEATURE_ADRENALINE == true
player_hudAdrenaline(id)
#endif // FEATURE_ADRENALINE
new iProtection = get_pcvar_num(pCvar_ctf_protection)
if(iProtection > 0)
player_protection(id - TASK_PROTECTION, iProtection)
message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
write_byte(id)
write_byte(0)
message_end()
if(g_bFirstSpawn[id] || g_bRestarted[id])
{
g_bRestarted[id] = false
g_bFirstSpawn[id] = false
new iStartMoney = (is_user_admin(id) ? get_pcvar_num(pCvar_adm_startmoney) : get_pcvar_num(pCvar_mp_startmoney));
if (cs_get_user_money(id) < iStartMoney)
cs_set_user_money(id, clamp(iStartMoney, get_pcvar_num(pCvar_mp_startmoney), 16000));
}
else if(g_bSuicide[id])
{
g_bSuicide[id] = false
player_print(id, id, "%L", id, "SPAWN_NOMONEY")
}
else
{
new iMoney = cs_get_user_money(id), iStartMoney = (is_user_admin(id) ? get_pcvar_num(pCvar_adm_startmoney) : get_pcvar_num(pCvar_mp_startmoney));
if (iMoney < iStartMoney)
{
cs_set_user_money(id, min(iStartMoney, 16000));
}
else
{
cs_set_user_money(id, min(iMoney + get_pcvar_num(pCvar_ctf_spawnmoney), 16000));
}
// Oneliner
// cs_set_user_money(id, min((iMoney < iStartMoney ? iStartMoney : iMoney + get_pcvar_num(pCvar_ctf_spawnmoney)), 16000));
}
}
public player_joinTeam()
{
new id = read_data(1)
if(g_bAlive[id])
return
new szTeam[2];
read_data(2, szTeam, charsmax(szTeam))
switch(szTeam[0])
{
case 'T':
{
if(g_iTeam[id] == TEAM_RED && g_bFirstSpawn[id])
{
new iRespawn = get_pcvar_num(pCvar_ctf_respawntime)
if(iRespawn > 0)
player_respawn(id - TASK_RESPAWN, iRespawn + 1)
task_remove(id - TASK_TEAMBALANCE)
task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
}
g_iTeam[id] = TEAM_RED
}
case 'C':
{
if(g_iTeam[id] == TEAM_BLUE && g_bFirstSpawn[id])
{
new iRespawn = get_pcvar_num(pCvar_ctf_respawntime)
if(iRespawn > 0)
player_respawn(id - TASK_RESPAWN, iRespawn + 1)
task_remove(id - TASK_TEAMBALANCE)
task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
}
g_iTeam[id] = TEAM_BLUE
}
case 'U':
{
g_iTeam[id] = TEAM_NONE
g_bFirstSpawn[id] = true
}
default:
{
player_screenFade(id, {0,0,0,0}, 0.0, 0.0, FADE_OUT, false)
player_allowChangeTeam(id)
g_iTeam[id] = TEAM_SPEC
g_bFirstSpawn[id] = true
}
}
}