SourceMod 1.10 and new OnEntitySpawned forward

This commit is contained in:
BotoX
2019-09-10 16:34:12 +02:00
parent 4bb399c18d
commit ad2f7cd71a
26 changed files with 802 additions and 975 deletions
+31 -1
View File
@@ -1,5 +1,7 @@
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <zombiereloaded>
#pragma semicolon 1
#pragma newdecls required
@@ -12,6 +14,7 @@ bool g_bWarmup = false;
ConVar g_CVar_sm_warmuptime;
ConVar g_CVar_sm_warmupratio;
ConVar g_CVar_sm_warmupmaxtime;
bool g_bLateLoad = false;
bool g_bRoundEnded = false;
bool g_bZombieSpawned = false;
@@ -40,10 +43,31 @@ public void OnPluginStart()
g_CVar_sm_warmupmaxtime = CreateConVar("sm_warmupmaxtime", "45", "Max Warmup timer.", 0, true, 0.0, true, 120.0);
AutoExecConfig(true, "plugin.TeamManager");
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && IsPlayerAlive(i) && ZR_IsClientZombie(i))
{
g_bZombieSpawned = true;
break;
}
}
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
g_bLateLoad = late;
return APLRes_Success;
}
public void OnMapStart()
{
if(g_bLateLoad)
{
g_bLateLoad = false;
return;
}
g_iWarmup = 0;
g_iMaxWarmup = 0;
g_bWarmup = false;
@@ -106,6 +130,7 @@ public void OnClientDisconnect(int client)
public Action OnJoinTeamCommand(int client, const char[] command, int argc)
{
LogMessage("OnJoinTeamCommand(%L, %s, %d)", client, command, argc);
if(client < 1 || client >= MaxClients || !IsClientInGame(client))
return Plugin_Continue;
@@ -127,6 +152,10 @@ public Action OnJoinTeamCommand(int client, const char[] command, int argc)
if(NewTeam < CS_TEAM_NONE || NewTeam > CS_TEAM_CT)
return Plugin_Handled;
// prevent accidental suicide
if(g_bZombieSpawned && IsPlayerAlive(client) && NewTeam != CS_TEAM_SPECTATOR)
return Plugin_Handled;
if(g_bRoundEnded)
{
if(NewTeam == CS_TEAM_T || NewTeam == CS_TEAM_NONE)
@@ -155,9 +184,10 @@ public Action OnJoinTeamCommand(int client, const char[] command, int argc)
else if(NewTeam == CS_TEAM_CT || NewTeam == CS_TEAM_NONE)
NewTeam = CS_TEAM_T;
if(NewTeam == CurrentTeam)
if(g_bZombieSpawned && NewTeam == CurrentTeam)
return Plugin_Handled;
ChangeClientTeam(client, CS_TEAM_NONE);
ChangeClientTeam(client, NewTeam);
return Plugin_Handled;
}