Skip to content

Air Serf #92

@spraY1965

Description

@spraY1965

i have write the following code and im trying to compile it, i did it but im getting a wierd error like the db its not connecting

The code :
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using Modularity;
using VipCoreApi;

namespace VIP_AirSurf;

public class VipAirSurf : BasePlugin, IModulePlugin
{
public override string ModuleAuthor => "Your Name";
public override string ModuleName => "[VIP] Air Surf";
public override string ModuleVersion => "v1.0.0";

private IVipCoreApi _api = null!;
private AirSurf? _airSurf;

public void LoadModule(IApiProvider provider)
{
    _api = provider.Get<IVipCoreApi>();
    _airSurf = new AirSurf(this, _api);
    _api.RegisterFeature(_airSurf);
}

public override void Unload(bool hotReload)
{
    if (_airSurf != null)
        _api.UnRegisterFeature(_airSurf);
}

}

public class AirSurf : VipFeatureBase
{
public override string Feature => "AirSurf";

public AirSurf(VipAirSurf vipAirSurf, IVipCoreApi api) : base(api)
{
    vipAirSurf.RegisterListener<Listeners.OnTick>(() =>
    {
        foreach (var player in Utilities.GetPlayers())
        {
            if (player == null || !player.IsValid || player.IsBot || !player.PawnIsAlive) continue;
            
            if (!IsClientVip(player)) continue;
            if (!PlayerHasFeature(player)) continue;
            if (GetPlayerFeatureState(player) is not IVipCoreApi.FeatureState.Enabled) continue;

            var playerPawn = player.PlayerPawn.Value;
            if (playerPawn == null) continue;

            var currentVelocity = playerPawn.AbsVelocity;
            var currentPosition = playerPawn.AbsOrigin;
            var currentAngles = playerPawn.AbsRotation;
            
            if (currentPosition == null || currentAngles == null) continue;
            
            var multiplier = GetFeatureValue<float>(player);

            // Check if player is in air by checking if they're not on ground
            if (!playerPawn.OnGroundLastTick)
            {
                var newVelocity = new Vector(
                    currentVelocity.X * multiplier,
                    currentVelocity.Y * multiplier,
                    currentVelocity.Z
                );
                
                playerPawn.Teleport(currentPosition, currentAngles, newVelocity);
            }
        }
    });
}

}

public enum MovementType
{
MOVETYPE_NONE = 0,
MOVETYPE_WALK = 2
}

The error : [EROR] (cssharp:Core) Error invoking callback
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at VIPCore.VipCore.PrintLogError(String message, Object[] args) in E:\github\cs2-VIPCore\VIPCore\VIPCore\VIPCore.cs:line 911
at VIPCore.VipCore.IsUserActiveVip(CCSPlayerController player) in E:\github\cs2-VIPCore\VIPCore\VIPCore\VIPCore.cs:line 875
at VIPCore.VipCore.<Load>b__13_1(EventPlayerDisconnect event, GameEventInfo _) in E:\github\cs2-VIPCore\VIPCore\VIPCore\VIPCore.cs:line 66
at InvokeStub_GameEventHandler1.Invoke(Object, Span1)
at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at CounterStrikeSharp.API.Core.FunctionReference.<CreateWrappedCallback>b__18_0(fxScriptContext* context) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/FunctionReference.cs:line 100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions