Skip to content

Commit 5909a2b

Browse files
Merge pull request #257 from shobhit-pathak/dev
0.8.7
2 parents 1fb8c7d + fac90ec commit 5909a2b

File tree

13 files changed

+227
-67
lines changed

13 files changed

+227
-67
lines changed

BackupManagement.cs

Lines changed: 158 additions & 58 deletions
Large diffs are not rendered by default.

ConfigConvars.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public partial class MatchZy
1313

1414
public FakeConVar<bool> smokeColorEnabled = new("matchzy_smoke_color_enabled", "Whether player-specific smoke color is enabled or not. Default: false", false);
1515
public FakeConVar<bool> techPauseEnabled = new("matchzy_enable_tech_pause", "Whether .tech command is enabled or not. Default: true", true);
16+
public FakeConVar<string> techPausePermission = new("matchzy_tech_pause_flag", "Flag required to use tech pause", "");
1617
public FakeConVar<int> techPauseDuration = new("matchzy_tech_pause_duration", "Tech pause duration in seconds. Default value: 300", 300);
1718

1819
public FakeConVar<int> maxTechPausesAllowed = new("matchzy_max_tech_pauses_allowed", " Max tech pauses allowed. Default value: 2", 2);

MatchZy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public partial class MatchZy : BasePlugin
1313
{
1414

1515
public override string ModuleName => "MatchZy";
16-
public override string ModuleVersion => "0.8.6";
16+
public override string ModuleVersion => "0.8.7";
1717

1818
public override string ModuleAuthor => "WD- (https://github.com/shobhit-pathak/)";
1919

MatchZy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.263">
10+
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.291">
1111
<PrivateAssets>none</PrivateAssets>
1212
<ExcludeAssets>runtime</ExcludeAssets>
1313
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

PracticeMode.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,26 @@ public class Position
1717

1818
public Vector PlayerPosition { get; private set; }
1919
public QAngle PlayerAngle { get; private set; }
20+
21+
// Copy constructor
22+
public Position(Position other)
23+
{
24+
PlayerPosition = other.PlayerPosition;
25+
PlayerAngle = other.PlayerAngle;
26+
}
27+
2028
public Position(Vector playerPosition, QAngle playerAngle)
2129
{
2230
// Create deep copies of the Vector and QAngle objects
2331
PlayerPosition = new Vector(playerPosition.X, playerPosition.Y, playerPosition.Z);
2432
PlayerAngle = new QAngle(playerAngle.X, playerAngle.Y, playerAngle.Z);
2533
}
2634

35+
public void Teleport(CCSPlayerController player)
36+
{
37+
player!.PlayerPawn.Value!.Teleport(PlayerPosition, PlayerAngle, new Vector(0, 0, 0));
38+
}
39+
2740
public override bool Equals(object? obj)
2841
{
2942
if (obj == null || GetType() != obj.GetType())

Utility.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ private int GetRoundNumer()
10291029

10301030
public void HandlePostRoundStartEvent(EventRoundStart @event)
10311031
{
1032+
if (isDryRun) RandomizeSpawns();
10321033
if (!matchStarted) return;
10331034
playerHasTakenDamage = false;
10341035
HandleCoaches();
@@ -1170,6 +1171,19 @@ private void PauseMatch(CCSPlayerController? player, CommandInfo? command)
11701171
ReplyToUserCommand(player, Localizer["matchzy.utility.tacticaltimeout"]);
11711172
return;
11721173
}
1174+
if (!techPauseEnabled.Value && player != null)
1175+
{
1176+
PrintToPlayerChat(player, Localizer["matchzy.pause.techpausenotenabled"]);
1177+
return;
1178+
}
1179+
if(!string.IsNullOrEmpty(techPausePermission.Value))
1180+
{
1181+
if (!IsPlayerAdmin(player, "css_pause", techPausePermission.Value))
1182+
{
1183+
SendPlayerNotAdminMessage(player);
1184+
return;
1185+
}
1186+
}
11731187
if (isMatchLive && !isPaused)
11741188
{
11751189

@@ -2013,5 +2027,31 @@ public void DropWeaponByDesignerName(CCSPlayerController player, string weaponNa
20132027
player.DropActiveWeapon();
20142028
}
20152029
}
2030+
2031+
public void RandomizeSpawns()
2032+
{
2033+
List<CCSPlayerController> players = Utilities.GetPlayers();
2034+
2035+
Dictionary<byte, List<Position>> teamSpawns = new()
2036+
{
2037+
{ (byte)CsTeam.CounterTerrorist, spawnsData[(byte)CsTeam.CounterTerrorist].Select(position => new Position(position)).ToList() },
2038+
{ (byte)CsTeam.Terrorist, spawnsData[(byte)CsTeam.Terrorist].Select(position => new Position(position)).ToList() }
2039+
};
2040+
2041+
Random random = new();
2042+
2043+
foreach (var player in players)
2044+
{
2045+
if (!IsPlayerValid(player)) continue;
2046+
2047+
if (teamSpawns[player.TeamNum].Count == 0) break;
2048+
2049+
int randomIndex = random.Next(teamSpawns[player.TeamNum].Count);
2050+
Position spawnPosition = teamSpawns[player.TeamNum][randomIndex];
2051+
teamSpawns[player.TeamNum].RemoveAt(randomIndex);
2052+
2053+
spawnPosition.Teleport(player);
2054+
}
2055+
}
20162056
}
20172057
}

cfg/MatchZy/config.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ matchzy_use_pause_command_for_tactical_pause false
3939
// Default value: true
4040
matchzy_enable_tech_pause true
4141

42+
// Flag required to use tech pause. Blank for anyone
43+
// Default value: ""
44+
matchzy_tech_pause_flag ""
45+
4246
// Tech pause duration in seconds. Set -1 to keep it infinite.
4347
// Default value: 300
4448
matchzy_tech_pause_duration 300
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

cfg/MatchZy/live.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ mp_disconnect_kills_players 0
112112
mp_warmup_end
113113

114114
// execute override config
115-
exec live_override.cfg
115+
exec MatchZy/live_override.cfg

cfg/MatchZy/live_override.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)