62 lines
No EOL
2.2 KiB
C#
62 lines
No EOL
2.2 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 PawelJumper : ISkill
|
|
{
|
|
private static Skills skillName = Skills.PawelJumper;
|
|
private static readonly PlayerFlags[] LF = new PlayerFlags[64];
|
|
private static readonly int?[] J = new int?[64];
|
|
private static readonly PlayerButtons[] LB = new PlayerButtons[64];
|
|
|
|
public static void LoadSkill()
|
|
{
|
|
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
|
|
return;
|
|
|
|
SkillUtils.RegisterSkill(skillName, "#FFA500");
|
|
|
|
Instance.RegisterListener<OnTick>(() =>
|
|
{
|
|
foreach (var player in Utilities.GetPlayers())
|
|
{
|
|
if (!Instance.IsPlayerValid(player)) return;
|
|
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
|
if (playerInfo?.Skill == skillName)
|
|
{
|
|
GiveAdditionalJump(player);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
private static void GiveAdditionalJump(CCSPlayerController player)
|
|
{
|
|
var playerPawn = player.PlayerPawn.Value;
|
|
var flags = (PlayerFlags)playerPawn.Flags;
|
|
var buttons = player.Buttons;
|
|
|
|
if ((LF[player.Slot] & PlayerFlags.FL_ONGROUND) != 0 && (flags & PlayerFlags.FL_ONGROUND) == 0 && (LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0)
|
|
{
|
|
//J[player.Slot] ++;
|
|
}
|
|
else if ((flags & PlayerFlags.FL_ONGROUND) != 0)
|
|
{
|
|
J[player.Slot] = 0;
|
|
}
|
|
else if ((LB[player.Slot] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0 && J[player.Slot] < 1)
|
|
{
|
|
J[player.Slot] ++;
|
|
playerPawn.AbsVelocity.Z = 300;
|
|
}
|
|
|
|
LF[player.Slot] = flags;
|
|
LB[player.Slot] = buttons;
|
|
}
|
|
}
|
|
} |