public SpawnPointCount()
{
new Target = -1
new TerrorEnts, CTEnts
new RequiredSpawnEnt
new bool:Found
new szData[256], PlayerTeam[32]
new Float:EntityOrigin[3], Float:EntityAngles[3]
new iFile = fopen(g_sEntFile, "a+")
if(!iFile)
return
while((Target = find_ent_by_class(Target, "info_player_deathmatch")))
{
if(pev_valid(Target))
{
TerrorEnts = TerrorEnts + 1
if(!Found)
{
pev(Target, pev_origin, EntityOrigin)
pev(Target, pev_angles, EntityAngles)
Found = true
}
}
}
if(TerrorEnts != g_iMaxSpawn)
{
if(TerrorEnts < g_iMaxSpawn)
{
RequiredSpawnEnt = g_iMaxSpawn - TerrorEnts
server_print("[Fail Spawn Protector] Required %d + Terro spawn ent!", RequiredSpawnEnt)
g_bServerReload = true
}
PlayerTeam = "T"
formatex(szData, charsmax(szData), "%s %d %d %.1f %.1f %.1f %.1f %.1f %.1f^n", PlayerTeam, 0, RequiredSpawnEnt, EntityOrigin[0], EntityOrigin[1], EntityOrigin[2], 0, EntityAngles[1], 0)
fputs(iFile, szData)
server_print("[Fail Spawn Protector] Auto reload TT")
}
Found = false
while((Target = find_ent_by_class(Target, "info_player_start")))
{
if(pev_valid(Target))
{
CTEnts = CTEnts + 1
if(!Found)
{
pev(Target, pev_origin, EntityOrigin)
pev(Target, pev_angles, EntityAngles)
Found = true
}
}
}
if(CTEnts != g_iMaxSpawn)
{
if(CTEnts < g_iMaxSpawn)
{
RequiredSpawnEnt = g_iMaxSpawn - CTEnts
server_print("Required %d + CT spawn ent!", RequiredSpawnEnt)
g_bServerReload = true
}
PlayerTeam = "CT"
formatex(szData, charsmax(szData), "%s %d %d %.1f %.1f %.1f %.1f %.1f %.1f^n", PlayerTeam, 0, RequiredSpawnEnt, EntityOrigin[0], EntityOrigin[1], EntityOrigin[2], 0, EntityAngles[1], 0)
fputs(iFile, szData)
server_print("[Fail Spawn Protector] Auto reload CT")
}
fclose(iFile)
g_iNowTerrorSpawnNum = TerrorEnts
g_iNowCTSpawnNum = CTEnts
server_print("[Fail Spawn Protector] CS Spawn Entity: %d || Terror Spawn Entity: %d", g_iNowCTSpawnNum, g_iNowTerrorSpawnNum)
if(g_bServerReload)
{
server_print("[Fail Spawn Protector] Server is reloading")
// Reload server?
set_task(0.5, "delay_restart")
}
}