Veteran Member
Join Date: Aug 2016
Location: Italy
|
05-08-2017
, 04:51
Re: [CS:GO/CS:S] Simple Stealth v1
|
#13
|
Quote:
Originally Posted by Chrahb
Now using on all my servers
The only problem now is i have !admins,
to see online admins.
The one i'm using is: Admin List 1.2 by Fredd,
is there a way to hide admins from that?
|
I've done I version with an API
Plugin:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <simplestealth>
#pragma semicolon 1
#pragma newdecls required
bool g_bHideMe[MAXPLAYERS+1] = {false,...};
int g_iPlayerManager;
int g_iConnectedOffset;
int g_iAliveOffset;
int g_iTeamOffset;
int g_iPingOffset;
int g_iScoreOffset;
int g_iDeathsOffset;
int g_iHealthOffset;
public Plugin myinfo =
{
name = "Simple Stealth",
author = "Potatoz | Edit by Hexah",
description = "",
version = "1.1",
url = "http://sourcemod.net"
}
ConVar sm_stealth_autoswitch = null;
ConVar sm_stealth_disable_switch = null;
public void OnPluginStart()
{
HookEvent("player_team", Event_OnPlayerTeam, EventHookMode_Pre);
RegAdminCmd("sm_stealth", Command_StealthMode, ADMFLAG_BAN);
sm_stealth_autoswitch = CreateConVar("sm_stealth_autoswitch", "1", "Automatically switch admins to spectators on Stealth?");
sm_stealth_disable_switch = CreateConVar("sm_stealth_disable_switch", "1", "Disable Stealth Mode on switch to other team? (If autoswitch is enabled)");
AutoExecConfig(true, "simple_stealth");
g_iConnectedOffset = FindSendPropInfo("CCSPlayerResource", "m_bConnected");
g_iAliveOffset = FindSendPropInfo("CCSPlayerResource", "m_bAlive");
g_iTeamOffset = FindSendPropInfo("CCSPlayerResource", "m_iTeam");
g_iPingOffset = FindSendPropInfo("CCSPlayerResource", "m_iPing");
g_iScoreOffset = FindSendPropInfo("CCSPlayerResource", "m_iScore");
g_iDeathsOffset = FindSendPropInfo("CCSPlayerResource", "m_iDeaths");
g_iHealthOffset = FindSendPropInfo("CCSPlayerResource", "m_iHealth");
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
CreateNative("IsClientStealth", Native_IsClientStealth);
RegPluginLibrary("simplestealth");
return APLRes_Success;
}
public void OnMapStart()
{
g_iPlayerManager = FindEntityByClassname(-1, "cs_player_manager");
if(g_iPlayerManager != -1)
{
SDKHook(g_iPlayerManager, SDKHook_ThinkPost, Hook_PMThink);
}
}
public void OnClientDisconnect(int client)
{
g_bHideMe[client] = false;
}
public Action Command_StealthMode(int client, int args)
{
if(!client)
return Plugin_Handled;
if(!g_bHideMe[client])
{
g_bHideMe[client] = true;
if(GetClientTeam(client) != CS_TEAM_SPECTATOR && GetConVarInt(sm_stealth_autoswitch) == 1)
{
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
}
SDKHook(client, SDKHook_SetTransmit, Hook_Transmit);
}
else
{
g_bHideMe[client] = false;
SDKUnhook(client, SDKHook_SetTransmit, Hook_Transmit);
}
return Plugin_Continue;
}
public Action Hook_Transmit(int entity, int client)
{
if (entity != client)
return Plugin_Handled;
return Plugin_Continue;
}
public Action Event_OnPlayerTeam(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(g_bHideMe[client])
{
if(g_bHideMe[client] && GetConVarInt(sm_stealth_disable_switch) == 1 && GetConVarInt(sm_stealth_autoswitch) == 1 && GetClientTeam(client) == CS_TEAM_SPECTATOR)
g_bHideMe[client] = false;
SDKUnhook(client, SDKHook_SetTransmit, Hook_Transmit);
SetEventBroadcast(event, true);
return Plugin_Changed;
}
return Plugin_Continue;
}
public void Hook_PMThink(int entity)
{
for(int i=1;i<=MaxClients;i++)
{
if(IsClientInGame(i) && g_bHideMe[i])
{
SetEntData(g_iPlayerManager, g_iAliveOffset + (i * 4), false, 4, true);
SetEntData(g_iPlayerManager, g_iConnectedOffset + (i * 4), false, 4, true);
SetEntData(g_iPlayerManager, g_iTeamOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iPingOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iScoreOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iDeathsOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iHealthOffset + (i * 4), 0, 4, true);
}
}
}
public void OnGameFrame()
{
for(int i=1;i<=MaxClients;i++)
{
if(IsClientInGame(i) && g_bHideMe[i])
{
SetEntData(g_iPlayerManager, g_iAliveOffset + (i * 4), false, 4, true);
SetEntData(g_iPlayerManager, g_iConnectedOffset + (i * 4), false, 4, true);
SetEntData(g_iPlayerManager, g_iTeamOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iPingOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iScoreOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iDeathsOffset + (i * 4), 0, 4, true);
SetEntData(g_iPlayerManager, g_iHealthOffset + (i * 4), 0, 4, true);
}
}
}
public int Native_IsClientStealth(Handle plugin, int argc)
{
int client = GetNativeCell(1);
if (g_bHideMe[client])
{
return true;
}
return false;
}
Include file:
PHP Code:
#if defined _simplestealth_included_
#endinput
#endif
#define _simplestealth_included_
/**
* Check if a client is in stealth mode
*
*
* @param client Client Index.
* @return True if is in stealth mode, false otherwise.
* @error Client is not in game.
*/
native bool IsClientStealth(int client);
I didn't tested it but it should work.
__________________
|
|