Skip to content

Commit b4a461f

Browse files
committed
Update v1.2.4
1 parent 306159b commit b4a461f

File tree

16 files changed

+383
-328
lines changed

16 files changed

+383
-328
lines changed

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build results
2+
[Bb]in/
3+
[Oo]bj/
4+
5+
# User-specific files
6+
*.suo
7+
*.user
8+
*.userosscache
9+
*.sln.docstates
10+
*.sln
11+
12+
# OS-specific files
13+
*.DS_Store
14+
*.Thumbs.db
15+
16+
# Package files
17+
*.nupkg
18+
*.snupkg

source/Deathmatch/API.cs

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using CounterStrikeSharp.API;
12
using CounterStrikeSharp.API.Modules.Utils;
23
using DeathmatchAPI;
34
using DeathmatchAPI.Events;
@@ -26,7 +27,7 @@ public void StartCustomMode(int modeId)
2627
SetupCustomMode(modeId.ToString());
2728
}
2829

29-
public void ChangeNextMode(int modeId)
30+
public void SetNextMode(int modeId)
3031
{
3132
if (!Config.CustomModes.ContainsKey(modeId.ToString()))
3233
throw new Exception($"A Custom mode with ID '{modeId}' cannot be set as next mode, because this mode does not exist!");
@@ -42,36 +43,12 @@ public void AddCustomMode(int modeId, ModeData mode)
4243
Config.CustomModes.Add(modeId.ToString(), mode);
4344
}
4445

45-
public void ChangeCheckDistance(int distance)
46+
public void SetCheckEnemiesSpawnDistance(int distance)
4647
{
4748
CheckedEnemiesDistance = distance;
4849
}
4950

50-
public void SetupCustomSpawns(string team, Dictionary<Vector, QAngle> spawns)
51-
{
52-
if (team.Equals("ct"))
53-
{
54-
spawnPositionsCT.Clear();
55-
foreach (var spawn in spawns)
56-
{
57-
spawnPositionsCT.Add(spawn.Key, spawn.Value);
58-
}
59-
}
60-
else if (team.Equals("t"))
61-
{
62-
spawnPositionsT.Clear();
63-
foreach (var spawn in spawns)
64-
{
65-
spawnPositionsT.Add(spawn.Key, spawn.Value);
66-
}
67-
}
68-
else
69-
{
70-
throw new Exception($"Invalid team name '{team}'! Allowed options: ct , t");
71-
}
72-
}
73-
74-
public void SwapHudMessageVisibility(bool visible)
51+
public void SetHudMessageVisibility(bool visible)
7552
{
7653
VisibleHud = visible;
7754
}
@@ -90,4 +67,31 @@ public Dictionary<string, ModeData> GetCustomModes()
9067
{
9168
return Config.CustomModes;
9269
}
70+
71+
public int GetDefaultCheckDistance()
72+
{
73+
return Config.Gameplay.DistanceRespawn;
74+
}
75+
76+
public void SetupCustomSpawns(List<SpawnData> spawns, bool clearSpawnsDictionary)
77+
{
78+
if (clearSpawnsDictionary)
79+
{
80+
spawnPositionsCT.Clear();
81+
spawnPositionsT.Clear();
82+
}
83+
84+
foreach (var data in spawns)
85+
{
86+
switch (data.Team)
87+
{
88+
case CsTeam.CounterTerrorist:
89+
spawnPositionsCT[data.Position] = data.Angle;
90+
break;
91+
case CsTeam.Terrorist:
92+
spawnPositionsT[data.Position] = data.Angle;
93+
break;
94+
}
95+
}
96+
}
9397
}

source/Deathmatch/Common/Classes.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ namespace Deathmatch
55
{
66
public partial class Deathmatch
77
{
8-
public class SpawnData
9-
{
10-
public required string team { get; set; }
11-
public required string pos { get; set; }
12-
public required string angle { get; set; }
13-
}
14-
158
public class DeathmatchPlayerData
169
{
1710
public Dictionary<string, string> PrimaryWeapon { get; set; } = new();

source/Deathmatch/Common/Collections.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial class Deathmatch
1212
public static Dictionary<Vector, QAngle> spawnPositionsCT = new();
1313
public static Dictionary<Vector, QAngle> spawnPositionsT = new();
1414
public static Dictionary<int, Vector> blockedSpawns = new();
15-
public static PlayerCache<DeathmatchPlayerData> playerData = new();
15+
public static Dictionary<int, DeathmatchPlayerData> playerData = new();
1616
public static List<PreferencesData> Preferences = new();
1717
public static List<CDynamicProp> savedSpawnsModel = new();
1818
public static List<CPointWorldText> savedSpawnsVectorText = new();
@@ -51,6 +51,17 @@ public partial class Deathmatch
5151
"negative", "enemydown", "sorry", "cheer", "compliment",
5252
"thanks", "go_a", "go_b", "needrop", "deathcry"
5353
};
54-
};
5554

55+
readonly string[] PointsMessagesArray =
56+
{
57+
"Player_Point_Award_Killed_Enemy",
58+
"Player_Point_Award_Killed_Enemy_Plural",
59+
"Player_Point_Award_Assist_Enemy",
60+
"Player_Point_Award_Assist_Enemy_Plural",
61+
"Player_Point_Award_Killed_Enemy_Noweapon",
62+
"Player_Point_Award_Killed_Enemy_Noweapon_Plural",
63+
"Player_Point_Award_Picked_Up_Dogtag",
64+
"Player_Point_Award_Picked_Up_Dogtag_Plural"
65+
};
66+
};
5667
}

source/Deathmatch/Configs.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ public class Gameplay
161161
[JsonPropertyName("Allow Buymenu")] public bool AllowBuyMenu { get; set; } = true;
162162
[JsonPropertyName("Use Default Spawns")] public bool DefaultSpawns { get; set; } = false;
163163
[JsonPropertyName("Respawn Players After New Mode")] public bool RespawnPlayersAtNewMode { get; set; } = false;
164-
[JsonPropertyName("Spawn Protection Color")] public string SpawnProtectionColor { get; set; } = "#FFFFFF";
164+
[JsonPropertyName("Fast Weapon Equip")] public bool FastWeaponEquip { get; set; } = true;
165+
[JsonPropertyName("Spawn Protection Color")] public string SpawnProtectionColor { get; set; } = "";
165166
}
166167
public class General
167168
{
@@ -172,6 +173,7 @@ public class General
172173
[JsonPropertyName("Block Player ChatWheel")] public bool BlockPlayerChatWheel { get; set; } = true;
173174
[JsonPropertyName("Remove Breakable Entities")] public bool RemoveBreakableEntities { get; set; } = true;
174175
[JsonPropertyName("Remove Decals")] public bool RemoveDecals { get; set; } = true;
176+
[JsonPropertyName("Remove Kill Points Message")] public bool RemovePointsMessage { get; set; } = true;
175177
[JsonPropertyName("Force Map End")] public bool ForceMapEnd { get; set; } = false;
176178
[JsonPropertyName("Restart Map On Plugin Load")] public bool RestartMapOnPluginLoad { get; set; } = false;
177179
}

source/Deathmatch/Deathmatch.cs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public partial class Deathmatch : BasePlugin, IPluginConfig<DeathmatchConfig>
1818
{
1919
public override string ModuleName => "Deathmatch Core";
2020
public override string ModuleAuthor => "Nocky";
21-
public override string ModuleVersion => "1.2.3";
21+
public override string ModuleVersion => "1.2.4";
2222

2323
public void OnConfigParsed(DeathmatchConfig config)
2424
{
@@ -110,7 +110,7 @@ public override void Load(bool hotReload)
110110
}
111111
SetupCustomMode(NextMode.ToString());
112112
}
113-
if (!string.IsNullOrEmpty(ActiveMode.CenterMessageText) && Config.CustomModes.TryGetValue(NextMode.ToString(),out var modeData))
113+
if (!string.IsNullOrEmpty(ActiveMode.CenterMessageText) && Config.CustomModes.TryGetValue(NextMode.ToString(), out var modeData))
114114
{
115115
var time = TimeSpan.FromSeconds(RemainingTime);
116116
var formattedTime = $"{time.Minutes}:{time.Seconds:D2}";//RemainingTime > 60 ? $"{time.Minutes}:{time.Seconds:D2}" : $"{time.Seconds}";
@@ -137,7 +137,7 @@ public override void Load(bool hotReload)
137137
}
138138
else
139139
{
140-
if (!GetPrefsValue(p.Slot, "HudMessages") || MenuManager.GetActiveMenu(p) != null)
140+
if ((Config.PlayersPreferences.HudMessages.Enabled && !GetPrefsValue(p.Slot, "HudMessages")) || MenuManager.GetActiveMenu(p) != null)
141141
continue;
142142

143143
if (!string.IsNullOrEmpty(ActiveMode.CenterMessageText))
@@ -179,6 +179,29 @@ public override void Load(bool hotReload)
179179
}, HookMode.Pre);
180180
}
181181

182+
if (Config.General.RemovePointsMessage)
183+
{
184+
HookUserMessage(124, um =>
185+
{
186+
if (IsCasualGamemode)
187+
return HookResult.Continue;
188+
189+
for (int i = 0; i < um.GetRepeatedFieldCount("param"); i++)
190+
{
191+
var message = um.ReadString("param", i);
192+
foreach (var msg in PointsMessagesArray)
193+
{
194+
if (message.Contains(msg))
195+
{
196+
return HookResult.Stop;
197+
}
198+
}
199+
200+
}
201+
return HookResult.Continue;
202+
}, HookMode.Pre);
203+
}
204+
182205
if (hotReload)
183206
{
184207
Server.ExecuteCommand($"map {Server.MapName}");
@@ -206,7 +229,7 @@ public void SetupCustomMode(string modeId)
206229
ActiveCustomMode = modeId;
207230
NextMode = GetModeType();
208231

209-
if (Config.CustomModes.TryGetValue(NextMode.ToString(),out var modeData) && !string.IsNullOrEmpty(ActiveMode.CenterMessageText))
232+
if (Config.CustomModes.TryGetValue(NextMode.ToString(), out var modeData) && !string.IsNullOrEmpty(ActiveMode.CenterMessageText))
210233
{
211234
ModeCenterMessage = ActiveMode.CenterMessageText.Replace("{NEXTMODE}", modeData.Name);
212235
ModeCenterMessage = ModeCenterMessage.Replace("{REMAININGTIME}", RemainingTime.ToString());
@@ -215,7 +238,7 @@ public void SetupCustomMode(string modeId)
215238

216239
Server.NextFrame(() =>
217240
{
218-
DeathmatchAPI.Get()?.TriggerEvent(new OnCustomModeStarted(int.Parse(ActiveCustomMode)));
241+
DeathmatchAPI.Get()?.TriggerEvent(new OnCustomModeStarted(int.Parse(ActiveCustomMode), ActiveMode));
219242
});
220243
}
221244

source/Deathmatch/Deathmatch.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
78
</PropertyGroup>
89

910
<ItemGroup>

0 commit comments

Comments
 (0)