fighting crashes #1

This commit is contained in:
Juzlus 2026-04-28 18:58:21 +02:00
parent 10dbf6629e
commit 0fb3d63cd8
145 changed files with 677278 additions and 1703 deletions

View file

@ -1,11 +1,13 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
using src.utils;
using System.Collections.Concurrent;
using System.Drawing;
using static src.jRandomSkills;
using Timer = CounterStrikeSharp.API.Modules.Timers.Timer;
namespace src.player.skills
{
@ -13,6 +15,7 @@ namespace src.player.skills
{
private const Skills skillName = Skills.ReZombie;
private static readonly ConcurrentDictionary<uint, byte> zombies = [];
private static readonly ConcurrentDictionary<ulong, Timer> timers = [];
private static readonly object setLock = new();
public static void LoadSkill()
@ -81,9 +84,12 @@ namespace src.player.skills
QAngle angle = new(pawn.V_angle.X, pawn.V_angle.Y, 0);
ulong steamID = player.SteamID;
int team = player.TeamNum;
if (team != 2 && team != 3) return;
player.Respawn();
Instance.AddTimer(.2f, () => {
Server.NextFrame(() => {
lock (setLock)
{
var player = Utilities.GetPlayerFromSteamId(steamID);
@ -93,10 +99,61 @@ namespace src.player.skills
if (pawn == null || !pawn.IsValid) return;
var zombieHealth = SkillsInfo.GetValue<int>(skillName, "zombieHealth");
bool isBlock = team != player.TeamNum || player.TeamChanged;
player.Respawn();
zombies.TryAdd(player.Index, 0);
if (isBlock)
{
pawn.Flags |= (uint)Flags_t.FL_FROZEN;
pawn.Teleport(new Vector(0, 0, -1000), new QAngle(90, 0, 0));
bool isFreezeTime = Instance.GameRules != null && Instance.GameRules.FreezePeriod == true;
if (!isFreezeTime)
{
Server.NextFrame(() =>
{
if (pawn == null || !pawn.IsValid) return;
pawn.CommitSuicide(false, true);
});
return;
}
ulong steamId = player.SteamID;
if (!timers.ContainsKey(player.SteamID))
{
var timer = Instance.AddTimer(1f, () =>
{
if (player == null || !player.IsValid || pawn == null || !pawn.IsValid)
{
if (timers.TryRemove(steamId, out var t))
t.Kill();
return;
}
bool isFreezeTime = Instance.GameRules != null && Instance.GameRules.FreezePeriod == true;
if (!isFreezeTime)
{
if (timers.TryRemove(steamId, out var t))
t.Kill();
pawn.CommitSuicide(false, true);
return;
}
}, TimerFlags.STOP_ON_MAPCHANGE | TimerFlags.REPEAT);
timers.TryAdd(player.SteamID, timer);
}
return;
}
SetPlayerColor(pawn, false);
SkillUtils.AddHealth(pawn, zombieHealth - 100, zombieHealth);
@ -139,7 +196,7 @@ namespace src.player.skills
Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender");
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int zombieHealth = 500) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission)
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int maxPerServer = -1, Rarity rarity = Rarity.Common, int zombieHealth = 500) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, maxPerServer, rarity)
{
public int ZombieHealth { get; set; } = zombieHealth;
}