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.
63 lines
No EOL
2.3 KiB
C#
63 lines
No EOL
2.3 KiB
C#
using CounterStrikeSharp.API;
|
|
using CounterStrikeSharp.API.Core;
|
|
using CounterStrikeSharp.API.Modules.Utils;
|
|
using jRandomSkills.src.player;
|
|
using static CounterStrikeSharp.API.Core.Listeners;
|
|
using static jRandomSkills.jRandomSkills;
|
|
|
|
namespace jRandomSkills
|
|
{
|
|
public class RadarHack : ISkill
|
|
{
|
|
private const Skills skillName = Skills.RadarHack;
|
|
|
|
public static void LoadSkill()
|
|
{
|
|
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
|
|
Instance.RegisterListener<OnTick>(CheckRadarowiec);
|
|
}
|
|
|
|
private static void CheckRadarowiec()
|
|
{
|
|
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)
|
|
{
|
|
SetEnemiesVisibleOnRadar(player);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void SetEnemiesVisibleOnRadar(CCSPlayerController player)
|
|
{
|
|
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null) return;
|
|
int playerIndex = (int)player.Index - 1;
|
|
|
|
foreach (var enemy in Utilities.GetPlayers().FindAll(p => p.Team != player.Team && p.PawnIsAlive))
|
|
{
|
|
var enemyPawn = enemy.PlayerPawn.Value;
|
|
if (enemyPawn == null) continue;
|
|
enemyPawn.EntitySpottedState.SpottedByMask[0] |= (1u << (int)(playerIndex % 32));
|
|
|
|
}
|
|
|
|
var bombEntities = Utilities.FindAllEntitiesByDesignerName<CC4>("weapon_c4").ToList();
|
|
if (bombEntities.Any())
|
|
{
|
|
var bomb = bombEntities.FirstOrDefault();
|
|
if (bomb != null)
|
|
bomb.EntitySpottedState.SpottedByMask[0] |= (1u << (int)(playerIndex % 32));
|
|
}
|
|
}
|
|
|
|
public class SkillConfig : Config.DefaultSkillInfo
|
|
{
|
|
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#2effcb", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
} |