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

Commit 9fd0e7c

Browse files
authored
1.0.5
1 parent 2c05bc5 commit 9fd0e7c

8 files changed

+1380
-0
lines changed

Config/Configs.cs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using System.Text.Json;
2+
using System.Text.Json.Serialization;
3+
using Microsoft.VisualBasic;
4+
5+
namespace Kill_Sound_GoldKingZ.Config
6+
{
7+
public static class Configs
8+
{
9+
public static class Shared {
10+
public static string? CookiesFolderPath { get; set; }
11+
}
12+
13+
private static readonly string ConfigDirectoryName = "config";
14+
private static readonly string ConfigFileName = "config.json";
15+
private static readonly string jsonFilePath = "Kill_Settings.json";
16+
private static string? _configFilePath;
17+
private static string? _jsonFilePath;
18+
private static ConfigData? _configData;
19+
20+
private static readonly JsonSerializerOptions SerializationOptions = new()
21+
{
22+
Converters =
23+
{
24+
new JsonStringEnumConverter()
25+
},
26+
WriteIndented = true,
27+
AllowTrailingCommas = true,
28+
ReadCommentHandling = JsonCommentHandling.Skip,
29+
};
30+
31+
public static bool IsLoaded()
32+
{
33+
return _configData is not null;
34+
}
35+
36+
public static ConfigData GetConfigData()
37+
{
38+
if (_configData is null)
39+
{
40+
throw new Exception("Config not yet loaded.");
41+
}
42+
43+
return _configData;
44+
}
45+
46+
public static ConfigData Load(string modulePath)
47+
{
48+
var configFileDirectory = Path.Combine(modulePath, ConfigDirectoryName);
49+
if(!Directory.Exists(configFileDirectory))
50+
{
51+
Directory.CreateDirectory(configFileDirectory);
52+
}
53+
_jsonFilePath = Path.Combine(configFileDirectory, jsonFilePath);
54+
Helper.CreateDefaultWeaponsJson(_jsonFilePath);
55+
56+
_configFilePath = Path.Combine(configFileDirectory, ConfigFileName);
57+
if (File.Exists(_configFilePath))
58+
{
59+
_configData = JsonSerializer.Deserialize<ConfigData>(File.ReadAllText(_configFilePath), SerializationOptions);
60+
}
61+
else
62+
{
63+
_configData = new ConfigData();
64+
}
65+
66+
if (_configData is null)
67+
{
68+
throw new Exception("Failed to load configs.");
69+
}
70+
71+
SaveConfigData(_configData);
72+
73+
return _configData;
74+
}
75+
76+
private static void SaveConfigData(ConfigData configData)
77+
{
78+
if (_configFilePath is null)
79+
{
80+
throw new Exception("Config not yet loaded.");
81+
}
82+
string json = JsonSerializer.Serialize(configData, SerializationOptions);
83+
84+
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;
85+
86+
File.WriteAllText(_configFilePath, json);
87+
}
88+
89+
public class ConfigData
90+
{
91+
public bool KS_EnableQuakeSounds { get; set; }
92+
93+
public string empty { get; set; }
94+
public string KS_HeadShotKillSoundPath { get; set; }
95+
public string KS_BodyKillSoundPath { get; set; }
96+
public string KS_HeadShotHitSoundPath { get; set; }
97+
public string KS_BodyHitSoundPath { get; set; }
98+
public string empty2 { get; set; }
99+
public string Information_For_You_Dont_Delete_it { get; set; }
100+
101+
public ConfigData()
102+
{
103+
KS_EnableQuakeSounds = false;
104+
empty = "-----------------------------------------------------------------------------------";
105+
KS_HeadShotKillSoundPath = "sounds/GoldKingZ/Training/bell_normal.vsnd_c";
106+
KS_BodyKillSoundPath = "sounds/GoldKingZ/Training/timer_bell.vsnd_c";
107+
KS_HeadShotHitSoundPath = "sounds/GoldKingZ/Training/bell_impact.vsnd_c";
108+
KS_BodyHitSoundPath = "sounds/GoldKingZ/Training/timer_bell.vsnd_c";
109+
empty2 = "-----------------------------------------------------------------------------------";
110+
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";
111+
}
112+
}
113+
}
114+
}

Config/Globals.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using CounterStrikeSharp.API.Core;
2+
using System.Diagnostics;
3+
4+
namespace Kill_Sound_GoldKingZ;
5+
6+
public class Globals
7+
{
8+
public static int Takefreezetime;
9+
public static Stopwatch Timers = new Stopwatch();
10+
public static bool First_Blood = false;
11+
public static Dictionary<ulong, int> Kill_Streak = new Dictionary<ulong, int>();
12+
public static Dictionary<ulong, int> Kill_StreakHS = new Dictionary<ulong, int>();
13+
public static Dictionary<ulong, int> Kill_Knife = new Dictionary<ulong, int>();
14+
public static Dictionary<ulong, int> Kill_Nade = new Dictionary<ulong, int>();
15+
public static Dictionary<ulong, int> Kill_Molly = new Dictionary<ulong, int>();
16+
public static Dictionary<ulong, DateTime> lastPlayTimes = new Dictionary<ulong, DateTime>();
17+
public static Dictionary<ulong, DateTime> lastPlayTimesHS = new Dictionary<ulong, DateTime>();
18+
public static Dictionary<ulong, DateTime> lastPlayTimesKnife = new Dictionary<ulong, DateTime>();
19+
public static Dictionary<ulong, DateTime> lastPlayTimesNade = new Dictionary<ulong, DateTime>();
20+
public static Dictionary<ulong, DateTime> lastPlayTimesMolly = new Dictionary<ulong, DateTime>();
21+
}

0 commit comments

Comments
 (0)