Refactored command handling to improve player and skill lookup logic, replaced some list operations with direct queries, and updated method signatures for clarity and null safety. The vote system was reworked to support more robust vote tracking, cooldowns, and localized chat messages. Language files were updated to add new vote-related translations. Various code style and nullability improvements were made throughout the plugin.
73 lines
No EOL
2.9 KiB
C#
73 lines
No EOL
2.9 KiB
C#
using CounterStrikeSharp.API;
|
|
using CounterStrikeSharp.API.Core;
|
|
using CounterStrikeSharp.API.Modules.Entities.Constants;
|
|
using CounterStrikeSharp.API.Modules.Utils;
|
|
using jRandomSkills.src.player;
|
|
using static jRandomSkills.jRandomSkills;
|
|
|
|
namespace jRandomSkills
|
|
{
|
|
public class Zeus : ISkill
|
|
{
|
|
private const Skills skillName = Skills.Zeus;
|
|
|
|
public static void LoadSkill()
|
|
{
|
|
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
|
|
|
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
|
|
{
|
|
Instance.AddTimer(0.1f, () =>
|
|
{
|
|
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) continue;
|
|
EnableSkill(player);
|
|
}
|
|
});
|
|
|
|
return HookResult.Continue;
|
|
});
|
|
|
|
Instance.RegisterEventHandler<EventWeaponFire>((@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)
|
|
{
|
|
var pawn = player!.PlayerPawn!.Value!;
|
|
if (pawn.WeaponServices == null || pawn.WeaponServices.ActiveWeapon == null || !pawn.WeaponServices.ActiveWeapon.IsValid) return HookResult.Continue;
|
|
if (pawn.WeaponServices.ActiveWeapon.Value == null || !pawn.WeaponServices.ActiveWeapon.Value.IsValid) return HookResult.Continue;
|
|
|
|
var activeWeapon = pawn.WeaponServices.ActiveWeapon.Value;
|
|
if (activeWeapon.DesignerName != "weapon_taser") return HookResult.Continue;
|
|
var taser = activeWeapon.As<CWeaponTaser>();
|
|
Instance.AddTimer(.1f, () =>
|
|
{
|
|
if (taser.IsValid)
|
|
{
|
|
taser.LastAttackTick = 0;
|
|
taser.FireTime = 0;
|
|
}
|
|
});
|
|
}
|
|
|
|
return HookResult.Continue;
|
|
});
|
|
}
|
|
|
|
public static void EnableSkill(CCSPlayerController player)
|
|
{
|
|
SkillUtils.TryGiveWeapon(player, CsItem.Zeus);
|
|
}
|
|
|
|
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#fbff00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : Config.DefaultSkillInfo(skill, active, color, onlyTeam, needsTeammates)
|
|
{
|
|
}
|
|
}
|
|
} |