Spectate: Add weapon strip code.
Possibly weapons stick around, causing stupid 'exploits'.
This commit is contained in:
parent
b66a9f51b5
commit
0c4fa9bc67
@ -41,9 +41,9 @@ 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");
|
||||
AddCommandListener(Command_Kill, "kill");
|
||||
AddCommandListener(Command_Suicide, "spectate");
|
||||
AddCommandListener(Command_Suicide, "kill");
|
||||
AddCommandListener(Command_Goto, "spec_goto");
|
||||
|
||||
g_hFwd_SpectateByCommand = CreateGlobalForward("OnPlayerSwitchedToSpectateByCommand", ET_Ignore, Param_Cell);
|
||||
}
|
||||
@ -100,14 +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 && GetTeamAliveClientCount(CS_TEAM_CT) > 0)
|
||||
{
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0)
|
||||
LogPlayerEvent(client, "triggered", "switch_to_spec");
|
||||
}
|
||||
|
||||
Call_StartForward(g_hFwd_SpectateByCommand);
|
||||
Call_PushCell(client);
|
||||
Call_Finish();
|
||||
|
||||
StripPlayerWeapons(client);
|
||||
ForcePlayerSuicide(client);
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
}
|
||||
@ -130,12 +130,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 && GetTeamAliveClientCount(CS_TEAM_CT) > 0)
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && GetTeamAliveClientCount(CS_TEAM_T) > 0)
|
||||
LogPlayerEvent(client, "triggered", "switch_to_spec");
|
||||
|
||||
Call_StartForward(g_hFwd_SpectateByCommand);
|
||||
Call_PushCell(client);
|
||||
Call_Finish();
|
||||
|
||||
StripPlayerWeapons(client);
|
||||
ForcePlayerSuicide(client);
|
||||
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
|
||||
}
|
||||
@ -143,11 +145,12 @@ public Action Command_Spectate(int client, int argc)
|
||||
SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", iTarget);
|
||||
|
||||
Obs_Mode iObserverMode = view_as<Obs_Mode>(GetEntProp(client, Prop_Send, "m_iObserverMode"));
|
||||
|
||||
// If the client is currently in free roaming then switch them to first person view
|
||||
if (iObserverMode == OBS_MODE_ROAMING)
|
||||
{
|
||||
ClientCommand(client, "cl_spec_mode %d", OBS_MODE_IN_EYE);
|
||||
SetEntProp(client, Prop_Send, "m_iObserverMode", OBS_MODE_IN_EYE);
|
||||
ClientCommand(client, "cl_spec_mode %d", OBS_MODE_ROAMING);
|
||||
}
|
||||
|
||||
PrintToChat(client, "\x01[SM] Spectating \x04%N\x01.", iTarget);
|
||||
@ -155,24 +158,16 @@ public Action Command_Spectate(int client, int argc)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_SpectateViaConsole(int client, char[] command, int args)
|
||||
public Action Command_Suicide(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;
|
||||
}
|
||||
|
||||
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)
|
||||
if ((IsPlayerAlive(client) && ZR_IsClientHuman(client)) && 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)
|
||||
public Action Command_Goto(int client, const char[] command, int argc)
|
||||
{
|
||||
if(argc == 5)
|
||||
{
|
||||
@ -210,3 +205,20 @@ stock int GetTeamAliveClientCount(int iTeam)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
stock void StripPlayerWeapons(int client)
|
||||
{
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
int w = -1;
|
||||
|
||||
while ((w = GetPlayerWeaponSlot(client, i)) != -1)
|
||||
{
|
||||
if(IsValidEntity(w) && IsValidEdict(w))
|
||||
{
|
||||
RemovePlayerItem(client, w);
|
||||
AcceptEntityInput(w, "Kill");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user