Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Klayeryt authored Dec 30, 2023
1 parent ec65f5c commit ee5070c
Show file tree
Hide file tree
Showing 33 changed files with 434 additions and 0 deletions.
Binary file added CounterStrikeSharp.API.dll
Binary file not shown.
141 changes: 141 additions & 0 deletions Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
using System;
using System.Text.Json.Serialization;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Utils;
using CounterStrikeSharp.API.Modules.Cvars;

namespace Main;
public class ConnectInfoConfig : BasePluginConfig
{
[JsonPropertyName("PluginName")] public string Name { get; set; } = "[Welcome] | ";
[JsonPropertyName("Timer")] public float Timer { get; set; } = 10.0f;
[JsonPropertyName("WelcomePlayerOneEnable")] public string WelcomePlayerOneEnable { get; set; } = "true";
[JsonPropertyName("WelcomePlayerAllEnable")] public string WelcomePlayerAllEnable { get; set; } = "true";
[JsonPropertyName("DisconnectPlayerAllEnable")] public string DisconnectPlayerAllEnable { get; set; } = "true";
[JsonPropertyName("WelcomeText")] public string WelcomeText { get; set; } = " {RED}---------------------------------{ENTER} {LIGHTBLUE}Welcome on server {PLAYERNAME} {ENTER} Now map: {MAP} {ENTER} Players online: {PLAYERS}/{MAXPLAYERS} {ENTER} {RED}Your IP: {IPUSER} {ENTER} {RED}------------------------------ ";
[JsonPropertyName("disconnectAllText")] public string disconnectAllText { get; set; } = " {RED} {PLAYERNAME} disconnect to reason: {REASON} ";
[JsonPropertyName("WelcomeAllText")] public string WelcomeAllText { get; set; } = " {RED} {PLAYERNAME} connected to server";
}

public class Main : BasePlugin, IPluginConfig<ConnectInfoConfig>
{
public override string ModuleName => "Welcome";
public override string ModuleAuthor => "Xenomoros";
public override string ModuleVersion => "1.0";

public ConnectInfoConfig Config { get; set; }

public void OnConfigParsed(ConnectInfoConfig config)
{
Config = config;
}

public override void Load(bool hotReload)
{
ReWriteColor($"-------------------------------------------");
ReWriteColor($"{Config.Name} Plugin has been enebled :)");
ReWriteColor($"{Config.Name} Plugin version - {ModuleVersion}");
ReWriteColor($"-------------------------------------------");
ReWriteColor("ConVars status: ");
if(Config.WelcomePlayerAllEnable == "false" || Config.WelcomePlayerAllEnable == "0") {
ReWriteColor("WelcomePlayerAllEnable(-None-)");
}
else if (Config.WelcomePlayerAllEnable == "true" || Config.WelcomePlayerAllEnable == "1") {
ReWriteColor("WelcomePlayerAllEnable(-Enable-)");
}

if (Config.WelcomePlayerOneEnable == "false" || Config.WelcomePlayerOneEnable == "0") {
ReWriteColor("WelcomePlayerOneEnable(-None-)");
}
else if (Config.WelcomePlayerOneEnable == "true" || Config.WelcomePlayerOneEnable == "1") {
ReWriteColor("WelcomePlayerOneEnable(-Enable-)");
}

if (Config.DisconnectPlayerAllEnable == "false" || Config.DisconnectPlayerAllEnable == "0") {
ReWriteColor("DisconnectPlayerAllEnable(-None-)");
}
else if (Config.DisconnectPlayerAllEnable == "true" || Config.DisconnectPlayerAllEnable == "1") {
ReWriteColor("DisconnectPlayerAllEnable(-Enable-)");
}
}

[GameEventHandler]
public HookResult OnPlayerConnectFull(EventPlayerConnectFull @event, GameEventInfo info)
{
string ipuser = @event.Userid.IpAddress;
var playerName = @event.Userid.PlayerName;
var eventr = @event;
var userid = @event.Userid;
var steamId = @event.Userid.SteamID.ToString();
if(Config.WelcomePlayerAllEnable == "true" || Config.WelcomePlayerAllEnable == "1") {
if(!@event.Userid.IsBot) {
Server.PrintToChatAll(ReplaceMessageTags(Config.WelcomeAllText, playerName, String.Empty, ipuser, steamId));
}
}
else {}

if(Config.WelcomePlayerOneEnable == "true" || Config.WelcomePlayerOneEnable == "1") {
if(!@event.Userid.IsBot) {
AddTimer(Config.Timer, () => {
userid.PrintToChat(ReplaceMessageTags(Config.WelcomeText, playerName, String.Empty, ipuser, steamId));
});
}
}
else {}
return HookResult.Stop;
}

[GameEventHandler]
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info) {
string playerName = @event.Name;
if(Config.DisconnectPlayerAllEnable == "true" || Config.DisconnectPlayerAllEnable == "1") {
if(@event.Reason.ToString() != "39") {
Server.PrintToChatAll(ReplaceMessageTags(Config.disconnectAllText, playerName, @event.Reason.ToString(), String.Empty, String.Empty));
}
}
else {}
return HookResult.Continue;
}

public string ReWriteColor(string text) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"{text}");
Console.ForegroundColor = ConsoleColor.White;
return text;
}

private string ReplaceMessageTags(string message, string playerName, string reason, string ipuser, string SteamPlID)
{
var replacedMessage = message
.Replace("{ENTER}", "\u2029")
.Replace("{MAP}", NativeAPI.GetMapName())
.Replace("{TIME}", DateTime.Now.ToString("HH:mm:ss"))
.Replace("{DATE}", DateTime.Now.ToString("dd.MM.yyyy"))
.Replace("{SERVERNAME}", ConVar.Find("hostname")!.StringValue)
.Replace("{IP}", ConVar.Find("ip")!.StringValue)
.Replace("{PORT}", ConVar.Find("hostport")!.GetPrimitiveValue<int>().ToString())
.Replace("{MAXPLAYERS}", Server.MaxPlayers.ToString())
.Replace("{PLAYERS}", Utilities.GetPlayers().Count.ToString())
.Replace("{REASON}", reason)
.Replace("{PLAYERNAME}", playerName.ToString())
.Replace("{IPUSER}", ipuser)
.Replace("{STEAMID}", SteamPlID);

replacedMessage = ReplaceMessageColors(replacedMessage);

return replacedMessage;
}

private string ReplaceMessageColors(string input) {
string[] ColorAlphabet = {"{GREEN}", "{BLUE}", "{RED}", "{SILVER}", "{MAGENTA}", "{GOLD}", "{DEFAULT}", "{LIGHTBLUE}", "{LIGHTPURPLE}", "{LIGHTRED}", "{LIGHTYELLOW}", "{YELLOW}", "{GREY}", "{LIME}", "{OLIVE}", "{ORANGE}", "{DARKRED}", "{DARKBLUE}", "{BLUEGREY}", "{PURPLE}"};
string[] ColorChar = {$"{ChatColors.Green}", $"{ChatColors.Blue}", $"{ChatColors.Red}", $"{ChatColors.Silver}", $"{ChatColors.Magenta}", $"{ChatColors.Gold}", $"{ChatColors.Default}", $"{ChatColors.LightBlue}", $"{ChatColors.LightPurple}", $"{ChatColors.LightRed}", $"{ChatColors.LightYellow}", $"{ChatColors.Yellow}", $"{ChatColors.Grey}", $"{ChatColors.Lime}", $"{ChatColors.Olive}", $"{ChatColors.Orange}", $"{ChatColors.Darkred}", $"{ChatColors.DarkBlue}", $"{ChatColors.BlueGrey}", $"{ChatColors.Purple}"};

for(int z = 0; z < ColorAlphabet.Length; z++)
input = input.Replace(ColorAlphabet[z], ColorChar[z]);


return input;
}
}
15 changes: 15 additions & 0 deletions Welcome.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Platforms>AnyCPU;x86;x64</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Reference Include="CounterStrikeSharp.API">
<HintPath>..\CounterStrikeSharp.API.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions obj/Debug/net7.0/Welcome.AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Welcome")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Welcome")]
[assembly: System.Reflection.AssemblyTitleAttribute("Welcome")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

1 change: 1 addition & 0 deletions obj/Debug/net7.0/Welcome.AssemblyInfoInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
96ef558e15c98f10fd85988999973a17678585ea3e7b1e3dd36419929a7c1263
13 changes: 13 additions & 0 deletions obj/Debug/net7.0/Welcome.GeneratedMSBuildEditorConfig.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net7.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Welcome
build_property.ProjectDir = D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Binary file added obj/Debug/net7.0/Welcome.assets.cache
Binary file not shown.
Binary file not shown.
Empty file.
1 change: 1 addition & 0 deletions obj/Debug/net7.0/Welcome.csproj.CoreCompileInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2aa64b1994f8ced77a2c92d8712cba7f6a5b48fc3de662e5b20bc6a6c09c75f2
14 changes: 14 additions & 0 deletions obj/Debug/net7.0/Welcome.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.csproj.AssemblyReference.cache
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.GeneratedMSBuildEditorConfig.editorconfig
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.AssemblyInfoInputs.cache
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.AssemblyInfo.cs
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.csproj.CoreCompileInputs.cache
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net7.0\Welcome.deps.json
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net7.0\Welcome.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net7.0\Welcome.pdb
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net7.0\CounterStrikeSharp.API.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.csproj.CopyComplete
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\refint\Welcome.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\Welcome.pdb
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net7.0\ref\Welcome.dll
Binary file added obj/Debug/net7.0/Welcome.dll
Binary file not shown.
Binary file added obj/Debug/net7.0/Welcome.pdb
Binary file not shown.
Binary file added obj/Debug/net7.0/ref/Welcome.dll
Binary file not shown.
Binary file added obj/Debug/net7.0/refint/Welcome.dll
Binary file not shown.
22 changes: 22 additions & 0 deletions obj/Debug/net8.0/Welcome.AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Welcome")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Welcome")]
[assembly: System.Reflection.AssemblyTitleAttribute("Welcome")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

1 change: 1 addition & 0 deletions obj/Debug/net8.0/Welcome.AssemblyInfoInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
96ef558e15c98f10fd85988999973a17678585ea3e7b1e3dd36419929a7c1263
13 changes: 13 additions & 0 deletions obj/Debug/net8.0/Welcome.GeneratedMSBuildEditorConfig.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Welcome
build_property.ProjectDir = D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
8 changes: 8 additions & 0 deletions obj/Debug/net8.0/Welcome.GlobalUsings.g.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file added obj/Debug/net8.0/Welcome.assets.cache
Binary file not shown.
Binary file not shown.
Empty file.
1 change: 1 addition & 0 deletions obj/Debug/net8.0/Welcome.csproj.CoreCompileInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f0be647a7afebe135f41c1d6108c3614924c15d6a8abba1f7759b04fc47b5001
14 changes: 14 additions & 0 deletions obj/Debug/net8.0/Welcome.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net8.0\Welcome.deps.json
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net8.0\Welcome.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net8.0\Welcome.pdb
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\bin\Debug\net8.0\CounterStrikeSharp.API.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.csproj.AssemblyReference.cache
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.GeneratedMSBuildEditorConfig.editorconfig
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.AssemblyInfoInputs.cache
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.AssemblyInfo.cs
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.csproj.CoreCompileInputs.cache
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.csproj.CopyComplete
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\refint\Welcome.dll
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\Welcome.pdb
D:\cs2server\steamapps\common\Counter-Strike Global Offensive\game\csgo\addons\counterstrikesharp\source\Welcome\obj\Debug\net8.0\ref\Welcome.dll
Binary file added obj/Debug/net8.0/Welcome.dll
Binary file not shown.
Binary file added obj/Debug/net8.0/Welcome.pdb
Binary file not shown.
Binary file added obj/Debug/net8.0/ref/Welcome.dll
Binary file not shown.
Binary file added obj/Debug/net8.0/refint/Welcome.dll
Binary file not shown.
68 changes: 68 additions & 0 deletions obj/Welcome.csproj.nuget.dgspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"format": 1,
"restore": {
"D:\\cs2server\\steamapps\\common\\Counter-Strike Global Offensive\\game\\csgo\\addons\\counterstrikesharp\\source\\Welcome\\Welcome.csproj": {}
},
"projects": {
"D:\\cs2server\\steamapps\\common\\Counter-Strike Global Offensive\\game\\csgo\\addons\\counterstrikesharp\\source\\Welcome\\Welcome.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\cs2server\\steamapps\\common\\Counter-Strike Global Offensive\\game\\csgo\\addons\\counterstrikesharp\\source\\Welcome\\Welcome.csproj",
"projectName": "Welcome",
"projectPath": "D:\\cs2server\\steamapps\\common\\Counter-Strike Global Offensive\\game\\csgo\\addons\\counterstrikesharp\\source\\Welcome\\Welcome.csproj",
"packagesPath": "C:\\Users\\Daniel\\.nuget\\packages\\",
"outputPath": "D:\\cs2server\\steamapps\\common\\Counter-Strike Global Offensive\\game\\csgo\\addons\\counterstrikesharp\\source\\Welcome\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"D:\\Addins\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\Daniel\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"C:\\Program Files\\dotnet\\library-packs": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.100\\RuntimeIdentifierGraph.json"
}
}
}
}
}
Loading

0 comments on commit ee5070c

Please sign in to comment.