This commit is contained in:
Juzlus 2025-09-25 04:06:00 +02:00
parent 555fc45d08
commit d68896f181
22 changed files with 338 additions and 106 deletions

View file

@ -283,6 +283,8 @@ namespace src.player
SpecialSkill = Skills.None,
IsDrawing = false,
SkillChance = 1,
PrintHTML = null,
DisplayHUD = true,
});
string welcomeMsg = player.GetTranslation("welcome_message", "welcome");
@ -385,6 +387,24 @@ namespace src.player
}
});
}
if (Config.LoadedConfig.DisableSkillsOnRoundEnd)
{
isTransmitRegistered = false;
Instance.AddTimer(1f, () =>
{
DisableAll();
foreach (var player in Utilities.GetPlayers().Where(p => p.IsValid && !p.IsBot && !p.IsHLTV && p.Team is CsTeam.CounterTerrorist or CsTeam.Terrorist))
{
var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (skillPlayer == null) continue;
skillPlayer.Skill = noneSkill.Skill;
skillPlayer.SpecialSkill = noneSkill.Skill;
skillPlayer.PrintHTML = null;
}
});
Instance.RemoveListener<CheckTransmit>(CheckTransmit);
}
return HookResult.Continue;
}
}
@ -559,6 +579,7 @@ namespace src.player
if (randomSkill.Display)
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{player.GetSkillName(randomSkill.Skill)}{ChatColors.Lime}: {player.GetSkillDescription(randomSkill.Skill)}", false);
Instance?.SkillAction(skillPlayer.Skill.ToString(), "DisableSkill", [player]);
skillPlayer.Skill = randomSkill.Skill;
skillPlayer.SpecialSkill = Skills.None;

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Utils;
using src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
@ -48,7 +49,7 @@ namespace src.player
{
if (player == null) return;
var skillPlayer = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (skillPlayer == null) return;
if (skillPlayer == null || !skillPlayer.DisplayHUD) return;
string infoLine = "";
string skillLine = "";
@ -86,7 +87,7 @@ namespace src.player
}
} else if (player?.IsValid == true)
{
if (player.Team is CsTeam.Spectator or CsTeam.None && Config.LoadedConfig.DisableSpectateHUD)
if ((player.Team is CsTeam.Spectator or CsTeam.None && Config.LoadedConfig.DisableSpectateHUD) || AdminManager.PlayerHasPermissions(player, Config.LoadedConfig.DisableHUDOnDeathPermission))
return;
var pawn = player.Pawn.Value;

View file

@ -112,7 +112,7 @@ namespace src.player.skills
{
if (string.IsNullOrEmpty(model))
model = player.Team == CsTeam.Terrorist ? defaultTModel : defaultCTModel;
pawn.SetModel(model);
var originalRender = pawn.Render;
pawn.Render = Color.FromArgb(255, originalRender.R, originalRender.G, originalRender.B);

View file

@ -93,7 +93,7 @@ namespace src.player.skills
private static void CreateReplica(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
var replica = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
var replica = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic_override");
if (replica == null || playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null || playerPawn.AbsRotation == null)
return;
@ -105,12 +105,12 @@ namespace src.player.skills
replica.Flags = playerPawn.Flags;
replica.Flags |= (uint)Flags_t.FL_DUCKING;
replica.Collision.SolidType = SolidType_t.SOLID_VPHYSICS;
replica.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(replica.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
replica.SetModel(playerPawn!.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName);
replica.Entity!.Name = replica.Globalname = $"Replica_{Server.TickCount}_{(player.Team == CsTeam.CounterTerrorist ? "CT" : "TT")}";
replica.Teleport(pos, playerPawn.AbsRotation, null);
replica.DispatchSpawn();
replica.AcceptInput("EnableCollision");
}
public static void OnTakeDamage(DynamicHook h)
@ -121,18 +121,21 @@ namespace src.player.skills
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
return;
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
if (string.IsNullOrEmpty(param.Entity.Name)) return;
if (!param.Entity.Name.StartsWith("Replica_")) return;
var replica = param.As<CPhysicsPropMultiplayer>();
if (replica == null || !replica.IsValid) return;
replica.EmitSound("GlassBottle.BulletImpact", volume: 1f);
replica.AcceptInput("Kill");
CCSPlayerPawn attackerPawn = new(param2.Attacker.Value.Handle);
if (attackerPawn.DesignerName != "player")
return;
var attackerTeam = attackerPawn.TeamNum;
var replicaTeam = replica.Globalname.EndsWith("CT") ? 3 : 2;
SkillUtils.TakeHealth(attackerPawn, attackerTeam != replicaTeam ? 15 : 5);
replica.AcceptInput("Kill");
}
public class PlayerSkillInfo