Skip to content

Commit

Permalink
Added ExecutedCommands for Custom Modes
Browse files Browse the repository at this point in the history
  • Loading branch information
NockyCZ committed Apr 27, 2024
1 parent 2692bc1 commit e1d2468
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Custom Modes Examples/Only_AK47.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"weapon_ak47"
],
"SecondaryWeapons": [],
"Utilities": []
"Utilities": [],
"ExecuteCommands": []
}
```

3 changes: 2 additions & 1 deletion Custom Modes Examples/Only_awp.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"SecondaryWeapons": [],
"Utilities": [
"weapon_flashbang"
]
],
"ExecuteCommands": []
}
```
3 changes: 2 additions & 1 deletion Custom Modes Examples/Only_pistols.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"Utilities": [
"weapon_flashbang",
"weapon_hegrenade
]
],
"ExecuteCommands": []
}
```

3 changes: 2 additions & 1 deletion Custom Modes Examples/Only_rifles.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"weapon_sg556"
],
"SecondaryWeapons": [],
"Utilities": []
"Utilities": [],
"ExecuteCommands": []
}
```
3 changes: 2 additions & 1 deletion Custom Modes Examples/Only_shotguns.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"weapon_xm1014"
],
"SecondaryWeapons": [],
"Utilities": []
"Utilities": [],
"ExecuteCommands": []
}
```
1 change: 1 addition & 0 deletions source/Common/Classes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ModeData
public List<string>? PrimaryWeapons { get; set; }
public List<string>? SecondaryWeapons { get; set; }
public List<string>? Utilities { get; set; }
public List<string>? ExecuteCommands { get; set; }
}

public class DeathmatchPlayerData
Expand Down
7 changes: 7 additions & 0 deletions source/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public class CustomModes
Utilities = new List<string> {
"weapon_flashbang"
},
ExecuteCommands = new List<string>()
};

[JsonPropertyName("1")]
Expand All @@ -184,6 +185,8 @@ public class CustomModes
"weapon_usp_silencer", "weapon_p250", "weapon_glock",
"weapon_fiveseven", "weapon_hkp2000", "weapon_deagle"
},
Utilities = new List<string>(),
ExecuteCommands = new List<string>()
};

[JsonPropertyName("2")]
Expand All @@ -203,6 +206,7 @@ public class CustomModes
Utilities = new List<string> {
"weapon_flashbang" , "weapon_healthshot"
},
ExecuteCommands = new List<string>()
};

[JsonPropertyName("3")]
Expand All @@ -221,6 +225,8 @@ public class CustomModes
"weapon_cz75a", "weapon_elite", "weapon_fiveseven",
"weapon_tec9", "weapon_hkp2000"
},
Utilities = new List<string>(),
ExecuteCommands = new List<string>()
};

[JsonPropertyName("4")]
Expand All @@ -242,6 +248,7 @@ public class CustomModes
Utilities = new List<string> {
"weapon_hegrenade", "weapon_flashbang", "weapon_healthshot"
},
ExecuteCommands = new List<string>()
};
}

Expand Down
8 changes: 7 additions & 1 deletion source/Deathmatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ public void SetupDeathmatchConfiguration(ModeData mode, bool isNewMode)
Server.PrintToChatAll($"{Localizer["Chat.Prefix"]} {Localizer["Chat.NewModeStarted", mode.Name]}");

Server.ExecuteCommand($"mp_free_armor {mode.Armor};mp_damage_headshot_only {mode.OnlyHS};mp_ct_default_primary \"\";mp_t_default_primary \"\";mp_ct_default_secondary \"\";mp_t_default_secondary \"\"");


if (mode.ExecuteCommands != null && mode.ExecuteCommands.Count > 0)
{
foreach (var cmd in mode.ExecuteCommands)
Server.ExecuteCommand(cmd);
}

foreach (var p in Utilities.GetPlayers().Where(p => p != null && p.IsValid && p.PawnIsAlive))
{
p.RemoveWeapons();
Expand Down

0 comments on commit e1d2468

Please sign in to comment.