CXXY

remote event error

Recommended Posts

Client side:

class KeyManager {
    constructor() {
        mp.keys.bind(0x11, true, function() {
            if(mp.players.local.vehicle && mp.players.local.vehicle.getPedInSeat(-1) === mp.players.local.handle) {
                mp.events.callRemote('BANG_onVehicleShotPrimary', mp.players.local.vehicle.getForwardVector());
            }
        });
    }
}
export default new KeyManager();

Server side:

        [RemoteEvent ("BANG_onVehicleShotPrimary")]
        public void BANG_onVehicleShotPrimary (Client player, object[] arguments) {
            player.SendChatMessage("HALLILUAH");
        }

Console:

at object RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor)
at object System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(object obj, object[] parameters, object[] arguments)
at void GTANetworkInternals.RemoteEventParser.Parse(Client sender, ulong eventNameHash, object[] args) in C:\Users\Adam\Documents\Git\comp-layer2\BootstrapperNC\Handlers\ResourceInfo.cs:line 62
at void GTANetworkInternals.RemoteEventHandler.Parse(Client sender, ulong eventNameHash, object[] arguments) in C:\Users\Adam\Documents\Git\comp-layer2\BootstrapperNC\Handlers\ResourceInfo.cs:line 67
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 void GC_FunGame.Main.BANG_onVehicleShotPrimary(Client player, object[] arguments)

 

Share this post


Link to post
Share on other sites
  mp.events.callRemote('BANG_onVehicleShotPrimary', JSON.stringfy(mp.players.local.vehicle.getForwardVector()));
 [RemoteEvent ("BANG_onVehicleShotPrimary")]
        public void BANG_onVehicleShotPrimary (Client player, string position) {
            var pos = NAPI.Utils.FromJson<Vector3>(position);
            player.SendChatMessage(":)");
       }

Use NAPI.Utils.FromJson to parse data from json and NAPI.Utils.ToJson to transform your c# object to json.

Share this post


Link to post
Share on other sites
   at void GTANetworkInternals.RemoteEventParser.Parse(Client sender, ulong eventNameHash, object[] args) in C:\Users\Adam\Documents\Git\comp-layer2\BootstrapperNC\Handlers\ResourceInfo.cs:line 62

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.