Jump to content

UNHANDLED EXCEPTION IN COMMAND veh FOR RESOURCE RPV


Recommended Posts

Posted

Hi guys i have a problem with simple vehicle command. Namely server droped error:

UNHANDLED EXCEPTION IN COMMAND veh FOR RESOURCE RPV
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeLoadException: Could not load type 'GTANetworkAPI.Vector3' from assembly 'RPV, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' due to value type mismatch.
   at void RPV.Komendy.AdminCommands.CMD_Veh(Player player, string vehName)
   --- End of inner exception stack trace ---
   at object RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor, bool wrapExceptions)
   at object System.Reflection.RuntimeMethodInfo.Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
   at bool GTANetworkInternals.CommandParser.Parse(Player sender, string cmdRaw, string ourcmd, string[] args)
[12:01:28][0]WeirdNewbie:  /getpos elo
Exception has been thrown by the target of an invocation.

 

I guess something with Vector3, my command code.

 

using GTANetworkAPI;
using System.Globalization;
using System.IO;
using System;

namespace RPV.Komendy
{
    class AdminCommands : Script
    {
        // /veh /vehicle
        [Command("veh", "Użyj: /veh [Nazwa Pojazdu]")]
        public void CMD_Veh(Player player, string vehName)
        {
            VehicleHash hash = NAPI.Util.VehicleNameToModel(vehName);

            if(hash == 0)
            {
                player.SendChatMessage("~r~Błąd: ~w~Niepoprawna nazwa pojazdu");
                return;
            }


            Random random = new Random();
            Vehicle vehicle = NAPI.Vehicle.CreateVehicle(hash, player.Position.Around(5), player.Rotation.Z, random.Next(160), random.Next(160));
            player.SendChatMessage($"Info: ~w~Stworzyłeś pojazd {vehicle.DisplayName}");

        }
	}
}

 

I need help

Posted

Sounds like you are using another Bootstrapper/GTANetwork package (NuGet?) version than Bootstrapper.dll in server folder/dotnet/runtime.

Posted
On 1/2/2021 at 12:23 AM, Bonus said:

Sounds like you are using another Bootstrapper/GTANetwork package (NuGet?) version than Bootstrapper.dll in server folder/dotnet/runtime.

This is the answer.

I've been trying to fix the exact same error for one of my commands (/pos), and after hours and hours of research, all you have to do is to copy bootstrapper.dll and bootstrapper.xml from your server-files/dotnet/runtime into C:\Users\YOURUSER\.nuget\packages\gtanetwork.api\1.1.0-dp1-2\lib\netcoreapp3.1\

Hope this helps someone.

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.
×
×
  • Create New...