update Spectate
This commit is contained in:
parent
06518f1b0b
commit
dd024b6e5f
@ -1,10 +1,12 @@
|
||||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <cstrike>
|
||||
#include <zombiereloaded>
|
||||
#include "loghelper.inc"
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
@ -37,9 +39,15 @@ public void OnPluginStart()
|
||||
RegConsoleCmd("sm_spectate", Command_Spectate, "Spectate a player.");
|
||||
RegConsoleCmd("sm_spec", Command_Spectate, "Spectate a player.");
|
||||
|
||||
AddCommandListener(Command_SpectateViaConsole, "spectate");
|
||||
AddCommandListener(Command_GoTo, "spec_goto");
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
GetTeams();
|
||||
}
|
||||
|
||||
public void OnClientSettingsChanged(int client)
|
||||
{
|
||||
static char sSpecMode[8];
|
||||
@ -87,6 +95,9 @@ public Action Command_Spectate(int client, int argc)
|
||||
{
|
||||
if (GetClientTeam(client) != CS_TEAM_SPECTATOR)
|
||||
{
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamClientCount(CS_TEAM_T) > 0 && GetTeamAliveClientCount(CS_TEAM_T) > 0)
|
||||
LogPlayerEvent(client, "triggered", "switch_to_spec");
|
||||
|
||||
ForcePlayerSuicide(client);
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
}
|
||||
@ -109,6 +120,9 @@ public Action Command_Spectate(int client, int argc)
|
||||
|
||||
if (GetClientTeam(client) != CS_TEAM_SPECTATOR)
|
||||
{
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamClientCount(CS_TEAM_T) > 0 && GetTeamAliveClientCount(CS_TEAM_T) > 0)
|
||||
LogPlayerEvent(client, "triggered", "switch_to_spec");
|
||||
|
||||
ForcePlayerSuicide(client);
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
}
|
||||
@ -128,6 +142,14 @@ public Action Command_Spectate(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_SpectateViaConsole(int client, char[] command, int args)
|
||||
{
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamClientCount(CS_TEAM_T) > 0 && GetTeamAliveClientCount(CS_TEAM_T) > 0)
|
||||
LogPlayerEvent(client, "triggered", "switch_to_spec");
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
// Fix spec_goto crash exploit
|
||||
public Action Command_GoTo(int client, const char[] command, int argc)
|
||||
{
|
||||
@ -149,3 +171,21 @@ public Action Command_GoTo(int client, const char[] command, int argc)
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
stock int GetTeamAliveClientCount(int iTeam)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
for (int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if (!IsClientInGame(i) || GetClientTeam(i) != iTeam)
|
||||
continue;
|
||||
|
||||
if (!IsPlayerAlive(i))
|
||||
continue;
|
||||
|
||||
ret++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
1
Spectate/scripting/include/loghelper.inc
Symbolic link
1
Spectate/scripting/include/loghelper.inc
Symbolic link
@ -0,0 +1 @@
|
||||
../../../includes/loghelper.inc
|
Loading…
Reference in New Issue
Block a user