Skip to content

Commit

Permalink
Update v1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
NockyCZ committed Feb 21, 2024
1 parent debe2cf commit f23feeb
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 72 deletions.
4 changes: 2 additions & 2 deletions source/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class PlayersPreferences
[JsonPropertyName("Headshot Kill Sound")] public HSKillSound HSKillSound { get; set; } = new HSKillSound();
[JsonPropertyName("Knife Kill Sound")] public KnifeKillSound KnifeKillSound { get; set; } = new KnifeKillSound();
[JsonPropertyName("Hit Sound")] public HitSound HitSound { get; set; } = new HitSound();
[JsonPropertyName("Only Headsnhot")] public OnlyHS OnlyHS { get; set; } = new OnlyHS();
[JsonPropertyName("Only Headshot")] public OnlyHS OnlyHS { get; set; } = new OnlyHS();
[JsonPropertyName("Hud Messages")] public HudMessages HudMessages { get; set; } = new HudMessages();
}
// sounds/ui/beepclear.vsnd_c
Expand Down Expand Up @@ -147,7 +147,7 @@ public static void CreateOrLoadCvars(string filepath)
{
using (StreamWriter writer = new StreamWriter(filepath))
{
writer.Write("sv_disable_radar 1\nmp_give_player_c4 0\nmp_playercashawards 0\nmp_teamcashawards 0\nmp_weapons_allow_zeus 0\nmp_buy_allow_grenades 0\nmp_max_armor 0\nmp_freezetime 0\nmp_death_drop_grenade 0\nmp_death_drop_gun 0\nmp_death_drop_healthshot 0\nmp_drop_grenade_enable 0\nmp_death_drop_c4 0\nmp_death_drop_taser 0\nmp_defuser_allocation 0\nmp_solid_teammates 0\nmp_weapons_allow_typecount -1\nmp_hostages_max 0");
writer.Write("sv_disable_radar 1\nmp_give_player_c4 0\nmp_playercashawards 0\nmp_teamcashawards 0\nmp_weapons_allow_zeus 0\nmp_buy_allow_grenades 0\nmp_max_armor 0\nmp_freezetime 0\nmp_death_drop_grenade 0\nmp_death_drop_gun 0\nmp_death_drop_healthshot 0\nmp_drop_grenade_enable 0\nmp_death_drop_c4 0\nmp_death_drop_taser 0\nmp_defuser_allocation 0\nmp_solid_teammates 1\nmp_weapons_allow_typecount -1\nmp_hostages_max 0");
}
CustomCvarsList = new List<string>(File.ReadLines(filepath));
}
Expand Down
2 changes: 1 addition & 1 deletion source/Deathmatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class DeathmatchCore : BasePlugin, IPluginConfig<DeathmatchConfig
{
public override string ModuleName => "Deathmatch Core";
public override string ModuleAuthor => "Nocky";
public override string ModuleVersion => "1.0.6";
public override string ModuleVersion => "1.0.7";
public static DeathmatchCore Instance { get; set; } = new();
public class ModeInfo
{
Expand Down
133 changes: 65 additions & 68 deletions source/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
CCSPlayerController player = @event.Userid;
if (player != null && player.IsValid)
GivePlayerWeapons(player, false);

return HookResult.Continue;
}
[GameEventHandler(HookMode.Pre)]
Expand All @@ -58,7 +58,7 @@ public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
{
if (ModeData.OnlyHS)
{
if (@event.Hitgroup == 1 && !@event.Weapon.Contains("knife") && playerData[attacker].HitSound)
if (@event.Hitgroup == 1 && (!@event.Weapon.Contains("knife") || !@event.Weapon.Contains("bayonet")) && playerData[attacker].HitSound)
attacker.ExecuteClientCommand("play " + Config.PlayersPreferences.HitSound.Path);
}
else
Expand All @@ -70,7 +70,7 @@ public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
player.PlayerPawn.Value!.Health = player.PlayerPawn.Value.Health >= 100 ? 100 : player.PlayerPawn.Value.Health + @event.DmgHealth;
player.PlayerPawn.Value.ArmorValue = player.PlayerPawn.Value.ArmorValue >= 100 ? 100 : player.PlayerPawn.Value.ArmorValue + @event.DmgArmor;
}
else if (playerData[attacker].HitSound && !@event.Weapon.Contains("knife"))
else if (playerData[attacker].HitSound && (!@event.Weapon.Contains("knife") || !@event.Weapon.Contains("bayonet")))
attacker.ExecuteClientCommand("play " + Config.PlayersPreferences.HitSound.Path);
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ private HookResult OnTakeDamage(DynamicHook hook)
{
damageInfo.Damage = 0;
}
if (!ModeData.KnifeDamage && damageInfo.Ability.IsValid && damageInfo.Ability.Value!.DesignerName.Contains("knife"))
if (!ModeData.KnifeDamage && damageInfo.Ability.IsValid && (damageInfo.Ability.Value!.DesignerName.Contains("knife") || damageInfo.Ability.Value!.DesignerName.Contains("bayonet")))
{
attacker.PrintToCenter(Localizer["Knife_damage_disabled"]);
damageInfo.Damage = 0;
Expand All @@ -233,99 +233,96 @@ private HookResult OnWeaponCanAcquire(DynamicHook hook)
if (player == null || !player.IsValid || !player.PawnIsAlive)
return HookResult.Continue;

if (hook.GetParam<AcquireMethod>(2) == AcquireMethod.PickUp)
{
if (!AllowedPrimaryWeaponsList.Contains(vdata!.Name!) && !AllowedSecondaryWeaponsList.Contains(vdata.Name))
{
if (vdata.Name.Contains("knife") || vdata.Name.Contains("bayonet"))
return HookResult.Continue;

hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}
return HookResult.Continue;
}

if (ModeData.RandomWeapons)
{
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Select_Is_Disabled"]}");
hook.SetReturn(AcquireResult.AlreadyPurchased);
return HookResult.Stop;
}

if (!AllowedPrimaryWeaponsList.Contains(vdata!.Name!) && !AllowedSecondaryWeaponsList.Contains(vdata.Name))
{
if (vdata.Name.Contains("knife"))
/*if (vdata.Name.Contains("knife") || vdata.Name.Contains("bayonet"))
{
if (player.IsBot)
{
hook.SetReturn(AcquireResult.AlreadyPurchased);
return HookResult.Stop;
}
return HookResult.Continue;
}

}*/
if (!player.IsBot)
{
if (ModeData.RandomWeapons)
{
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Select_Is_Disabled"]}");
hook.SetReturn(AcquireResult.AlreadyPurchased);
return HookResult.Stop;
}
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);

string replacedweaponName = Localizer[vdata.Name];
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Disabled", replacedweaponName]}");
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);
}
hook.SetReturn(AcquireResult.AlreadyPurchased);
return HookResult.Stop;
}
if (hook.GetParam<AcquireMethod>(2) != AcquireMethod.PickUp)

if (playerData.ContainsPlayer(player))
{
if (playerData.ContainsPlayer(player))
string localizerWeaponName = Localizer[vdata.Name];
if (CheckIsWeaponRestricted(vdata.Name, AdminManager.PlayerHasPermissions(player, Config.PlayersSettings.VIPFlag), player.TeamNum))
{
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);

RestrictedWeaponsInfo restrict = RestrictedWeapons[vdata.Name];
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Is_Restricted", localizerWeaponName, restrict.nonVIPRestrict, restrict.VIPRestrict]}");
hook.SetReturn(AcquireResult.NotAllowedByMode);
return HookResult.Stop;
}

bool IsPrimary = AllowedPrimaryWeaponsList.Contains(vdata.Name);
if (IsPrimary)
{
if (ModeData.RandomWeapons)
if (vdata.Name == playerData[player].PrimaryWeapon)
{
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Select_Is_Disabled"]}");
hook.SetReturn(AcquireResult.AlreadyPurchased);
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Is_Already_Set", localizerWeaponName]}");
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}

string localizerWeaponName = Localizer[vdata.Name];
if (CheckIsWeaponRestricted(vdata.Name, AdminManager.PlayerHasPermissions(player, Config.PlayersSettings.VIPFlag), player.TeamNum))
playerData[player].PrimaryWeapon = vdata.Name;
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["PrimaryWeapon_Set", localizerWeaponName]}");
if (!Config.Gameplay.SwitchWeapons && IsHaveWeaponFromSlot(player, 1) == 1)
{
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);
RestrictedWeaponsInfo restrict = RestrictedWeapons[vdata.Name];
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Is_Restricted", localizerWeaponName, restrict.nonVIPRestrict, restrict.VIPRestrict]}");
hook.SetReturn(AcquireResult.NotAllowedByMode);
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}

bool IsPrimary = AllowedPrimaryWeaponsList.Contains(vdata.Name);
if (IsPrimary)
}
else
{
if (vdata.Name == playerData[player].SecondaryWeapon)
{
if (vdata.Name == playerData[player].PrimaryWeapon)
{
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Is_Already_Set", localizerWeaponName]}");
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}
playerData[player].PrimaryWeapon = vdata.Name;
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["PrimaryWeapon_Set", localizerWeaponName]}");
if (!Config.Gameplay.SwitchWeapons && IsHaveWeaponFromSlot(player, 1) == 1)
{
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}
return HookResult.Continue;
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Is_Already_Set", localizerWeaponName]}");
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}
else
playerData[player].SecondaryWeapon = vdata.Name;
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["SecondaryWeapon_Set", localizerWeaponName]}");
if (!Config.Gameplay.SwitchWeapons && IsHaveWeaponFromSlot(player, 2) == 2)
{
if (vdata.Name == playerData[player].SecondaryWeapon)
{
if (!string.IsNullOrEmpty(Config.SoundSettings.CantEquipSound))
player.ExecuteClientCommand("play " + Config.SoundSettings.CantEquipSound);
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["Weapon_Is_Already_Set", localizerWeaponName]}");
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}
playerData[player].SecondaryWeapon = vdata.Name;
player.PrintToChat($"{Localizer["Prefix"]} {Localizer["SecondaryWeapon_Set", localizerWeaponName]}");
if (!Config.Gameplay.SwitchWeapons && IsHaveWeaponFromSlot(player, 2) == 2)
{
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}
return HookResult.Continue;
hook.SetReturn(AcquireResult.AlreadyOwned);
return HookResult.Stop;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Functions/Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void OpenSubMenu(CCSPlayerController player, int menu, bool solo = false)
Menu.AddMenuOption($"{Localizer[options.Item1]} [{Value}]", (player, opt) => OnSelectSwitchPref(player, opt, options.Item3, solo));
}
}
if (solo)
if (!solo)
Menu.AddMenuOption($"{Localizer["Menu.Back"]}", OnSelectBack);

MenuManager.OpenCenterHtmlMenu(DeathmatchCore.Instance, player!, Menu);
Expand Down

0 comments on commit f23feeb

Please sign in to comment.