mp_autokick
This commit is contained in:
parent
d016d42780
commit
11f51b596c
4 changed files with 22 additions and 10 deletions
|
|
@ -16,9 +16,6 @@ namespace src.player.skills
|
||||||
public static void LoadSkill()
|
public static void LoadSkill()
|
||||||
{
|
{
|
||||||
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
|
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
|
||||||
|
|
||||||
try { defaultAutoKick = ConVar.Find("mp_autokick")?.GetPrimitiveValue<bool>() ?? true; }
|
|
||||||
catch { defaultAutoKick = true; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void NewRound()
|
public static void NewRound()
|
||||||
|
|
@ -26,7 +23,24 @@ namespace src.player.skills
|
||||||
if (!autoKickOverridden) return;
|
if (!autoKickOverridden) return;
|
||||||
|
|
||||||
autoKickOverridden = false;
|
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)
|
public static void OnTakeDamage(CBaseEntity damagedEntity, CTakeDamageInfo damageInfo)
|
||||||
|
|
@ -67,11 +81,7 @@ namespace src.player.skills
|
||||||
float damage = damageInfo.Damage;
|
float damage = damageInfo.Damage;
|
||||||
damageInfo.Damage = 0;
|
damageInfo.Damage = 0;
|
||||||
|
|
||||||
if (!autoKickOverridden)
|
TrySuppressAutoKick();
|
||||||
{
|
|
||||||
autoKickOverridden = true;
|
|
||||||
Server.ExecuteCommand("mp_autokick 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
SkillUtils.AddHealth(
|
SkillUtils.AddHealth(
|
||||||
victimPawn,
|
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 float HealthDamageMultiplier { get; set; } = healthDamageMultiplier;
|
||||||
|
public bool ManageAutoKick { get; set; } = manageAutoKick;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1702,6 +1702,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"HealthDamageMultiplier": 0.3,
|
"HealthDamageMultiplier": 0.3,
|
||||||
|
"ManageAutoKick": true,
|
||||||
"NeedsTeammates": true,
|
"NeedsTeammates": true,
|
||||||
"DisableOnFreezeTime": false,
|
"DisableOnFreezeTime": false,
|
||||||
"DisableOnPistolRound": false,
|
"DisableOnPistolRound": false,
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue