Skip to content
This repository has been archived by the owner on Feb 16, 2025. It is now read-only.

Commit

Permalink
1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
oqyh authored Apr 23, 2024
1 parent 2c05bc5 commit 9fd0e7c
Show file tree
Hide file tree
Showing 8 changed files with 1,380 additions and 0 deletions.
114 changes: 114 additions & 0 deletions Config/Configs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.VisualBasic;

namespace Kill_Sound_GoldKingZ.Config
{
public static class Configs
{
public static class Shared {
public static string? CookiesFolderPath { get; set; }
}

private static readonly string ConfigDirectoryName = "config";
private static readonly string ConfigFileName = "config.json";
private static readonly string jsonFilePath = "Kill_Settings.json";
private static string? _configFilePath;
private static string? _jsonFilePath;
private static ConfigData? _configData;

private static readonly JsonSerializerOptions SerializationOptions = new()
{
Converters =
{
new JsonStringEnumConverter()
},
WriteIndented = true,
AllowTrailingCommas = true,
ReadCommentHandling = JsonCommentHandling.Skip,
};

public static bool IsLoaded()
{
return _configData is not null;
}

public static ConfigData GetConfigData()
{
if (_configData is null)
{
throw new Exception("Config not yet loaded.");
}

return _configData;
}

public static ConfigData Load(string modulePath)
{
var configFileDirectory = Path.Combine(modulePath, ConfigDirectoryName);
if(!Directory.Exists(configFileDirectory))
{
Directory.CreateDirectory(configFileDirectory);
}
_jsonFilePath = Path.Combine(configFileDirectory, jsonFilePath);
Helper.CreateDefaultWeaponsJson(_jsonFilePath);

_configFilePath = Path.Combine(configFileDirectory, ConfigFileName);
if (File.Exists(_configFilePath))
{
_configData = JsonSerializer.Deserialize<ConfigData>(File.ReadAllText(_configFilePath), SerializationOptions);
}
else
{
_configData = new ConfigData();
}

if (_configData is null)
{
throw new Exception("Failed to load configs.");
}

SaveConfigData(_configData);

return _configData;
}

private static void SaveConfigData(ConfigData configData)
{
if (_configFilePath is null)
{
throw new Exception("Config not yet loaded.");
}
string json = JsonSerializer.Serialize(configData, SerializationOptions);

json = "// Note: To Use Modify Version And Lower Volume \n// Download https://github.com/Source2ZE/MultiAddonManager With Gold KingZ WorkShop \n// https://steamcommunity.com/sharedfiles/filedetails/?id=3230015783\n// mm_extra_addons 3230015783\n// OtherWise Use Normal Sounds https://github.com/oqyh/cs2-Kill-Sound-GoldKingZ/blob/main/sounds/sounds.txt \n\n" + json;

File.WriteAllText(_configFilePath, json);
}

public class ConfigData
{
public bool KS_EnableQuakeSounds { get; set; }

public string empty { get; set; }
public string KS_HeadShotKillSoundPath { get; set; }
public string KS_BodyKillSoundPath { get; set; }
public string KS_HeadShotHitSoundPath { get; set; }
public string KS_BodyHitSoundPath { get; set; }
public string empty2 { get; set; }
public string Information_For_You_Dont_Delete_it { get; set; }

public ConfigData()
{
KS_EnableQuakeSounds = false;
empty = "-----------------------------------------------------------------------------------";
KS_HeadShotKillSoundPath = "sounds/GoldKingZ/Training/bell_normal.vsnd_c";
KS_BodyKillSoundPath = "sounds/GoldKingZ/Training/timer_bell.vsnd_c";
KS_HeadShotHitSoundPath = "sounds/GoldKingZ/Training/bell_impact.vsnd_c";
KS_BodyHitSoundPath = "sounds/GoldKingZ/Training/timer_bell.vsnd_c";
empty2 = "-----------------------------------------------------------------------------------";
Information_For_You_Dont_Delete_it = " Vist [https://github.com/oqyh/cs2-Kill-Sound-GoldKingZ/tree/main?tab=readme-ov-file#-configuration-] To Understand All Above";
}
}
}
}
21 changes: 21 additions & 0 deletions Config/Globals.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using CounterStrikeSharp.API.Core;
using System.Diagnostics;

namespace Kill_Sound_GoldKingZ;

public class Globals
{
public static int Takefreezetime;
public static Stopwatch Timers = new Stopwatch();
public static bool First_Blood = false;
public static Dictionary<ulong, int> Kill_Streak = new Dictionary<ulong, int>();
public static Dictionary<ulong, int> Kill_StreakHS = new Dictionary<ulong, int>();
public static Dictionary<ulong, int> Kill_Knife = new Dictionary<ulong, int>();
public static Dictionary<ulong, int> Kill_Nade = new Dictionary<ulong, int>();
public static Dictionary<ulong, int> Kill_Molly = new Dictionary<ulong, int>();
public static Dictionary<ulong, DateTime> lastPlayTimes = new Dictionary<ulong, DateTime>();
public static Dictionary<ulong, DateTime> lastPlayTimesHS = new Dictionary<ulong, DateTime>();
public static Dictionary<ulong, DateTime> lastPlayTimesKnife = new Dictionary<ulong, DateTime>();
public static Dictionary<ulong, DateTime> lastPlayTimesNade = new Dictionary<ulong, DateTime>();
public static Dictionary<ulong, DateTime> lastPlayTimesMolly = new Dictionary<ulong, DateTime>();
}
Loading

0 comments on commit 9fd0e7c

Please sign in to comment.