From a4ddf38215c10876989725ab6d1959848f5fda78 Mon Sep 17 00:00:00 2001
From: Name2781 <98187590+Name2781@users.noreply.github.com>
Date: Wed, 4 Dec 2024 15:56:07 -0500
Subject: [PATCH] Initial commit
---
.gitignore | 400 +++++++++++++++++++++++++++++++
Funnies.csproj | 13 +
Funnies.sln | 25 ++
LICENSE.md | 0
README.md | 24 ++
src/Commands/CommandDebug.cs | 23 ++
src/Commands/CommandInvisible.cs | 45 ++++
src/Commands/CommandMoney.cs | 33 +++
src/Commands/CommandRcon.cs | 16 ++
src/Commands/CommandWallhack.cs | 32 +++
src/FunniesPlugin.cs | 49 ++++
src/Globals.cs | 16 ++
src/Models/SoundData.cs | 7 +
src/Modules/Invisible.cs | 144 +++++++++++
src/Modules/Wallhack.cs | 108 +++++++++
src/Util.cs | 51 ++++
16 files changed, 986 insertions(+)
create mode 100644 .gitignore
create mode 100644 Funnies.csproj
create mode 100644 Funnies.sln
create mode 100644 LICENSE.md
create mode 100644 README.md
create mode 100644 src/Commands/CommandDebug.cs
create mode 100644 src/Commands/CommandInvisible.cs
create mode 100644 src/Commands/CommandMoney.cs
create mode 100644 src/Commands/CommandRcon.cs
create mode 100644 src/Commands/CommandWallhack.cs
create mode 100644 src/FunniesPlugin.cs
create mode 100644 src/Globals.cs
create mode 100644 src/Models/SoundData.cs
create mode 100644 src/Modules/Invisible.cs
create mode 100644 src/Modules/Wallhack.cs
create mode 100644 src/Util.cs
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..60b2ea0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,400 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+# but not Directory.Build.rsp, as it configures directory-level build defaults
+!Directory.Build.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
\ No newline at end of file
diff --git a/Funnies.csproj b/Funnies.csproj
new file mode 100644
index 0000000..ca50424
--- /dev/null
+++ b/Funnies.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Funnies.sln b/Funnies.sln
new file mode 100644
index 0000000..7a4cbfc
--- /dev/null
+++ b/Funnies.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.002.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Funnies", "Funnies.csproj", "{C30340C9-EB65-4BF4-862D-0AA945D9336F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C30340C9-EB65-4BF4-862D-0AA945D9336F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C30340C9-EB65-4BF4-862D-0AA945D9336F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C30340C9-EB65-4BF4-862D-0AA945D9336F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C30340C9-EB65-4BF4-862D-0AA945D9336F}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {D76A2B88-56B8-4C9E-BD76-99AB89891B4A}
+ EndGlobalSection
+EndGlobal
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..e69de29
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..70d4197
--- /dev/null
+++ b/README.md
@@ -0,0 +1,24 @@
+# Funny Plugin
+
+## Overview
+This plugin recreates the 1v5 but one person has wallhacks and the invisible man gamemode shown in dima_wallhacks and renyan videos for Counter Strike 2.
+
+## Installation
+1. Install [Counter Strike Sharp](https://docs.cssharp.dev/docs/guides/getting-started.html) on your server.
+2. Download the plugin from the [releases](https://github.com/Name2781/FunnyPlugin/releases) and put it in `server/game/csgo/addons/counterstrikesharp/plugins`.
+
+## Usage:
+
+### Commands:
+1. `!wallhack ` gives a player wallhacks.
+2. `!invisible ` makes a player invisible.
+
+### Admin Commands:
+1. `!rcon ` runs a server command.
+2. `!money ` gives a player money.
+
+## Contact:
+If you have any issues, feedback, or feature requests please make an issue on the issues page. If you want to contact me directly about making custom plugins you can through discord (namethempguy).
+
+## License:
+This plugin is licensed under the MIT License. Feel free to use, modify, and distribute it in your servers. Attribution is appreciated but not required.
\ No newline at end of file
diff --git a/src/Commands/CommandDebug.cs b/src/Commands/CommandDebug.cs
new file mode 100644
index 0000000..cff8237
--- /dev/null
+++ b/src/Commands/CommandDebug.cs
@@ -0,0 +1,23 @@
+#if DEBUG
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Modules.Commands;
+
+namespace Funnies.Commands;
+
+public class CommandDebug
+{
+ public static void OnDebugCommand(CCSPlayerController? caller, CommandInfo command)
+ {
+ foreach (var ent in Utilities.GetAllEntities())
+ {
+ try
+ {
+ var name = ent.As().CBodyComponent.SceneNode.GetSkeletonInstance().ModelState.ModelName;
+ Console.WriteLine($"{ent.DesignerName} | {name}");
+ }
+ catch {};
+ }
+ }
+}
+#endif
\ No newline at end of file
diff --git a/src/Commands/CommandInvisible.cs b/src/Commands/CommandInvisible.cs
new file mode 100644
index 0000000..5ed608f
--- /dev/null
+++ b/src/Commands/CommandInvisible.cs
@@ -0,0 +1,45 @@
+using System.Drawing;
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Modules.Admin;
+using CounterStrikeSharp.API.Modules.Commands;
+
+namespace Funnies.Commands;
+
+public class CommandInvisible
+{
+ public static void OnInvisibleCommand(CCSPlayerController? caller, CommandInfo command)
+ {
+ if (!AdminManager.PlayerHasPermissions(caller, "@css/generic")) return;
+
+ var player = Util.GetPlayerByName(command.ArgString);
+
+ if (player != null)
+ {
+ if (Util.IsPlayerValid(caller))
+ Util.ServerPrintToChat(caller!, $"Toggled invisiblity on {command.ArgString}");
+
+ if (Globals.InvisiblePlayers.ContainsKey(player))
+ {
+ Globals.InvisiblePlayers.Remove(player);
+
+ var pawn = player.PlayerPawn.Value;
+ pawn!.Render = Color.FromArgb(255, pawn.Render);
+ Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender");
+
+ foreach (var weapon in pawn.WeaponServices!.MyWeapons)
+ {
+ weapon.Value!.Render = pawn!.Render;
+ Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender");
+ }
+ }
+ else
+ Globals.InvisiblePlayers.Add(player, new());
+ }
+ else
+ {
+ if (Util.IsPlayerValid(caller))
+ Util.ServerPrintToChat(caller!, $"Player {command.ArgString} not found");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Commands/CommandMoney.cs b/src/Commands/CommandMoney.cs
new file mode 100644
index 0000000..c64fc23
--- /dev/null
+++ b/src/Commands/CommandMoney.cs
@@ -0,0 +1,33 @@
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Modules.Admin;
+using CounterStrikeSharp.API.Modules.Commands;
+
+namespace Funnies.Commands;
+
+public class CommandMoney
+{
+ public static void OnMoneyCommand(CCSPlayerController? caller, CommandInfo command)
+ {
+ if (!AdminManager.PlayerHasPermissions(caller, "@css/generic")) return;
+
+ int index = command.ArgString.IndexOf(' ');
+ int money = int.Parse(command.ArgString[..index]);
+ var name = command.ArgString[(index + 1)..];
+ var player = Util.GetPlayerByName(name);
+
+ if (player != null)
+ {
+ if (Util.IsPlayerValid(caller))
+ Util.ServerPrintToChat(caller!, $"Set {name}'s money to ${money}");
+
+ player.InGameMoneyServices!.Account = money;
+ Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInGameMoneyServices");
+ }
+ else
+ {
+ if (Util.IsPlayerValid(caller))
+ Util.ServerPrintToChat(caller!, $"Player {name} not found");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Commands/CommandRcon.cs b/src/Commands/CommandRcon.cs
new file mode 100644
index 0000000..d9494a8
--- /dev/null
+++ b/src/Commands/CommandRcon.cs
@@ -0,0 +1,16 @@
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Modules.Admin;
+using CounterStrikeSharp.API.Modules.Commands;
+
+namespace Funnies.Commands;
+
+public class CommandRcon
+{
+ public static void OnRconCommand(CCSPlayerController? caller, CommandInfo command)
+ {
+ if (!AdminManager.PlayerHasPermissions(caller, "@css/rcon")) return;
+
+ Server.ExecuteCommand(command.ArgString);
+ }
+}
\ No newline at end of file
diff --git a/src/Commands/CommandWallhack.cs b/src/Commands/CommandWallhack.cs
new file mode 100644
index 0000000..353c773
--- /dev/null
+++ b/src/Commands/CommandWallhack.cs
@@ -0,0 +1,32 @@
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Core.Attributes.Registration;
+using CounterStrikeSharp.API.Modules.Admin;
+using CounterStrikeSharp.API.Modules.Commands;
+
+namespace Funnies.Commands;
+
+public class CommandWallhack
+{
+ public static void OnWallhackCommand(CCSPlayerController? caller, CommandInfo command)
+ {
+ if (!AdminManager.PlayerHasPermissions(caller, "@css/generic")) return;
+
+ var player = Util.GetPlayerByName(command.ArgString);
+
+ if (player != null)
+ {
+ if (Util.IsPlayerValid(caller))
+ Util.ServerPrintToChat(caller!, $"Toggled wallhacks on {command.ArgString}");
+
+ if (Globals.Wallhackers.Contains(player))
+ Globals.Wallhackers.Remove(player);
+ else
+ Globals.Wallhackers.Add(player);
+ }
+ else
+ {
+ if (Util.IsPlayerValid(caller))
+ Util.ServerPrintToChat(caller!, $"Player {command.ArgString} not found");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FunniesPlugin.cs b/src/FunniesPlugin.cs
new file mode 100644
index 0000000..5ea1bb5
--- /dev/null
+++ b/src/FunniesPlugin.cs
@@ -0,0 +1,49 @@
+using CounterStrikeSharp.API.Core;
+using Funnies.Commands;
+using Funnies.Modules;
+
+namespace Funnies;
+
+public class FunniesPlugin : BasePlugin
+{
+ public override string ModuleName => "Funny plugin";
+
+ public override string ModuleVersion => "0.0.1";
+
+ public override void Load(bool hotReload)
+ {
+ Console.WriteLine("So funny :)");
+
+ Globals.Plugin = this;
+
+ RegisterListener(OnCheckTransmit);
+ RegisterListener(OnTick);
+
+ AddCommand("css_money", "Gives a player money", CommandMoney.OnMoneyCommand);
+ AddCommand("css_rcon", "Runs a command", CommandRcon.OnRconCommand);
+
+ #if DEBUG
+ AddCommand("css_debug", "Debug command", CommandDebug.OnDebugCommand);
+ #endif
+
+ Invisible.Setup();
+ Wallhack.Setup();
+ }
+
+ public void OnTick()
+ {
+ Invisible.OnTick();
+ }
+
+ public void OnCheckTransmit(CCheckTransmitInfoList infoList)
+ {
+ foreach ((CCheckTransmitInfo info, CCSPlayerController? player) in infoList)
+ {
+ if (!Util.IsPlayerValid(player))
+ continue;
+
+ Wallhack.OnPlayerTransmit(info, player!);
+ Invisible.OnPlayerTransmit(info, player!);
+ }
+ }
+}
diff --git a/src/Globals.cs b/src/Globals.cs
new file mode 100644
index 0000000..db85d84
--- /dev/null
+++ b/src/Globals.cs
@@ -0,0 +1,16 @@
+using CounterStrikeSharp.API.Core;
+using Funnies.Models;
+
+namespace Funnies;
+
+public static class Globals
+{
+ public static List Wallhackers = [];
+ public static Dictionary GlowEntities = [];
+
+ public static Dictionary InvisiblePlayers = [];
+
+#pragma warning disable CS8618
+ public static FunniesPlugin Plugin;
+#pragma warning restore CS8618
+}
\ No newline at end of file
diff --git a/src/Models/SoundData.cs b/src/Models/SoundData.cs
new file mode 100644
index 0000000..02f0d62
--- /dev/null
+++ b/src/Models/SoundData.cs
@@ -0,0 +1,7 @@
+namespace Funnies.Models;
+
+public struct SoundData(float startTime = -1f, float endTime = -1f)
+{
+ public float StartTime = startTime;
+ public float EndTime = endTime;
+}
\ No newline at end of file
diff --git a/src/Modules/Invisible.cs b/src/Modules/Invisible.cs
new file mode 100644
index 0000000..85e7e24
--- /dev/null
+++ b/src/Modules/Invisible.cs
@@ -0,0 +1,144 @@
+using System.Drawing;
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Modules.Utils;
+using Funnies.Commands;
+
+namespace Funnies.Modules;
+
+public class Invisible
+{
+ public static void OnPlayerTransmit(CCheckTransmitInfo info, CCSPlayerController player)
+ {
+ // TODO: Should store these but dont know a good way :/
+ var gameRules = Utilities.FindAllEntitiesByDesignerName("cs_gamerules").First();
+
+ if (gameRules.GameRules!.WarmupPeriod) return;
+ var c4 = Utilities.FindAllEntitiesByDesignerName("weapon_c4").First();
+
+ if (player!.Team != CsTeam.Terrorist && !gameRules.GameRules!.BombPlanted && !c4.IsPlantingViaUse && !gameRules.GameRules!.BombDropped)
+ info.TransmitEntities.Remove(c4);
+ else
+ info.TransmitEntities.Add(c4);
+ }
+
+ public static void OnTick()
+ {
+ foreach (var invis in Globals.InvisiblePlayers)
+ {
+ if (!Util.IsPlayerValid(invis.Key)) continue;
+
+ var alpha = 255f;
+
+ var half = Server.CurrentTime + ((invis.Value.StartTime - Server.CurrentTime) / 2);
+ if (half < Server.CurrentTime)
+ alpha = invis.Value.EndTime < Server.CurrentTime ? 0 : Util.Map(Server.CurrentTime, half, invis.Value.EndTime, 255, 0);
+
+ var progress = (int)Util.Map(alpha, 0, 255, 0, 20);
+ var pawn = invis.Key.PlayerPawn.Value;
+
+ invis.Key.PrintToCenterHtml(string.Concat(Enumerable.Repeat("█", progress)) + string.Concat(Enumerable.Repeat("░", 20 - progress)));
+
+ pawn!.Render = Color.FromArgb((int)alpha, pawn.Render);
+ Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender");
+
+ foreach (var weapon in pawn.WeaponServices!.MyWeapons)
+ {
+ weapon.Value!.Render = pawn!.Render;
+ Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender");
+ }
+ }
+ }
+
+ public static HookResult OnPlayerSound(EventPlayerSound @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.InvisiblePlayers.TryGetValue(player!, out var data)) return HookResult.Continue;
+
+ data.StartTime = Server.CurrentTime;
+ data.EndTime = Server.CurrentTime + (@event.Duration * 2);
+
+ Globals.InvisiblePlayers[player!] = data;
+ return HookResult.Continue;
+ }
+
+ public static HookResult OnPlayerShoot(EventBulletImpact @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.InvisiblePlayers.TryGetValue(player!, out var data)) return HookResult.Continue;
+
+ data.StartTime = Server.CurrentTime;
+ data.EndTime = Server.CurrentTime + 0.5f;
+
+ Globals.InvisiblePlayers[player!] = data;
+ return HookResult.Continue;
+ }
+
+ public static HookResult OnPlayerStartPlant(EventBombBeginplant @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.InvisiblePlayers.TryGetValue(player!, out var data)) return HookResult.Continue;
+
+ data.StartTime = Server.CurrentTime;
+ data.EndTime = Server.CurrentTime + 1f;
+
+ Globals.InvisiblePlayers[player!] = data;
+ return HookResult.Continue;
+ }
+
+ public static HookResult OnPlayerStartDefuse(EventBombBegindefuse @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.InvisiblePlayers.TryGetValue(player!, out var data)) return HookResult.Continue;
+
+ data.StartTime = Server.CurrentTime;
+ data.EndTime = Server.CurrentTime + 1f;
+
+ Globals.InvisiblePlayers[player!] = data;
+ return HookResult.Continue;
+ }
+
+ public static HookResult OnPlayerReload(EventWeaponReload @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.InvisiblePlayers.TryGetValue(player!, out var data)) return HookResult.Continue;
+
+ data.StartTime = Server.CurrentTime;
+ data.EndTime = Server.CurrentTime + 1.5f;
+
+ Globals.InvisiblePlayers[player!] = data;
+ return HookResult.Continue;
+ }
+
+ public static HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.InvisiblePlayers.TryGetValue(player!, out var data)) return HookResult.Continue;
+
+ data.StartTime = Server.CurrentTime;
+ data.EndTime = Server.CurrentTime + 0.5f;
+
+ Globals.InvisiblePlayers[player!] = data;
+ return HookResult.Continue;
+ }
+
+ public static void Setup()
+ {
+ Globals.Plugin.RegisterEventHandler(OnPlayerStartPlant);
+ // EventPlayerShoot doesnt work so we use EventBulletImpact
+ Globals.Plugin.RegisterEventHandler(OnPlayerShoot);
+ Globals.Plugin.RegisterEventHandler(OnPlayerSound);
+ Globals.Plugin.RegisterEventHandler(OnPlayerStartDefuse);
+ Globals.Plugin.RegisterEventHandler(OnPlayerReload);
+ Globals.Plugin.RegisterEventHandler(OnPlayerHurt);
+
+ Globals.Plugin.AddCommand("css_invisible", "Makes a player invisible", CommandInvisible.OnInvisibleCommand);
+ Globals.Plugin.AddCommand("css_invis", "Makes a player invisible", CommandInvisible.OnInvisibleCommand);
+ }
+}
\ No newline at end of file
diff --git a/src/Modules/Wallhack.cs b/src/Modules/Wallhack.cs
new file mode 100644
index 0000000..b79a989
--- /dev/null
+++ b/src/Modules/Wallhack.cs
@@ -0,0 +1,108 @@
+using System.Drawing;
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Core.Attributes.Registration;
+using CounterStrikeSharp.API.Modules.Utils;
+using Funnies.Commands;
+
+namespace Funnies.Modules;
+
+public class Wallhack
+{
+ public static void OnPlayerTransmit(CCheckTransmitInfo info, CCSPlayerController player)
+ {
+ foreach (var entity in Globals.GlowEntities)
+ {
+ if (Globals.Wallhackers.Contains(player!))
+ {
+ if (entity.Key.Team != player!.Team)
+ {
+ info.TransmitEntities.Add(entity.Value);
+ continue;
+ }
+ }
+
+ info.TransmitEntities.Remove(entity.Value);
+ }
+ }
+
+ public static HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (player!.Team < CsTeam.Terrorist) return HookResult.Continue; // if player isnt on a team
+
+ Glow(player!);
+
+ return HookResult.Continue;
+ }
+
+ public static HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.GlowEntities.TryGetValue(player!, out var glowEntity)) return HookResult.Continue;
+
+ if (glowEntity.IsValid)
+ glowEntity.Remove();
+
+ Globals.GlowEntities.Remove(player!);
+ Globals.Wallhackers.Remove(player!);
+
+ return HookResult.Continue;
+ }
+
+ public static HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
+ {
+ var player = @event.Userid;
+ if (!Util.IsPlayerValid(player)) return HookResult.Continue;
+ if (!Globals.GlowEntities.TryGetValue(player!, out var glowEntity)) return HookResult.Continue;
+
+ glowEntity.Glow.GlowRange = 0;
+ // Its dumb to call this again but the server crashes if i do anything else
+ glowEntity.DispatchSpawn();
+
+ return HookResult.Continue;
+ }
+
+ private static void Glow(CCSPlayerController player)
+ {
+ var glowEntity = Utilities.CreateEntityByName("prop_dynamic");
+ var modelRelay = Utilities.CreateEntityByName("prop_dynamic");
+
+ modelRelay!.Spawnflags = 256;
+ modelRelay.Render = Color.Transparent;
+ modelRelay.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(modelRelay.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
+ modelRelay.SetModel(Util.GetPlayerModel(player));
+
+ // https://github.com/exkludera/cs2-glowing-entities/blob/main/src/main.cs
+ glowEntity!.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(glowEntity.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
+
+ glowEntity.SetModel(Util.GetPlayerModel(player));
+
+ glowEntity.DispatchSpawn();
+ modelRelay.DispatchSpawn();
+
+ glowEntity.Glow.GlowRange = 5000;
+ glowEntity.Glow.GlowRangeMin = 0;
+ glowEntity.Glow.GlowColorOverride = Color.FromArgb(255, 171, 75, 209);
+ glowEntity.Glow.GlowTeam = -1;
+ glowEntity.Glow.GlowType = 3;
+
+ modelRelay.AcceptInput("FollowEntity", player.Pawn.Value, null, "!activator");
+ glowEntity.AcceptInput("FollowEntity", modelRelay, null, "!activator");
+
+ Globals.GlowEntities.Remove(player);
+ Globals.GlowEntities.Add(player, glowEntity);
+ }
+
+ public static void Setup()
+ {
+ Globals.Plugin.RegisterEventHandler(OnPlayerDeath);
+ Globals.Plugin.RegisterEventHandler(OnPlayerDisconnect);
+ Globals.Plugin.RegisterEventHandler(OnPlayerSpawn, HookMode.Post);
+
+ Globals.Plugin.AddCommand("css_wh", "Gives a player walls", CommandWallhack.OnWallhackCommand);
+ Globals.Plugin.AddCommand("css_wallhack", "Gives a player walls", CommandWallhack.OnWallhackCommand);
+ }
+}
\ No newline at end of file
diff --git a/src/Util.cs b/src/Util.cs
new file mode 100644
index 0000000..3d99646
--- /dev/null
+++ b/src/Util.cs
@@ -0,0 +1,51 @@
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Modules.Memory;
+using CounterStrikeSharp.API.Modules.Utils;
+
+namespace Funnies;
+
+public static class Util
+{
+
+ public static string GetPlayerModel(CCSPlayerController player)
+ {
+ // This hurts
+ return player.Pawn.Value!.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName;
+ }
+
+ public static bool IsPlayerValid(CCSPlayerController? plr)
+ {
+ if (plr == null) return false;
+ if (plr.PlayerPawn == null) return false;
+ return plr.IsValid || plr.PlayerPawn.IsValid;
+ }
+
+ public static List GetValidPlayers()
+ {
+ List validPlayers = [];
+ foreach (var plr in Utilities.GetPlayers())
+ {
+ if (IsPlayerValid(plr))
+ validPlayers.Add(plr);
+ }
+
+ return validPlayers;
+ }
+
+ public static float Map(float value, float fromMin, float fromMax, float toMin, float toMax)
+ {
+ float normalized = (value - fromMin) / (fromMax - fromMin);
+ return toMin + normalized * (toMax - toMin);
+ }
+
+ public static CCSPlayerController? GetPlayerByName(string name)
+ {
+ return GetValidPlayers().FirstOrDefault(x => x!.PlayerName == name, null);
+ }
+
+ public static void ServerPrintToChat(CCSPlayerController player, string message)
+ {
+ player.PrintToChat($" {ChatColors.Green}[SERVER]{ChatColors.White} {message}");
+ }
+}
\ No newline at end of file