Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sdktools>
- #include <sdkhooks>
- #include <sourcemod>
- #include <geoip>
- #define PLUGIN_VERSION "1.4e2 css:go"
- #define PLAYER_MANAGER "cs_player_manager"
- #define STEALTHTEAM 1
- #define QUIT_MESSAGE_CSGO "Gracz %N opuścił grę (Disconnect)"
- #define PREFIX "\x01\x0B \x02[cs-placzabaw.pl]\x01"
- #define EF_BONEMERGE (1 << 0)
- #define EF_NOSHADOW (1 << 4)
- #define EF_NORECEIVESHADOW (1 << 6)
- #define PLUGIN_NAME "ESP & STEALTH"
- #define HEADSCALE 1.0
- #define HEADPROP "models/player/holiday/facemasks/facemask_tf2_spy_model.mdl"
- #define HEADATTACH "facemask"
- #define NORMATTACH "primary"
- ConVar cColor[2];
- ConVar cLifeState;
- ConVar cNotify;
- ConVar cTeam;
- ConVar cModel;
- ConVar sv_force_transmit_players;
- bool isUsingESP[MAXPLAYERS+1];
- bool canSeeESP[MAXPLAYERS+1];
- bool:g_bIsInvisible[MAXPLAYERS + 1] = {false, ...};
- int colors[2][4]
- int playersInESP = 0;
- int playerModels[MAXPLAYERS+1] = {INVALID_ENT_REFERENCE,...};
- int playerModelsIndex[MAXPLAYERS+1] = {-1,...};
- int playerTeam[MAXPLAYERS+1] = {0,...};
- int g_iOldTeam[MAXPLAYERS+1];
- int serverVer;
- new Float:nextPing[MAXPLAYERS+1];
- Handle:g_hHostname;
- public Plugin myinfo = {
- name = PLUGIN_NAME,
- author = "Mitch / necavi and Naydef / edit+merge = SUPER TIMOR",
- description = "Allow admins to use a server side ESP/WH + set admin invisibility when going /stealth.",
- version = PLUGIN_VERSION,
- url = "mtch.tech / sourcemod.net / cs-placzabaw.pl"
- };
- public OnPluginStart() {
- sv_force_transmit_players = FindConVar("sv_force_transmit_players");
- CreateConVar("sm_advanced_esp_version", PLUGIN_VERSION, PLUGIN_NAME, FCVAR_NOTIFY|FCVAR_DONTRECORD);
- cColor[0] = CreateConVar("sm_advanced_esp_tcolor", "144 120 72", "R G B ze spacjami dla TT", 0);
- cColor[1] = CreateConVar("sm_advanced_esp_ctcolor", "72 96 144", "R G B ze spacjami dla CT", 0);
- cLifeState = CreateConVar("sm_advanced_esp_lifestate", "0", "Set to 1 if admins should only see esp when dead, 2 to only see esp while alive, 0 dead or alive.", 0);
- cNotify = CreateConVar("sm_advanced_esp_notify", "0", "Set to 1 if giving and setting esp should notify the rest of the server.", 0);
- cTeam = CreateConVar("sm_advanced_esp_team", "0", "0 - Display all teams, 1 - Display enemy, 2 - Display teammates", 0);
- cModel = CreateConVar("sm_advanced_esp_model", "0", "0 - Use current model (full body glow), 1 - Use facemask model on head", 0);
- CreateConVar("sm_adminstealth_version", PLUGIN_VERSION, "Admin-Stealth version cvar", FCVAR_NOTIFY|FCVAR_SPONLY|FCVAR_DONTRECORD);
- RegAdminCmd("sm_stealth", Command_Stealth, ADMFLAG_KICK, "ON/OFF STEALTH");
- AutoExecConfig(true, "csgo_advanced_esp");
- cColor[0].AddChangeHook(ConVarChange);
- cColor[1].AddChangeHook(ConVarChange);
- cLifeState.AddChangeHook(ConVarChange);
- cTeam.AddChangeHook(ConVarChange);
- cModel.AddChangeHook(ConVarChange);
- for(int i = 0; i <= 1; i++)
- {
- retrieveColorValue(i);
- }
- LoadTranslations("common.phrases");
- LoadTranslations("esp.phrases");
- HookEvent("player_spawn", Event_PlayerSpawn);
- HookEvent("player_death", Event_PlayerDeath);
- HookEvent("round_end", Event_RoundEnd);
- AddCommandListener(Command_JoinTeam, "jointeam");
- AddCommandListener(Command_JoinTeam, "autoteam");
- AddCommandListener(Command_Status, "status");
- AddCommandListener(Command_Ping, "ping");
- g_hHostname = FindConVar("hostname");
- serverVer=GetSteamINFNum();
- HookEventEx("player_disconnect", Event_HandleStealthAdmins, EventHookMode_Pre);
- HookEventEx("player_team", Event_HandleStealthAdmins, EventHookMode_Pre);
- HookEvent("player_team", Event_PlayerTeam, EventHookMode_Post);
- playersInESP = 0;
- for(new i=1; i<=MaxClients; i++)
- {
- if(ValidPlayer(i))
- {
- SDKHook(i, SDKHook_SetTransmit, Hook_Transmit);
- SDKHook(i, SDKHook_WeaponCanUse, Event_WeaponCanUse);
- }
- }
- new PlayerManager=FindEntityByClassname(-1, PLAYER_MANAGER);
- if(IsValidEntity(PlayerManager))
- {
- SDKHook(PlayerManager, SDKHook_ThinkPost, Hook_PlayerManagetThinkPost);
- }
- }
- public OnClientPostAdminCheck(client)
- {
- SDKHook(client, SDKHook_SetTransmit, Hook_Transmit);
- SDKHook(client, SDKHook_WeaponCanUse, Event_WeaponCanUse);
- }
- public Action Command_JoinTeam(int client, char[] command, int args)
- {
- char sTeamName[8];
- GetCmdArg(1, sTeamName, sizeof(sTeamName)) ;
- int iTeam = StringToInt(sTeamName);
- if (iTeam == 1 && (GetUserFlagBits(client) & ADMFLAG_KICK) && !g_bIsInvisible[client])
- toggleGlow(client, true);
- else if (iTeam != 1 && (GetUserFlagBits(client) & ADMFLAG_KICK) && !g_bIsInvisible[client])
- toggleGlow(client, false);
- if(g_bIsInvisible[client])
- {
- PrintToChat(client, "%s Nie ma powrotu! Disconnectuj :)", PREFIX);
- return Plugin_Handled;
- }
- else
- return Plugin_Continue;
- }
- public void ConVarChange(ConVar convar, const char[] oldValue, const char[] newValue) {
- for(int i = 0; i <= 1; i++) {
- if(convar == cColor[i]) {
- retrieveColorValue(i);
- }
- }
- checkGlows();
- }
- public void retrieveColorValue(int index) {
- char pieces[4][16];
- char color[64];
- cColor[index].GetString(color, sizeof(color));
- if(ExplodeString(color, " ", pieces, sizeof(pieces), sizeof(pieces[])) >= 3) {
- for(int j = 0; j < 3; j++) {
- colors[index][j] = StringToInt(pieces[j]);
- }
- }
- }
- public Action Command_ESP(client, args) {
- if(!client || !IsClientInGame(client)) {
- return Plugin_Handled;
- }
- bool value = false;
- if(args > 0) {
- char arg1[32];
- GetCmdArg(1, arg1, sizeof(arg1));
- toggleGlow(client, (StringToInt(arg1) != 0));
- } else {
- toggleGlow(client, !isUsingESP[client]);
- }
- char targetName[64];
- GetClientName(client, targetName, sizeof(targetName));
- notifyServer(client, targetName, (args > 1) ? (value ? 1 : 0) : 2);
- return Plugin_Handled;
- }
- public void notifyServer(int client, char[] targetName, int status) {
- if(cNotify.BoolValue) {
- switch(status) {
- case 0: ShowActivity(client, "%t", "ESP Off", targetName);
- case 1: ShowActivity(client, "%t", "ESP On", targetName);
- default: ShowActivity(client, "%t", "ESP Toggle", targetName);
- }
- }
- }
- public OnPluginEnd() {
- destoryGlows();
- }
- public void OnMapStart() {
- PrecacheModel(HEADPROP);
- resetPlayerVars(0);
- }
- public void OnClientDisconnect(int client) {
- resetPlayerVars(client);
- SDKUnhook(client, SDKHook_WeaponCanUse, Event_WeaponCanUse);
- SDKUnhook(client, SDKHook_SetTransmit, Hook_Transmit);
- g_bIsInvisible[client]=false;
- }
- public void OnClientPutInServer(int client) {
- resetPlayerVars(client);
- }
- public void Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast) {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if(client <= 0 || client > MaxClients || !IsClientInGame(client)) {
- return;
- }
- playerTeam[client] = GetClientTeam(client);
- if(g_bIsInvisible[client])
- {
- ChangeClientTeam(client, STEALTHTEAM);
- }
- }
- public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if(client <= 0 || client > MaxClients || !IsClientInGame(client))
- {
- return;
- }
- checkGlows();
- }
- public void Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
- {
- checkGlows();
- }
- public void Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
- {
- destoryGlows();
- }
- public void toggleGlow(int client, bool value)
- {
- isUsingESP[client] = value;
- checkGlows();
- }
- public void resetPlayerVars(int client) {
- if(client == 0) {
- for(int i = 1; i <= MaxClients; i++) {
- resetPlayerVars(i);
- }
- return;
- }
- isUsingESP[client] = false;
- playerTeam[client] = 0;
- g_bIsInvisible[client] = false;
- if(IsClientInGame(client)) {
- playerTeam[client] = GetClientTeam(client);
- }
- }
- public bool getCanSeeEsp(int client, int lifestate) {
- switch(lifestate) {
- case 1: return !IsPlayerAlive(client);
- case 2: return IsPlayerAlive(client);
- }
- return true;
- }
- public void checkGlows() {
- playersInESP = 0;
- int lifestate = cLifeState.IntValue;
- for(int client = 1; client <= MaxClients; client++) {
- if(!IsClientInGame(client) || !isUsingESP[client]) {
- isUsingESP[client] = false;
- canSeeESP[client] = false;
- continue;
- }
- canSeeESP[client] = getCanSeeEsp(client, lifestate);
- if(canSeeESP[client]) {
- playersInESP++;
- }
- }
- destoryGlows();
- if(playersInESP > 0) {
- sv_force_transmit_players.SetString("1", true, false);
- createGlows();
- } else {
- sv_force_transmit_players.SetString("0", true, false);
- }
- }
- public void destoryGlows() {
- for(int client = 1; client <= MaxClients; client++) {
- if(IsClientInGame(client)) {
- RemoveSkin(client);
- }
- }
- }
- public void createGlows() {
- char model[PLATFORM_MAX_PATH];
- char attachment[PLATFORM_MAX_PATH];
- int skin = -1;
- float scale = 1.0;
- attachment = NORMATTACH;
- for(int client = 1; client <= MaxClients; client++)
- {
- if(!IsClientInGame(client) || !IsPlayerAlive(client))
- continue;
- playerTeam[client] = GetClientTeam(client);
- if(playerTeam[client] <= 1)
- continue;
- GetClientModel(client, model, sizeof(model));
- skin = CreatePlayerModelProp(client, model, attachment, true, scale);
- if(skin > MaxClients)
- {
- playerTeam[client] = GetClientTeam(client);
- if(SDKHookEx(skin, SDKHook_SetTransmit, OnSetTransmit_All))
- setGlowTeam(skin, playerTeam[client]);
- }
- }
- }
- public setGlowTeam(int skin, int team) {
- if(team >= 2) {
- SetupGlow(skin, colors[team-2]);
- }
- }
- public Action OnSetTransmit_All(int entity, int client) {
- if(canSeeESP[client] && playerModelsIndex[client] != entity) {
- return Plugin_Continue;
- }
- return Plugin_Stop;
- }
- public void SetupGlow(int entity, int color[4]) {
- static offset;
- if (!offset && (offset = GetEntSendPropOffs(entity, "m_clrGlow")) == -1) {
- LogError("Unable to find property offset: \"m_clrGlow\"!");
- return;
- }
- SetEntProp(entity, Prop_Send, "m_bShouldGlow", true);
- SetEntProp(entity, Prop_Send, "m_nGlowStyle", 0);
- SetEntPropFloat(entity, Prop_Send, "m_flGlowMaxDist", 10000.0);
- for(int i=0;i<3;i++) {
- SetEntData(entity, offset + i, color[i], _, true);
- }
- }
- public int CreatePlayerModelProp(int client, char[] sModel, char[] attachment, bool bonemerge, float scale) {
- RemoveSkin(client);
- int skin = CreateEntityByName("prop_dynamic_glow");
- DispatchKeyValue(skin, "model", sModel);
- DispatchKeyValue(skin, "solid", "0");
- DispatchKeyValue(skin, "fademindist", "1");
- DispatchKeyValue(skin, "fademaxdist", "1");
- DispatchKeyValue(skin, "fadescale", "2.0");
- SetEntProp(skin, Prop_Send, "m_CollisionGroup", 0);
- DispatchSpawn(skin);
- SetEntityRenderMode(skin, RENDER_GLOW);
- SetEntityRenderColor(skin, 0, 0, 0, 0);
- if(bonemerge) {
- SetEntProp(skin, Prop_Send, "m_fEffects", EF_BONEMERGE);
- }
- if(scale != 1.0) {
- SetEntPropFloat(skin, Prop_Send, "m_flModelScale", scale);
- }
- SetVariantString("!activator");
- AcceptEntityInput(skin, "SetParent", client, skin);
- SetVariantString(attachment);
- AcceptEntityInput(skin, "SetParentAttachment", skin, skin, 0);
- SetVariantString("OnUser1 !self:Kill::0.1:-1");
- AcceptEntityInput(skin, "AddOutput");
- playerModels[client] = EntIndexToEntRef(skin);
- playerModelsIndex[client] = skin;
- return skin;
- }
- public void RemoveSkin(int client) {
- int index = EntRefToEntIndex(playerModels[client]);
- if(index > MaxClients && IsValidEntity(index)) {
- SetEntProp(index, Prop_Send, "m_bShouldGlow", false);
- AcceptEntityInput(index, "FireUser1");
- }
- playerModels[client] = INVALID_ENT_REFERENCE;
- playerModelsIndex[client] = -1;
- }
- public bool IsValidClient(int client) {
- return (1 <= client && client <= MaxClients && IsClientInGame(client));
- }
- public OnEntityCreated(entity, const String:classname[])
- {
- if(StrEqual(classname, PLAYER_MANAGER, false))
- {
- SDKHook(entity, SDKHook_SpawnPost, Hook_SpawnPost);
- }
- }
- public Action:Hook_SpawnPost(entity)
- {
- if(IsValidEntity(entity))
- {
- SDKHook(entity, SDKHook_ThinkPost, Hook_PlayerManagetThinkPost);
- }
- return Plugin_Continue;
- }
- public Hook_PlayerManagetThinkPost(entity)
- {
- for(new i=1; i<=MaxClients; i++)
- {
- if(ValidPlayer(i) && g_bIsInvisible[i])
- {
- SetEntProp(entity, Prop_Send, "m_bConnected", false, _, i);
- }
- }
- }
- public Action:Event_HandleStealthAdmins(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client=GetClientOfUserId(GetEventInt(event, "userid"));
- if(ValidPlayer(client) && g_bIsInvisible[client]) return Plugin_Handled;
- return Plugin_Continue;
- }
- public Action:Event_WeaponCanUse(client, weapon)
- {
- if(g_bIsInvisible[client])
- {
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public Action:Command_Status(client, const String:command[], args)
- {
- if(CheckCommandAccess(client, "sm_stealth", 0))
- {
- return Plugin_Continue;
- }
- new String:buffer[64];
- GetConVarString(g_hHostname, buffer, sizeof(buffer));
- PrintToConsole(client, "hostname: %s", buffer);
- PrintToConsole(client, "version : %i/24 %i secure", serverVer, serverVer);
- GetCurrentMap(buffer, sizeof(buffer));
- new Float:vec[3];
- GetClientAbsOrigin(client, vec);
- PrintToConsole(client,"map : %s", buffer);
- PrintToConsole(client,"players : %d (%d max)", GetClientCount() - GetInvisCount(), MaxClients);
- PrintToConsole(client,"# userid name uniqueid connected ping loss state");
- new String:name[MAX_NAME_LENGTH];
- new String:steamID[21];
- new String:time[10];
- for(new i; i <= MaxClients; i++)
- {
- if(ValidPlayer(i))
- {
- if(!g_bIsInvisible[i])
- {
- Format(name, sizeof(name), "%N", i);
- GetClientAuthId(i, AuthId_Steam2, steamID, sizeof(steamID));
- if(!IsFakeClient(i))
- {
- FormatShortTime(RoundToFloor(GetClientTime(i)), time,sizeof(time));
- PrintToConsole(client,"# %6d %-19s %19s %9s %4d %4d active", GetClientUserId(i),
- name, steamID, time, RoundToFloor(GetClientAvgLatency(i,NetFlow_Both) * 1000.0),
- RoundToFloor(GetClientAvgLoss(i, NetFlow_Both) * 100.0));
- }
- else
- {
- PrintToConsole(client, "# %6d %-19s %19s active", GetClientUserId(i), name, steamID);
- }
- }
- }
- }
- PrintToConsole(client, "#end");
- return Plugin_Stop;
- }
- public Action:Command_Ping(client, const String:command[], args)
- {
- if(!ValidPlayer(client) || CheckCommandAccess(client, "sm_stealth", 0)) // Console will now work!!!
- {
- return Plugin_Continue;
- }
- if(nextPing[client]<=GetGameTime())
- {
- PrintToConsole(client, "Client ping times:");
- for(new i=1; i<=MaxClients; i++)
- {
- if(ValidPlayer(i) && !g_bIsInvisible[i] && !IsFakeClient(i))
- {
- PrintToConsole(client, " %i ms : %N", RoundToFloor(GetClientAvgLatency(i, NetFlow_Both) * 1000.0), i);
- }
- }
- nextPing[client]=GetGameTime()+0.2;
- }
- return Plugin_Handled;
- }
- public Action:Hook_Transmit(entity, client)
- {
- if(ValidPlayer(entity) && g_bIsInvisible[entity] && entity != client)
- {
- return Plugin_Handled;
- }
- return Plugin_Continue;
- }
- public Action:Command_Stealth(client, args)
- {
- ToggleInvis(client);
- return Plugin_Handled;
- }
- ToggleInvis(client)
- {
- if(!g_bIsInvisible[client])
- {
- InvisOn(client);
- }
- else
- {
- PrintToChat(client, "%s Prosiliśmy! Nie wracaj tylko disconnectuj!", PREFIX);
- }
- }
- InvisOn(client)
- {
- CreateTimer(0.1, zmiana_bool, client);
- g_iOldTeam[client] = GetEntProp(client, Prop_Send, "m_iTeamNum");
- SetEntProp(client, Prop_Send, "m_lifeState", 2);
- ChangeClientTeam(client, STEALTHTEAM);
- SetEntProp(client, Prop_Data, "m_takedamage", 0);
- SetEntityMoveType(client, MOVETYPE_NOCLIP);
- RemoveAllWeapons(client);
- PrintConDisMessg(client, false);
- toggleGlow(client, true);
- PrintToChat(client, "%s Jesteś na stealthu! Obserwuj grę, ale komendy wpisuj w konsoli albo z /. Jak skończysz - wyjdź z serwera!", PREFIX);
- }
- public Action:zmiana_bool(Handle timer, any client)
- {
- if(!IsClientInGame(client))
- return Plugin_Continue;
- g_bIsInvisible[client] = true;
- return Plugin_Continue;
- }
- RemoveAllWeapons(client)
- {
- new weaponIndex;
- for (new i = 0; i <= 5; i++)
- {
- while((weaponIndex = GetPlayerWeaponSlot(client, i)) != -1)
- {
- RemovePlayerItem(client, weaponIndex);
- RemoveEdict(weaponIndex);
- }
- }
- }
- bool:ValidPlayer(client)
- {
- if(client > 0 && client <= MaxClients && IsClientInGame(client))
- {
- return true;
- }
- return false;
- }
- public bool:IsStealthed(client) // In case some plugin wants to make a call to the plugin via reflection!
- {
- return g_bIsInvisible[client];
- }
- FormatShortTime(time, String:outTime[], size)
- {
- new temp;
- temp = time % 60;
- Format(outTime, size,"%02d",temp);
- temp = (time % 3600) / 60;
- Format(outTime, size,"%02d:%s", temp, outTime);
- temp = (time % 86400) / 3600;
- if(temp > 0)
- {
- Format(outTime, size, "%d%:s", temp, outTime);
- }
- }
- GetInvisCount()
- {
- new count = 0;
- for(new i; i <= MaxClients; i++)
- {
- if(ValidPlayer(i) && g_bIsInvisible[i])
- {
- count++;
- }
- }
- return count;
- }
- //To-do: Use the new fake event function in Sourcemod 1.8
- bool:PrintConDisMessg(client, bool:connect)
- {
- if(!ValidPlayer(client))
- {
- return false;
- }
- if(!connect)
- {
- PrintToChatAll(QUIT_MESSAGE_CSGO, client);
- }
- return true;
- }
- stock GetSteamINFNum(String:search[]="ServerVersion")
- {
- new String:file[16]="./steam.inf", String:inf_buffer[64];
- new Handle:file_h=OpenFile(file, "r");
- do
- {
- if(!ReadFileLine(file_h, inf_buffer, sizeof(inf_buffer)))
- {
- return -1;
- }
- TrimString(inf_buffer);
- }
- while(StrContains(inf_buffer, search, false) < 0);
- CloseHandle(file_h);
- return StringToInt(inf_buffer[strlen(search)+1]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement