diff --git a/jRandomSkills - SRC Files/src/command/Command.cs b/jRandomSkills - SRC Files/src/command/Command.cs index 7e9bbcc..e45902b 100644 --- a/jRandomSkills - SRC Files/src/command/Command.cs +++ b/jRandomSkills - SRC Files/src/command/Command.cs @@ -12,25 +12,25 @@ namespace jRandomSkills public static class Command { private static bool gamePaused = false; + private static readonly Config.Settings config = Config.LoadedConfig.Settings; public static void Load() { - var config = Config.LoadedConfig?.Settings; if (config == null || config == null) return; - var commands = new Dictionary, (string description, CommandInfo.CommandCallback handler)> { - { SplitCommands(config.SetSkillCommands), ("Set skill", Command_SetSkill) }, - { SplitCommands(config.SkillsListCommands), ("Delete all records", Command_SkillsListMenu) }, - { SplitCommands(config.UseSkillCommands), ("Use/Type skill", Command_UseTypeSkill) }, - { SplitCommands(config.ChangeMapCommands), ("Change map", Command_ChangeMap) }, - { SplitCommands(config.ConsoleCommands), ("Console command", Command_CustomCommand) }, - { SplitCommands(config.StartGameCommands), ("Start game", Command_StartGame) }, - { SplitCommands(config.SwapCommands), ("Swap team", Command_Swap) }, - { SplitCommands(config.ShuffleCommands), ("Shuffle team", Command_Shuffle) }, - { SplitCommands(config.PauseCommands), ("Pause game", Command_Pause) }, - { SplitCommands(config.HealCommands), ("Heal", Command_Heal) }, - { SplitCommands(config.SetScoreCommands), ("Set teams score", Command_SetScore) }, + { SplitCommands(config.SetSkillCommands.Alias), ("Set skill", Command_SetSkill) }, + { SplitCommands(config.SkillsListCommands.Alias), ("Delete all records", Command_SkillsListMenu) }, + { SplitCommands(config.UseSkillCommands.Alias), ("Use/Type skill", Command_UseTypeSkill) }, + { SplitCommands(config.ChangeMapCommands.Alias), ("Change map", Command_ChangeMap) }, + { SplitCommands(config.ConsoleCommands.Alias), ("Console command", Command_CustomCommand) }, + { SplitCommands(config.StartGameCommands.Alias), ("Start game", Command_StartGame) }, + { SplitCommands(config.SwapCommands.Alias), ("Swap team", Command_Swap) }, + { SplitCommands(config.ShuffleCommands.Alias), ("Shuffle team", Command_Shuffle) }, + { SplitCommands(config.PauseCommands.Alias), ("Pause game", Command_Pause) }, + { SplitCommands(config.HealCommands.Alias), ("Heal", Command_Heal) }, + { SplitCommands(config.SetScoreCommands.Alias), ("Set teams score", Command_SetScore) }, + { SplitCommands(config.SetStaticSkillCommands.Alias), ("Set static skill", Command_SetStaticSkill) }, }; foreach (var commandPair in commands) @@ -40,7 +40,7 @@ namespace jRandomSkills private static IEnumerable SplitCommands(string commands) { - return commands.Split(',').Select(c => c.Trim()); + return commands.Split(',').Select(c => c.Trim()).Where(c => !string.IsNullOrEmpty(c)); } [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)] @@ -62,11 +62,11 @@ namespace jRandomSkills Instance.SkillAction(playerInfo.Skill.ToString(), "TypeSkill", [player, commands]); } - [RequiresPermissions("@jRandmosSkills/admin")] - [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)] + [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_SetSkill(CCSPlayerController? player, CommandInfo command) { - if (player == null) return; + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_setskill {command.ArgString} command."); + if (player == null || !AdminManager.PlayerHasPermissions(player, config.SetSkillCommands.Permissions)) return; var targetPlayer = Utilities.GetPlayers().FirstOrDefault(p => !p.IsBot && (p.SteamID.ToString().Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase) || p.PlayerName.Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase)) ); @@ -103,6 +103,7 @@ namespace jRandomSkills { Instance.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", [targetPlayer]); skillPlayer.Skill = skill.Skill; + skillPlayer.SpecialSkill = src.player.Skills.None; Instance.SkillAction(skill.Skill.ToString(), "EnableSkill", [targetPlayer]); player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); @@ -120,16 +121,18 @@ namespace jRandomSkills [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)] private static void Command_SkillsListMenu(CCSPlayerController? player, CommandInfo command) { - if (player == null) return; - + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_skills {command.ArgString} command."); + if (player == null || !AdminManager.PlayerHasPermissions(player, config.SkillsListCommands.Permissions)) return; Menu.DisplaySkillsList(player); } [CommandHelper(minArgs: 1, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_ChangeMap(CCSPlayerController? player, CommandInfo command) { - if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD")) + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_map {command.ArgString} command."); + if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.ChangeMapCommands.Permissions)) { + if (!config.ChangeMapCommands.EnableVoting) return; player.Vote(VoteType.ChangeMap, command.ArgString); return; } @@ -159,8 +162,10 @@ namespace jRandomSkills [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_StartGame(CCSPlayerController? player, CommandInfo command) { - if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD")) + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_start {command.ArgString} command."); + if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.StartGameCommands.Permissions)) { + if (!config.StartGameCommands.EnableVoting) return; player.Vote(VoteType.StartGame); return; } @@ -186,8 +191,10 @@ namespace jRandomSkills [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_Swap(CCSPlayerController? player, CommandInfo command) { - if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD")) + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_swap {command.ArgString} command."); + if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.SwapCommands.Permissions)) { + if (!config.SwapCommands.EnableVoting) return; player.Vote(VoteType.SwapTeam); return; } @@ -205,8 +212,10 @@ namespace jRandomSkills [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_Shuffle(CCSPlayerController? player, CommandInfo command) { - if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD")) + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_shuffle {command.ArgString} command."); + if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.ShuffleCommands.Permissions)) { + if (!config.ShuffleCommands.EnableVoting) return; player.Vote(VoteType.ShuffleTeam); return; } @@ -229,8 +238,10 @@ namespace jRandomSkills [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_Pause(CCSPlayerController? player, CommandInfo command) { - if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@TESTTEST/TESTAFD")) + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_pause {command.ArgString} command."); + if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.PauseCommands.Permissions)) { + if (!config.PauseCommands.EnableVoting) return; player.Vote(VoteType.PauseGame); return; } @@ -244,11 +255,12 @@ namespace jRandomSkills gamePaused = !gamePaused; } - [RequiresPermissions("@jRandmosSkills/root")] [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_Heal(CCSPlayerController? player, CommandInfo command) { + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_heal {command.ArgString} command."); if (player == null || !player.IsValid || player.PlayerPawn.Value == null || !player.PlayerPawn.Value.IsValid || player.LifeState != (byte)LifeState_t.LIFE_ALIVE) return; + if (!AdminManager.PlayerHasPermissions(player, config.HealCommands.Permissions)) return; SkillUtils.AddHealth(player.PlayerPawn.Value, 100); player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("healed")}"); } @@ -256,8 +268,10 @@ namespace jRandomSkills [CommandHelper(minArgs: 2, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_SetScore(CCSPlayerController? player, CommandInfo command) { - if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, "@testset/testset")) + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_setscore {command.ArgString} command."); + if (player != null && player.IsValid && !AdminManager.PlayerHasPermissions(player, config.SetScoreCommands.Permissions)) { + if (!config.SetScoreCommands.EnableVoting) return; player.Vote(VoteType.SetScore, command.ArgString); return; } @@ -276,13 +290,74 @@ namespace jRandomSkills SkillUtils.SetTeamScores((short)ctScore, (short)tScore, RoundEndReason.RoundDraw); } - [RequiresPermissions("@jRandmosSkills/root")] [CommandHelper(minArgs: 1, whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] private static void Command_CustomCommand(CCSPlayerController? player, CommandInfo command) { - if (player == null) return; + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_console {command.ArgString} command."); + if (player == null || !AdminManager.PlayerHasPermissions(player, config.ConsoleCommands.Permissions)) return; string param = command.ArgString; Server.ExecuteCommand(param); } + + [CommandHelper(minArgs: 0, whoCanExecute: CommandUsage.CLIENT_ONLY)] + private static void Command_SetStaticSkill(CCSPlayerController? player, CommandInfo command) + { + Debug.WriteToDebug($"Player {player?.PlayerPawn} used the css_setstaticskill {command.ArgString} command."); + if (player == null || !AdminManager.PlayerHasPermissions(player, config.SetStaticSkillCommands.Permissions)) return; + var targetPlayer = Utilities.GetPlayers().FirstOrDefault(p => !p.IsBot + && (p.SteamID.ToString().Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase) + || p.PlayerName.Equals(command.GetArg(1), StringComparison.CurrentCultureIgnoreCase))); + + if (command.ArgCount < 2) + { + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + SkillUtils.PrintToChat(player, Localization.GetTranslation("correct_form_setskill"), true); + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + return; + } + + if (targetPlayer == null) + { + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + SkillUtils.PrintToChat(player, Localization.GetTranslation("player_not_found_setskill"), true); + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + return; + } + + var skillName = command.ArgCount > 3 ? $"{command.GetArg(2)} {command.GetArg(3)}" : command.GetArg(2); + var skill = SkillData.Skills.FirstOrDefault(s => s.Name.Equals(skillName, StringComparison.OrdinalIgnoreCase) || s.Skill.ToString().Equals(skillName, StringComparison.OrdinalIgnoreCase)); + + if (skill == null) + { + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + SkillUtils.PrintToChat(player, Localization.GetTranslation("skill_not_found_setskill"), true); + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + return; + } + + var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == targetPlayer.SteamID); + if (skillPlayer != null) + { + Instance.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", [targetPlayer]); + skillPlayer.Skill = skill.Skill; + skillPlayer.SpecialSkill = src.player.Skills.None; + + if (skill.Skill == src.player.Skills.None) + Event.staticSkills.Remove(targetPlayer.SteamID); + else + Event.staticSkills.Add(targetPlayer.SteamID, skill); + Instance.SkillAction(skill.Skill.ToString(), "EnableSkill", [targetPlayer]); + + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + SkillUtils.PrintToChat(player, $"{Localization.GetTranslation("done_setskill")}: {ChatColors.LightRed}{skill.Name} {ChatColors.Lime}{Localization.GetTranslation("for_setskill")} {ChatColors.LightRed}{targetPlayer.PlayerName}", false); + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + } + else + { + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + SkillUtils.PrintToChat(player, Localization.GetTranslation("error_setskill"), true); + player.PrintToChat($" {ChatColors.Green}―――――――――――{ChatColors.DarkRed}◥◣◆◢◤{ChatColors.Green}―――――――――――"); + } + } } } \ No newline at end of file diff --git a/jRandomSkills - SRC Files/src/command/VoteSystem.cs b/jRandomSkills - SRC Files/src/command/VoteSystem.cs index 8ebb56e..f6ef9a7 100644 --- a/jRandomSkills - SRC Files/src/command/VoteSystem.cs +++ b/jRandomSkills - SRC Files/src/command/VoteSystem.cs @@ -31,6 +31,7 @@ namespace jRandomSkills { if (!votes.Contains(vote) || !vote.GetActive()) return; vote.SetActive(false); + vote.TimeToNextSameVoting = vote.TimeToNextVoting; Server.PrintToChatAll($" {ChatColors.Red}{Localization.GetTranslation("vote_timeout", commandName)}"); }); diff --git a/jRandomSkills - SRC Files/src/lang/en.json b/jRandomSkills - SRC Files/src/lang/en.json index dff203f..99ec3a8 100644 --- a/jRandomSkills - SRC Files/src/lang/en.json +++ b/jRandomSkills - SRC Files/src/lang/en.json @@ -401,7 +401,7 @@ "skill_not_found_setskill": "No such CHATCOLORS.REDskill found", "player_not_found_setskill": "No such CHATCOLORS.REDplayer found", "correct_form_setskill": "Correct usage: CHATCOLORS.RED!setskill ", - "correct_form_setskill": "Correct usage: CHATCOLORS.RED!setscore ", + "correct_form_setscore": "Correct usage: CHATCOLORS.RED!setscore ", "done_setskill": "skill set", "error_setskill": "Failed to set CHATCOLORS.REDskill", "for_setskill": "for", diff --git a/jRandomSkills - SRC Files/src/player/Debug.cs b/jRandomSkills - SRC Files/src/player/Debug.cs index 71df826..5e39b5c 100644 --- a/jRandomSkills - SRC Files/src/player/Debug.cs +++ b/jRandomSkills - SRC Files/src/player/Debug.cs @@ -3,6 +3,7 @@ using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; using CounterStrikeSharp.API.Modules.Utils; +using static CounterStrikeSharp.API.Core.Listeners; using static jRandomSkills.jRandomSkills; namespace jRandomSkills @@ -80,6 +81,11 @@ namespace jRandomSkills return HookResult.Continue; }); + Instance.RegisterListener((string mapName) => + { + Debug.WriteToDebug($"Map changed: {mapName}."); + }); + Instance.RegisterEventHandler((@event, info) => { var player = @event.Userid; diff --git a/jRandomSkills - SRC Files/src/player/PlayerEvents.cs b/jRandomSkills - SRC Files/src/player/PlayerEvents.cs index 00bd264..0fe19b8 100644 --- a/jRandomSkills - SRC Files/src/player/PlayerEvents.cs +++ b/jRandomSkills - SRC Files/src/player/PlayerEvents.cs @@ -5,17 +5,23 @@ using CounterStrikeSharp.API.Modules.Utils; using jRandomSkills.src.player; using jRandomSkills.src.utils; using System.Text.RegularExpressions; +using static jRandomSkills.Config; using static jRandomSkills.jRandomSkills; namespace jRandomSkills { public static partial class Event { - private static jSkill_SkillInfo ctSkill = new(Skills.None, Config.GetValue(Skills.None, "color"), false); - private static jSkill_SkillInfo tSkill = new(Skills.None, Config.GetValue(Skills.None, "color"), false); - private static jSkill_SkillInfo allSkill = new(Skills.None, Config.GetValue(Skills.None, "color"), false); + private static readonly jSkill_SkillInfo noneSkill = new(Skills.None, Config.GetValue(Skills.None, "color"), false); + + private static jSkill_SkillInfo ctSkill = noneSkill; + private static jSkill_SkillInfo tSkill = noneSkill; + private static jSkill_SkillInfo allSkill = noneSkill; private static List debugSkills = new(SkillData.Skills); + private static readonly Dictionary> playersSkills = []; + public static readonly Dictionary staticSkills = []; + public static void Load() { Instance.RegisterEventHandler((@event, info) => @@ -155,7 +161,10 @@ namespace jRandomSkills if (Instance?.GameRules != null && Instance?.GameRules.WarmupPeriod == false) { - if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.Normal) + Config.GameModes gameMode = (Config.GameModes)Config.LoadedConfig.Settings.GameMode; + if (staticSkills.TryGetValue(player.SteamID, out var staticSkill)) + randomSkill = staticSkill; + else if (gameMode == Config.GameModes.Normal || gameMode == Config.GameModes.NoRepeat) { List skillList = new(SkillData.Skills); skillList.RemoveAll(s => s?.Skill == skillPlayer?.Skill || s?.Skill == skillPlayer?.SpecialSkill || s?.Skill == Skills.None); @@ -171,13 +180,26 @@ namespace jRandomSkills else skillList.RemoveAll(s => terroristSkills.Any(s2 => s2.Name == s.Skill.ToString())); - randomSkill = skillList.Count == 0 ? new jSkill_SkillInfo(Skills.None, Config.GetValue(Skills.None, "color"), false) : skillList[Instance.Random.Next(skillList.Count)]; + if (gameMode == Config.GameModes.NoRepeat && playersSkills.TryGetValue(player.SteamID, out List? skills)) + { + skillList.RemoveAll(s => skills.Any(s2 => s2.Skill == s.Skill)); + if (skillList.Count == 0) skills.Clear(); + } + + randomSkill = skillList.Count == 0 ? noneSkill : skillList[Instance.Random.Next(skillList.Count)]; + if (gameMode == Config.GameModes.NoRepeat) + { + if (playersSkills.TryGetValue(player.SteamID, out List? value)) + value.Add(randomSkill); + else + playersSkills.Add(player.SteamID, [randomSkill]); + } } - else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.TeamSkills) + else if (gameMode == Config.GameModes.TeamSkills) randomSkill = player.Team == CsTeam.Terrorist ? tSkill : ctSkill; - else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.SameSkills) + else if (gameMode == Config.GameModes.SameSkills) randomSkill = allSkill; - else if (Config.LoadedConfig.Settings.GameMode == (int)Config.GameModes.Debug) + else if (gameMode == Config.GameModes.Debug) { if (debugSkills.Count == 0) debugSkills = new List(SkillData.Skills); diff --git a/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs b/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs index f1d6470..f177ed9 100644 --- a/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs +++ b/jRandomSkills - SRC Files/src/player/PlayerOnTick.cs @@ -25,6 +25,7 @@ namespace jRandomSkills private static void OnMapStart(string mapName) { Instance.GameRules = null; + Event.staticSkills.Clear(); } private static void InitializeGameRules() diff --git a/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs b/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs index 697c402..5c6fcf5 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Aimbot.cs @@ -11,7 +11,7 @@ namespace jRandomSkills public class Aimbot : ISkill { private const Skills skillName = Skills.Aimbot; - private static Dictionary hitGroups = new Dictionary(); + private static readonly Dictionary hitGroups = []; public static void LoadSkill() { @@ -27,8 +27,8 @@ namespace jRandomSkills if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null) return HookResult.Continue; - CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle); - CCSPlayerPawn victimPawn = new CCSPlayerPawn(param.Handle); + CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle); + CCSPlayerPawn victimPawn = new(param.Handle); if (attackerPawn.DesignerName != "player" || victimPawn.DesignerName != "player") return HookResult.Continue; @@ -64,11 +64,8 @@ namespace jRandomSkills return HookResult.Continue; } - public class SkillConfig : Config.DefaultSkillInfo + public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates) { - public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates) - { - } } } } \ No newline at end of file diff --git a/jRandomSkills - SRC Files/src/player/skills/BunnyHop.cs b/jRandomSkills - SRC Files/src/player/skills/BunnyHop.cs index 0ea43c1..2042e85 100644 --- a/jRandomSkills - SRC Files/src/player/skills/BunnyHop.cs +++ b/jRandomSkills - SRC Files/src/player/skills/BunnyHop.cs @@ -10,9 +10,9 @@ namespace jRandomSkills public class BunnyHop : ISkill { private const Skills skillName = Skills.BunnyHop; - private static float maxSpeed = Config.GetValue(skillName, "maxSpeed"); - private static float bunnyHopVelocity = Config.GetValue(skillName, "jumpVelocity"); - private static float jumpBoost = Config.GetValue(skillName, "jumpBoost"); + private static readonly float maxSpeed = Config.GetValue(skillName, "maxSpeed"); + private static readonly float bunnyHopVelocity = Config.GetValue(skillName, "jumpVelocity"); + private static readonly float jumpBoost = Config.GetValue(skillName, "jumpBoost"); public static void LoadSkill() { @@ -60,17 +60,11 @@ namespace jRandomSkills } } - public class SkillConfig : Config.DefaultSkillInfo + public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1430a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxSpeed = 500f, float jumpVelocity = 300f, float jumpBoost = 2f) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates) { - public float MaxSpeed { get; set; } - public float JumpVelocity { get; set; } - public float JumpBoost { get; set; } - public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1430a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxSpeed = 500f, float jumpVelocity = 300f, float jumpBoost = 2f) : base(skill, active, color, onlyTeam, needsTeammates) - { - MaxSpeed = maxSpeed; - JumpVelocity = jumpVelocity; - JumpBoost = jumpBoost; - } + public float MaxSpeed { get; set; } = maxSpeed; + public float JumpVelocity { get; set; } = jumpVelocity; + public float JumpBoost { get; set; } = jumpBoost; } } } \ No newline at end of file diff --git a/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs b/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs index 95b9132..2599a54 100644 --- a/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs +++ b/jRandomSkills - SRC Files/src/player/skills/C4Camouflage.cs @@ -1,8 +1,10 @@ using System.Drawing; using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Attributes; using CounterStrikeSharp.API.Modules.Utils; using jRandomSkills.src.player; +using static CounterStrikeSharp.API.Core.Listeners; using static jRandomSkills.jRandomSkills; namespace jRandomSkills @@ -10,6 +12,8 @@ namespace jRandomSkills public class C4Camouflage : ISkill { private const Skills skillName = Skills.C4Camouflage; + private static bool exists = false; + private static readonly Dictionary> invisibleEntities = []; public static void LoadSkill() { @@ -77,10 +81,40 @@ namespace jRandomSkills } return HookResult.Continue; }); + + Instance.RegisterEventHandler((@event, info) => + { + foreach (var player in Utilities.GetPlayers()) + { + if (!Instance.IsPlayerValid(player)) continue; + var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID); + if (playerInfo?.Skill == skillName) + DisableSkill(player); + } + Instance.RemoveListener(CheckTransmit); + exists = false; + return HookResult.Continue; + }); + } + + public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList) + { + foreach (var (info, player) in infoList) + { + if (player == null) continue; + foreach ((var playerId, var itemList) in invisibleEntities) + if (player.SteamID != playerId) + foreach (var item in itemList) + info.TransmitEntities.Remove(item); + } } public static void EnableSkill(CCSPlayerController player) { + if (!exists) + Instance.RegisterListener(CheckTransmit); + exists = true; + if (player == null || !player.IsValid) return; var playerPawn = player.PlayerPawn.Value; @@ -100,6 +134,7 @@ namespace jRandomSkills { SetPlayerVisibility(player, true); SetWeaponVisibility(player, true); + invisibleEntities.Remove(player.SteamID); } private static void SetPlayerVisibility(CCSPlayerController player, bool enabled) @@ -113,23 +148,32 @@ namespace jRandomSkills } } - private static void SetWeaponVisibility(CCSPlayerController player, bool enabled) + private static void SetWeaponVisibility(CCSPlayerController player, bool visible) { if (!Instance.IsPlayerValid(player)) return; - var playerPawn = player.PlayerPawn.Value; - if (playerPawn == null || !playerPawn.IsValid) return; - var weaponServices = playerPawn.WeaponServices; - if (weaponServices == null) return; + var playerPawn = player.PlayerPawn.Value!; + if (playerPawn.WeaponServices == null) return; - var color = Color.FromArgb(enabled ? 255 : 0, 255, 255, 255); - foreach (var weapon in weaponServices.MyWeapons) + invisibleEntities.Remove(player.SteamID); + foreach (var weapon in playerPawn.WeaponServices.MyWeapons) { if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid) { - weapon.Value.Render = color; - Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender"); + if (!visible) + { + if (invisibleEntities.TryGetValue(player.SteamID, out var items)) + { + if (!items.Contains(weapon.Index)) + items.Add(weapon.Index); + } + else + invisibleEntities.Add(player.SteamID, [weapon.Index]); + } } } + + if (visible) + invisibleEntities.Remove(player.SteamID); } public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#00911f", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates) diff --git a/jRandomSkills - SRC Files/src/player/skills/Chicken.cs b/jRandomSkills - SRC Files/src/player/skills/Chicken.cs index 5d31d3a..d9d73ae 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Chicken.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Chicken.cs @@ -6,6 +6,7 @@ using jRandomSkills.src.player; using static CounterStrikeSharp.API.Core.Listeners; using static jRandomSkills.jRandomSkills; using jRandomSkills.src.utils; +using CounterStrikeSharp.API.Core.Attributes; namespace jRandomSkills { @@ -13,6 +14,7 @@ namespace jRandomSkills { private const Skills skillName = Skills.Chicken; private static bool roundEnd = false; + private static bool exists = false; private static readonly string[] disabledWeapons = [ "weapon_ak47", "weapon_m4a4", "weapon_m4a1", "weapon_m4a1_silencer", @@ -57,6 +59,8 @@ namespace jRandomSkills DisableSkill(player); } roundEnd = true; + Instance.RemoveListener(CheckTransmit); + exists = false; return HookResult.Continue; }); @@ -92,11 +96,26 @@ namespace jRandomSkills Instance.RegisterListener(OnTick); } + public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList) + { + foreach (var (info, player) in infoList) + { + if (player == null) continue; + if (chickens.TryGetValue(player, out var chicken)) + if (chicken != null && chicken.IsValid) + info.TransmitEntities.Remove(chicken.Index); + } + } + public static void EnableSkill(CCSPlayerController player) { var playerPawn = player.PlayerPawn?.Value; if (playerPawn != null && playerPawn.IsValid) { + if (!exists) + Instance.RegisterListener(CheckTransmit); + exists = true; + playerPawn.VelocityModifier = 1.1f; playerPawn.Health = 50; @@ -136,11 +155,11 @@ namespace jRandomSkills SetWeaponAttack(player, false); } - foreach (var chicken in chickens) + if (chickens.TryGetValue(player, out var chicken)) { - if (chicken.Value != null && chicken.Value.IsValid) - chicken.Value.Remove(); - chickens.Remove(chicken.Key); + if (chicken != null && chicken.IsValid) + chicken.Remove(); + chickens.Remove(player); } } diff --git a/jRandomSkills - SRC Files/src/player/skills/Ghost.cs b/jRandomSkills - SRC Files/src/player/skills/Ghost.cs index 56cfdf3..2969798 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Ghost.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Ghost.cs @@ -15,6 +15,7 @@ namespace jRandomSkills { private const Skills skillName = Skills.Ghost; private static bool roundEnd = false; + private static bool exists = false; private static readonly string[] disabledWeapons = [ "weapon_deagle", "weapon_revolver", "weapon_glock", "weapon_usp_silencer", @@ -27,7 +28,7 @@ namespace jRandomSkills "weapon_g3sg1", "weapon_nova", "weapon_xm1014", "weapon_mag7", "weapon_sawedoff", "weapon_m249", "weapon_negev" ]; - private static readonly HashSet invisibleEntities = []; + private static readonly Dictionary> invisibleEntities = []; public static void LoadSkill() { @@ -63,6 +64,8 @@ namespace jRandomSkills DisableSkill(player); } roundEnd = true; + Instance.RemoveListener(CheckTransmit); + exists = false; return HookResult.Continue; }); @@ -86,7 +89,18 @@ namespace jRandomSkills if (playerInfo?.Skill != skillName) return HookResult.Continue; SetWeaponVisibility(player!, false); - SetWearablesVisibility(player!, false); + SetWeaponAttack(player!, true); + return HookResult.Continue; + }); + + Instance.RegisterEventHandler((@event, info) => + { + var player = @event.Userid; + if (!Instance.IsPlayerValid(player)) return HookResult.Continue; + var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID); + + if (playerInfo?.Skill != skillName) return HookResult.Continue; + SetWeaponVisibility(player!, false); SetWeaponAttack(player!, true); return HookResult.Continue; }); @@ -99,7 +113,6 @@ namespace jRandomSkills }); Instance.RegisterListener(OnTick); - Instance.RegisterListener(CheckTransmit); } public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList) @@ -107,16 +120,21 @@ namespace jRandomSkills foreach (var (info, player) in infoList) { if (player == null) continue; - foreach (var entity in invisibleEntities) - info.TransmitEntities.Remove((int)entity); + foreach ((var playerId, var itemList) in invisibleEntities) + if (player.SteamID != playerId) + foreach (var item in itemList) + info.TransmitEntities.Remove(item); } } public static void EnableSkill(CCSPlayerController player) { + if (!exists) + Instance.RegisterListener(CheckTransmit); + exists = true; + SetPlayerVisibility(player, false); SetWeaponVisibility(player, false); - SetWearablesVisibility(player, false); SetWeaponAttack(player, true); } @@ -124,8 +142,8 @@ namespace jRandomSkills { SetPlayerVisibility(player, true); SetWeaponVisibility(player, true); - SetWearablesVisibility(player, true); SetWeaponAttack(player, false); + invisibleEntities.Remove(player.SteamID); } private static void OnTick() @@ -152,44 +170,39 @@ namespace jRandomSkills } } - private static void SetWearablesVisibility(CCSPlayerController player, bool visible) - { - if (!Instance.IsPlayerValid(player)) return; - var playerPawn = player.PlayerPawn.Value!; - - var color = visible ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(0, 255, 255, 255); - var shadowStrength = visible ? 1.0f : 0.0f; - - foreach (var item in playerPawn.MyWearables) - { - if (item != null && item.IsValid && item.Value != null && item.Value.IsValid) - { - Server.PrintToChatAll($"NAME: {item.Value.DesignerName}"); - item.Value.Render = color; - item.Value.ShadowStrength = shadowStrength; - Utilities.SetStateChanged(item.Value, "CBaseModelEntity", "m_clrRender"); - } - } - } - private static void SetWeaponVisibility(CCSPlayerController player, bool visible) { if (!Instance.IsPlayerValid(player)) return; var playerPawn = player.PlayerPawn.Value!; if (playerPawn.WeaponServices == null) return; - var color = visible ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(0, 255, 255, 255); - var shadowStrength = visible ? 1.0f : 0.0f; + // var color = visible ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(0, 255, 255, 255); + // var shadowStrength = visible ? 1.0f : 0.0f; + invisibleEntities.Remove(player.SteamID); foreach (var weapon in playerPawn.WeaponServices.MyWeapons) { if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid) { + if (!visible) + { + if (invisibleEntities.TryGetValue(player.SteamID, out var items)) + { + if (!items.Contains(weapon.Index)) + items.Add(weapon.Index); + } + else + invisibleEntities.Add(player.SteamID, [weapon.Index]); + } + /* weapon.Value.Render = color; weapon.Value.ShadowStrength = shadowStrength; - Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender"); + Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender");*/ } } + + if (visible) + invisibleEntities.Remove(player.SteamID); } private static void SetWeaponAttack(CCSPlayerController player, bool disableWeapon) diff --git a/jRandomSkills - SRC Files/src/player/skills/Glaz.cs b/jRandomSkills - SRC Files/src/player/skills/Glaz.cs index 3ec8594..0e46c35 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Glaz.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Glaz.cs @@ -12,7 +12,7 @@ namespace jRandomSkills { private const Skills skillName = Skills.Glaz; private static bool exists = false; - private static List smokes = new List(); + private readonly static List smokes = []; public static void LoadSkill() { @@ -80,11 +80,8 @@ namespace jRandomSkills SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade); } - public class SkillConfig : Config.DefaultSkillInfo + public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates) { - public SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates) - { - } } } } \ No newline at end of file diff --git a/jRandomSkills - SRC Files/src/player/skills/Jackal.cs b/jRandomSkills - SRC Files/src/player/skills/Jackal.cs index b1f44e5..b1fd3f6 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Jackal.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Jackal.cs @@ -73,8 +73,9 @@ namespace jRandomSkills if (pawn == null || !pawn.IsValid || pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue; var beams = step.Value; - if (beams.Count == 0 || pawn.AbsOrigin == null) continue; - Vector lastBeamVector = beams.LastOrDefault()?.EndPos ?? pawn.AbsOrigin; + if (pawn.AbsOrigin == null) continue; + Vector lastBeamVector = beams.Count > 0 + ? beams.LastOrDefault()!.EndPos : pawn.AbsOrigin; var newBeam = CreateBeamStep(step.Key.Team, lastBeamVector, pawn.AbsOrigin); if (newBeam != null) diff --git a/jRandomSkills - SRC Files/src/player/skills/Ninja.cs b/jRandomSkills - SRC Files/src/player/skills/Ninja.cs index b097cd9..68fd922 100644 --- a/jRandomSkills - SRC Files/src/player/skills/Ninja.cs +++ b/jRandomSkills - SRC Files/src/player/skills/Ninja.cs @@ -1,6 +1,7 @@ using System.Drawing; using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Attributes; using CounterStrikeSharp.API.Modules.Utils; using jRandomSkills.src.player; using static CounterStrikeSharp.API.Core.Listeners; @@ -11,15 +12,36 @@ namespace jRandomSkills public class Ninja : ISkill { private const Skills skillName = Skills.Ninja; + private static bool exists = false; private static readonly float idlePercentInvisibility = Config.GetValue(skillName, "idlePercentInvisibility"); private static readonly float duckPercentInvisibility = Config.GetValue(skillName, "duckPercentInvisibility"); private static readonly float knifePercentInvisibility = Config.GetValue(skillName, "knifePercentInvisibility"); private static readonly Dictionary invisibilityChanged = []; + private static readonly Dictionary> invisibleEntities = []; public static void LoadSkill() { SkillUtils.RegisterSkill(skillName, Config.GetValue(skillName, "color")); + Instance.RegisterEventHandler((@event, info) => + { + Instance.AddTimer(0.1f, () => + { + foreach (var player in Utilities.GetPlayers()) + { + DisableSkill(player); + if (!Instance.IsPlayerValid(player)) continue; + var playerPawn = player.PlayerPawn?.Value; + + var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID); + if (playerInfo?.Skill != skillName) continue; + EnableSkill(player); + } + }); + + return HookResult.Continue; + }); + Instance.RegisterEventHandler((@event, info) => { foreach (var player in Utilities.GetPlayers()) @@ -51,9 +73,46 @@ namespace jRandomSkills return HookResult.Continue; }); + Instance.RegisterEventHandler((@event, info) => + { + var player = @event.Userid; + if (!Instance.IsPlayerValid(player)) return HookResult.Continue; + var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID); + + if (playerInfo?.Skill != skillName) return HookResult.Continue; + UpdateNinja(player); + return HookResult.Continue; + }); + + Instance.RegisterEventHandler((@event, info) => + { + foreach (var player in Utilities.GetPlayers()) + { + if (!Instance.IsPlayerValid(player)) continue; + var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID); + if (playerInfo?.Skill == skillName) + DisableSkill(player); + } + Instance.RemoveListener(CheckTransmit); + exists = false; + return HookResult.Continue; + }); + Instance.RegisterListener(OnTick); } + public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList) + { + foreach (var (info, player) in infoList) + { + if (player == null) continue; + foreach ((var playerId, var itemList) in invisibleEntities) + if (player.SteamID != playerId) + foreach (var item in itemList) + info.TransmitEntities.Remove(item); + } + } + private static void OnTick() { foreach (var player in Utilities.GetPlayers()) @@ -64,10 +123,18 @@ namespace jRandomSkills } } + public static void EnableSkill(CCSPlayerController player) + { + if (!exists) + Instance.RegisterListener(CheckTransmit); + exists = true; + } + public static void DisableSkill(CCSPlayerController player) { SetPlayerVisibility(player, 0); SetWeaponVisibility(player, 0); + invisibleEntities.Remove(player.SteamID); } private static void UpdateNinja(CCSPlayerController? player) @@ -92,13 +159,13 @@ namespace jRandomSkills if (!buttons.HasFlag(PlayerButtons.Moveleft) && !buttons.HasFlag(PlayerButtons.Moveright) && !buttons.HasFlag(PlayerButtons.Forward) && !buttons.HasFlag(PlayerButtons.Back) && flags.HasFlag(PlayerFlags.FL_ONGROUND)) percentInvisibility += idlePercentInvisibility; + SetWeaponVisibility(player, percentInvisibility); if (invisibilityChanged.TryGetValue(player.Handle, out float oldInvisibility)) if (percentInvisibility == oldInvisibility) return; invisibilityChanged[player.Handle] = percentInvisibility; SetPlayerVisibility(player, percentInvisibility); - SetWeaponVisibility(player, percentInvisibility); } private static void SetPlayerVisibility(CCSPlayerController player, float percentInvisibility) @@ -115,17 +182,25 @@ namespace jRandomSkills private static void SetWeaponVisibility(CCSPlayerController player, float percentInvisibility) { if (!Instance.IsPlayerValid(player)) return; - var playerPawn = player.PlayerPawn.Value; - if (playerPawn == null || !playerPawn.IsValid || playerPawn.WeaponServices == null) return; + var playerPawn = player.PlayerPawn.Value!; + if (playerPawn.WeaponServices == null) return; var color = Color.FromArgb(Math.Max(255 - (int)(255 * percentInvisibility * 2), 0), 255, 255, 255); + invisibleEntities.Remove(player.SteamID); + if (color.A != 0) return; + foreach (var weapon in playerPawn.WeaponServices.MyWeapons) { if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid) { - weapon.Value.Render = color; - Utilities.SetStateChanged(weapon.Value, "CBaseModelEntity", "m_clrRender"); + if (invisibleEntities.TryGetValue(player.SteamID, out var items)) + { + if (!items.Contains(weapon.Index)) + items.Add(weapon.Index); + } + else + invisibleEntities.Add(player.SteamID, [weapon.Index]); } } } diff --git a/jRandomSkills - SRC Files/src/player/skills/PawelJumper.cs b/jRandomSkills - SRC Files/src/player/skills/PawelJumper.cs index 45c9d62..28c686c 100644 --- a/jRandomSkills - SRC Files/src/player/skills/PawelJumper.cs +++ b/jRandomSkills - SRC Files/src/player/skills/PawelJumper.cs @@ -20,7 +20,7 @@ namespace jRandomSkills public static void LoadSkill() { - SkillUtils.RegisterSkill(skillName, Config.GetValue(skillName, "color")); + SkillUtils.RegisterSkill(skillName, Config.GetValue(skillName, "color"), false); Instance.RegisterListener(() => { diff --git a/jRandomSkills - SRC Files/src/utils/Config.cs b/jRandomSkills - SRC Files/src/utils/Config.cs index eec8f90..b7f1ca7 100644 --- a/jRandomSkills - SRC Files/src/utils/Config.cs +++ b/jRandomSkills - SRC Files/src/utils/Config.cs @@ -140,52 +140,54 @@ namespace jRandomSkills public bool TeamMateSkillInfo { get; set; } public bool SummaryAfterTheRound { get; set; } public bool DebugMode { get; set; } - public string SetSkillCommands { get; set; } - public string SkillsListCommands { get; set; } - public string UseSkillCommands { get; set; } - public string ChangeMapCommands { get; set; } - public string StartGameCommands { get; set; } - public string ConsoleCommands { get; set; } - public string SwapCommands { get; set; } - public string ShuffleCommands { get; set; } - public string PauseCommands { get; set; } - public string HealCommands { get; set; } - public string SetScoreCommands { get; set; } - public VotingCommand[] VotingCommand { get; set; } + public NormalCommand SetSkillCommands { get; set; } + public NormalCommand SkillsListCommands { get; set; } + public NormalCommand UseSkillCommands { get; set; } + public NormalCommand HealCommands { get; set; } + public NormalCommand ConsoleCommands { get; set; } + public NormalCommand SetStaticSkillCommands { get; set; } + public VotingCommand StartGameCommands { get; set; } + public VotingCommand ChangeMapCommands { get; set; } + public VotingCommand SwapCommands { get; set; } + public VotingCommand ShuffleCommands { get; set; } + public VotingCommand PauseCommands { get; set; } + public VotingCommand SetScoreCommands { get; set; } public Settings() { LangCode = "en"; - GameMode = (int)GameModes.Normal; + GameMode = (int)GameModes.NoRepeat; KillerSkillInfo = true; TeamMateSkillInfo = true; SummaryAfterTheRound = true; DebugMode = true; - SetSkillCommands = "ustawskill, setskill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能"; - SkillsListCommands = "supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表"; - UseSkillCommands = "t, useSkill, usarHabilidade, 技能使用, 使用技能"; - HealCommands = "heal, ulecz, curar, tratar, 治疗, 治愈"; - ConsoleCommands = "console, sv, 控制台, 服务器"; + SetSkillCommands = new NormalCommand("ustawskill, ustaw_skill, setskill, set_skill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能", "@jRandmosSkills/admin"); + SkillsListCommands = new NormalCommand("supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表", "@jRandmosSkills/admin"); + UseSkillCommands = new NormalCommand("t, useSkill, usarHabilidade, 技能使用, 使用技能", "@jRandmosSkills/admin"); + HealCommands = new NormalCommand("heal, ulecz, curar, tratar, 治疗, 治愈", "@jRandmosSkills/admin"); + ConsoleCommands = new NormalCommand("console, sv, 控制台, 服务器", "@jRandmosSkills/root"); + SetStaticSkillCommands = new NormalCommand("ustawstatycznyskill, ustaw_statyczny_skill, setstaticskill, set_static_skill", "@jRandmosSkills/admin"); - VotingCommand = [ - new VotingCommand("StartGameCommands", true, "start, go, começar, iniciar, 开始, 启动", "@jRandmosSkills/admin", 15, 60, 15, 500, 2), - new VotingCommand("ChangeMapCommands", true, "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图", "@jRandmosSkills/admin", 25, 90, 15, 500, 2), - new VotingCommand("SwapCommands", true, "swap, zmiana, trocar, 交换, 切换", "@jRandmosSkills/admin", 15, 90, 15, 20, 2), - new VotingCommand("ShuffleCommands", true, "shuffle, embaralhar, 随机排序, 洗牌", "@jRandmosSkills/admin", 15, 90, 15, 90, 2), - new VotingCommand("PauseCommands", true, "pause, unpause, pausar, despausar, 暂停, 恢复", "@jRandmosSkills/admin", 15, 60, 15, 90, 2), - new VotingCommand("SetScoreCommands", true, "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数", "@jRandmosSkills/root", 15, 90, 15, 90, 2), - ]; + StartGameCommands = new VotingCommand(true, "start, go, começar, iniciar, 开始, 启动", "@jRandmosSkills/admin", 15, 60, 15, 500, 2); + ChangeMapCommands = new VotingCommand( true, "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图", "@jRandmosSkills/admin", 25, 90, 15, 500, 2); + SwapCommands = new VotingCommand(true, "swap, zmiana, trocar, 交换, 切换", "@jRandmosSkills/admin", 15, 90, 15, 20, 2); + ShuffleCommands = new VotingCommand(true, "shuffle, embaralhar, 随机排序, 洗牌", "@jRandmosSkills/admin", 15, 90, 15, 20, 2); + PauseCommands = new VotingCommand(true, "pause, unpause, pausar, despausar, 暂停, 恢复", "@jRandmosSkills/admin", 15, 60, 15, 2, 2); + SetScoreCommands = new VotingCommand(true, "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数", "@jRandmosSkills/root", 15, 90, 15, 90, 2); } } - public class VotingCommand(string name, bool enableVoting, string alias, string permissions, float timeToVote, float percentagesToSuccess, float timeToNextVoting, float timeToNextSameVoting, int minimumPlayersToStartVoting) + public class NormalCommand(string alias, string permissions) { - public string Name { get; set; } = name; - public bool EnableVoting { get; set; } = enableVoting; public string Alias { get; set; } = alias; public string Permissions { get; set; } = permissions; + } + + public class VotingCommand(bool enableVoting, string alias, string permissions, float timeToVote, float percentagesToSuccess, float timeToNextVoting, float timeToNextSameVoting, int minimumPlayersToStartVoting) : NormalCommand(alias, permissions) + { + public bool EnableVoting { get; set; } = enableVoting; public float TimeToVote { get; set; } = timeToVote; public float PercentagesToSuccess { get; set; } = percentagesToSuccess; public float TimeToNextVoting { get; set; } = timeToNextVoting; @@ -207,7 +209,8 @@ namespace jRandomSkills Normal = 0, TeamSkills = 1, SameSkills = 2, - Debug = 3, + NoRepeat = 3, + Debug = 4 } } } \ No newline at end of file diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/Config.json b/jRandomSkills - Server Files/plugins/jRandomSkills/Config.json index af21cca..3ba04af 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/Config.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/Config.json @@ -1,22 +1,95 @@ { "Settings": { "LangCode": "en", - "GameMode": 0, + "GameMode": 3, "KillerSkillInfo": true, "TeamMateSkillInfo": true, "SummaryAfterTheRound": true, "DebugMode": true, - "SetSkillCommands": "ustawskill, setskill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能", - "SkillsListCommands": "supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表", - "UseSkillCommands": "t, useSkill, usarHabilidade, 技能使用, 使用技能", - "ChangeMapCommands": "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图", - "StartGameCommands": "start, go, começar, iniciar, 开始, 启动", - "ConsoleCommands": "console, sv, 控制台, 服务器", - "SwapCommands": "swap, zmiana, trocar, 交换, 切换", - "ShuffleCommands": "shuffle, embaralhar, 随机排序, 洗牌", - "PauseCommands": "pause, unpause, pausar, despausar, 暂停, 恢复", - "HealCommands": "heal, ulecz, curar, tratar, 治疗, 治愈", - "SetScoreCommands": "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数" + "SetSkillCommands": { + "Alias": "ustawskill, ustaw_skill, setskill, set_skill, definirhabilidade, configurarhabilidade, 设置技能, 配置技能", + "Permissions": "@jRandmosSkills/admin" + }, + "SkillsListCommands": { + "Alias": "supermoc, skille, listamocy, supermoce, skills, listaHabilidades, habilidades, 技能列表, 超能力列表", + "Permissions": "@jRandmosSkills/admin" + }, + "UseSkillCommands": { + "Alias": "t, useSkill, usarHabilidade, 技能使用, 使用技能", + "Permissions": "@jRandmosSkills/admin" + }, + "HealCommands": { + "Alias": "heal, ulecz, curar, tratar, 治疗, 治愈", + "Permissions": "@jRandmosSkills/admin" + }, + "ConsoleCommands": { + "Alias": "console, sv, 控制台, 服务器", + "Permissions": "@jRandmosSkills/root" + }, + "SetStaticSkillCommands": { + "Alias": "ustawstatycznyskill, ustaw_statyczny_skill, setstaticskill, set_static_skill", + "Permissions": "@jRandmosSkills/admin" + }, + "StartGameCommands": { + "EnableVoting": true, + "TimeToVote": 15.0, + "PercentagesToSuccess": 60.0, + "TimeToNextVoting": 15.0, + "TimeToNextSameVoting": 500.0, + "MinimumPlayersToStartVoting": 2, + "Alias": "start, go, começar, iniciar, 开始, 启动", + "Permissions": "@jRandmosSkills/admin" + }, + "ChangeMapCommands": { + "EnableVoting": true, + "TimeToVote": 25.0, + "PercentagesToSuccess": 90.0, + "TimeToNextVoting": 15.0, + "TimeToNextSameVoting": 500.0, + "MinimumPlayersToStartVoting": 2, + "Alias": "map, mapa, changemap, zmienmape, zmienmape, mudarMapa, trocarMapa, 更换地图, 更改地图", + "Permissions": "@jRandmosSkills/admin" + }, + "SwapCommands": { + "EnableVoting": true, + "TimeToVote": 15.0, + "PercentagesToSuccess": 90.0, + "TimeToNextVoting": 15.0, + "TimeToNextSameVoting": 20.0, + "MinimumPlayersToStartVoting": 2, + "Alias": "swap, zmiana, trocar, 交换, 切换", + "Permissions": "@jRandmosSkills/admin" + }, + "ShuffleCommands": { + "EnableVoting": true, + "TimeToVote": 15.0, + "PercentagesToSuccess": 90.0, + "TimeToNextVoting": 15.0, + "TimeToNextSameVoting": 20.0, + "MinimumPlayersToStartVoting": 2, + "Alias": "shuffle, embaralhar, 随机排序, 洗牌", + "Permissions": "@jRandmosSkills/admin" + }, + "PauseCommands": { + "EnableVoting": true, + "TimeToVote": 15.0, + "PercentagesToSuccess": 60.0, + "TimeToNextVoting": 15.0, + "TimeToNextSameVoting": 2.0, + "MinimumPlayersToStartVoting": 2, + "Alias": "pause, unpause, pausar, despausar, 暂停, 恢复", + "Permissions": "@jRandmosSkills/admin" + }, + "SetScoreCommands": { + "EnableVoting": true, + "TimeToVote": 15.0, + "PercentagesToSuccess": 90.0, + "TimeToNextVoting": 15.0, + "TimeToNextSameVoting": 90.0, + "MinimumPlayersToStartVoting": 2, + "Alias": "setscore, wynik, definirPontuacao, configurarPontos, 设置分数, 调整分数", + "Permissions": "@jRandmosSkills/root" + } }, "SkillsInfo": [ { diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll index af5887d..e54341a 100644 Binary files a/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll and b/jRandomSkills - Server Files/plugins/jRandomSkills/jRandomSkills.dll differ diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/en.json b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/en.json index fc0aa2b..99ec3a8 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/en.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/en.json @@ -401,7 +401,7 @@ "skill_not_found_setskill": "No such CHATCOLORS.REDskill found", "player_not_found_setskill": "No such CHATCOLORS.REDplayer found", "correct_form_setskill": "Correct usage: CHATCOLORS.RED!setskill ", - "correct_form_setskill": "Correct usage: CHATCOLORS.RED!setscore ", + "correct_form_setscore": "Correct usage: CHATCOLORS.RED!setscore ", "done_setskill": "skill set", "error_setskill": "Failed to set CHATCOLORS.REDskill", "for_setskill": "for", @@ -414,6 +414,14 @@ "healed": "You have been healed.", "game_start": "Game started!", + "vote_started": "Vote started: '{0}'", + "vote_timeout": "Vote '{0}' timed out!", + "vote_wait": "You need to wait before starting another vote!", + "vote_same_wait": "You need to wait before starting the same vote again!", + "vote_not_enough_players": "Not enough players to start a vote!", + "vote_alredy_voted": "You have already voted!", + "vote_vote": "Vote", + "teammate_skills": "Your teammates' skills", "summary_start": "======SUMMARY=OF=THE=LAST=ROUND======", "summary_end": "=======================================" diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pl.json b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pl.json index 70741e1..6d461a8 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pl.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pl.json @@ -414,6 +414,14 @@ "healed": "Zostałeś uleczony.", "game_start": "Gra rozpoczęta!", + "vote_started": "Głosowanie rozpoczęte: '{0}'", + "vote_timeout": "Głosowanie '{0}' przekroczyło limit czasu!", + "vote_wait": "Musisz poczekać, zanim rozpoczniesz kolejne głosowanie!", + "vote_same_wait": "Musisz poczekać, zanim ponownie rozpoczniesz to samo głosowanie!", + "vote_not_enough_players": "Za mało graczy, aby rozpocząć głosowanie!", + "vote_alredy_voted": "Już zagłosowałeś!", + "vote_vote": "Głosowanie", + "teammate_skills": "Supermoce twoich sojuszników", "summary_start": "======PODSUMOWANIE=Z=OSTATNIEJ=RUNDY======", "summary_end": "============================================" diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pt-br.json b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pt-br.json index ff42def..af41fee 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pt-br.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/pt-br.json @@ -414,6 +414,14 @@ "healed": "Você foi curado.", "game_start": "Jogo iniciado!", + "vote_started": "Votação iniciada: '{0}'", + "vote_timeout": "Votação '{0}' expirou!", + "vote_wait": "Você precisa esperar antes de iniciar outra votação!", + "vote_same_wait": "Você precisa esperar antes de iniciar a mesma votação novamente!", + "vote_not_enough_players": "Não há jogadores suficientes para iniciar uma votação!", + "vote_alredy_voted": "Você já votou!", + "vote_vote": "Votar", + "teammate_skills": "Habilidades dos seus companheiros de equipe", "summary_start": "=======RESUMO=DA=ÚLTIMA=RODADA=======", "summary_end": "=======================================" diff --git a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/zh.json b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/zh.json index f0e5b19..6ed2da3 100644 --- a/jRandomSkills - Server Files/plugins/jRandomSkills/lang/zh.json +++ b/jRandomSkills - Server Files/plugins/jRandomSkills/lang/zh.json @@ -414,6 +414,14 @@ "healed": "你已被治疗。", "game_start": "游戏开始!", + "vote_started": "投票开始:'{0}'", + "vote_timeout": "投票'{0}'超时!", + "vote_wait": "您需要等待才能开始另一轮投票!", + "vote_same_wait": "您需要等待才能再次发起相同投票!", + "vote_not_enough_players": "投票人数不足!", + "vote_alredy_voted": "您已投票!", + "vote_vote": "投票", + "teammate_skills": "你队友的技能", "summary_start": "=============上一回合总结==============", "summary_end": "======================================="