mp_autokick

This commit is contained in:
ByDexter 2026-08-20 18:34:10 +03:00
parent d016d42780
commit 11f51b596c
4 changed files with 22 additions and 10 deletions

View file

@ -16,9 +16,6 @@ namespace src.player.skills
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
try { defaultAutoKick = ConVar.Find("mp_autokick")?.GetPrimitiveValue<bool>() ?? true; }
catch { defaultAutoKick = true; }
}
public static void NewRound()
@ -26,7 +23,24 @@ namespace src.player.skills
if (!autoKickOverridden) return;
autoKickOverridden = false;
Server.ExecuteCommand($"mp_autokick {(defaultAutoKick ? 1 : 0)}");
if (defaultAutoKick) Server.ExecuteCommand("mp_autokick 1");
}
private static bool TrySuppressAutoKick()
{
if (autoKickOverridden) return true;
if (!SkillsInfo.GetValue<bool>(skillName, "manageAutoKick")) return false;
bool live;
try { live = ConVar.Find("mp_autokick")?.GetPrimitiveValue<bool>() ?? false; }
catch { return false; }
if (!live) return false;
defaultAutoKick = true;
autoKickOverridden = true;
Server.ExecuteCommand("mp_autokick 0");
return true;
}
public static void OnTakeDamage(CBaseEntity damagedEntity, CTakeDamageInfo damageInfo)
@ -67,11 +81,7 @@ namespace src.player.skills
float damage = damageInfo.Damage;
damageInfo.Damage = 0;
if (!autoKickOverridden)
{
autoKickOverridden = true;
Server.ExecuteCommand("mp_autokick 0");
}
TrySuppressAutoKick();
SkillUtils.AddHealth(
victimPawn,
@ -80,9 +90,10 @@ namespace src.player.skills
);
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = true, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Common, float healthDamageMultiplier = .3f) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = true, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Common, float healthDamageMultiplier = .3f, bool manageAutoKick = true) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)
{
public float HealthDamageMultiplier { get; set; } = healthDamageMultiplier;
public bool ManageAutoKick { get; set; } = manageAutoKick;
}
}
}

View file

@ -1702,6 +1702,7 @@
},
{
"HealthDamageMultiplier": 0.3,
"ManageAutoKick": true,
"NeedsTeammates": true,
"DisableOnFreezeTime": false,
"DisableOnPistolRound": false,