Spectate: adding forward
This commit is contained in:
parent
3db6438022
commit
e01da92b94
10
Spectate/include/Spectate.inc
Normal file
10
Spectate/include/Spectate.inc
Normal file
@ -0,0 +1,10 @@
|
||||
#if defined _Spectate_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _Spectate_included
|
||||
/**
|
||||
* Called when a client switches to spec by sm_spectate.
|
||||
*
|
||||
* @param client Client index of the caller.
|
||||
*/
|
||||
forward void OnPlayerSwitchedToSpectateByCommand(int client);
|
@ -8,6 +8,8 @@
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
Handle g_hFwd_SpectateByCommand;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Spectate",
|
||||
@ -41,6 +43,9 @@ public void OnPluginStart()
|
||||
|
||||
AddCommandListener(Command_SpectateViaConsole, "spectate");
|
||||
AddCommandListener(Command_GoTo, "spec_goto");
|
||||
AddCommandListener(Command_Kill, "kill");
|
||||
|
||||
g_hFwd_SpectateByCommand = CreateGlobalForward("OnPlayerSwitchedToSpectateByCommand", ET_Ignore, Param_Cell);
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
@ -95,9 +100,14 @@ 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)
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamClientCount(CS_TEAM_T) > 0 && GetTeamAliveClientCount(CS_TEAM_T) > 0 && GetTeamAliveClientCount(CS_TEAM_CT) > 0)
|
||||
{
|
||||
LogPlayerEvent(client, "triggered", "switch_to_spec");
|
||||
}
|
||||
|
||||
Call_StartForward(g_hFwd_SpectateByCommand);
|
||||
Call_PushCell(client);
|
||||
Call_Finish();
|
||||
ForcePlayerSuicide(client);
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
}
|
||||
@ -120,9 +130,12 @@ 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)
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamClientCount(CS_TEAM_T) > 0 && GetTeamAliveClientCount(CS_TEAM_T) > 0 && GetTeamAliveClientCount(CS_TEAM_CT) > 0)
|
||||
LogPlayerEvent(client, "triggered", "switch_to_spec");
|
||||
|
||||
Call_StartForward(g_hFwd_SpectateByCommand);
|
||||
Call_PushCell(client);
|
||||
Call_Finish();
|
||||
ForcePlayerSuicide(client);
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
}
|
||||
@ -150,6 +163,14 @@ public Action Command_SpectateViaConsole(int client, char[] command, int args)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
public Action Command_Kill(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)
|
||||
{
|
||||
@ -188,4 +209,4 @@ stock int GetTeamAliveClientCount(int iTeam)
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user