Jump to content
RAGE Multiplayer Community

I tried to create a command but it didn't work and I got this error.


Recommended Posts

I tried to create a command but it didn't work and I got this error. Can someone help me?

 

UNHANDLED EXCEPTION IN COMMAND spawncar FOR RESOURCE ServerRage
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeLoadException: Could not load type 'GTANetworkAPI.Vector3' from assembly 'ServerRage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' due to value type mismatch.
   at void ServerRage.Commands.PlayerCommands.CMD_CreateVehicle(Player player, string vehicleName)
   --- 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)

My code:

using System;
using System.Collections.Generic;
using System.Text;
using GTANetworkAPI;

namespace ServerRage.Commands
{
    class PlayerCommands : Script
    {

        [Command("spawncar", "~o~Syntax: ~w~/spawncar [Car Name]", GreedyArg = true)]
        public void CMD_CreateVehicle(Player player, string vehicleName)
        {
            VehicleHash hash = NAPI.Util.VehicleNameToModel(vehicleName);
            if(hash == 0)
            {
                player.SendChatMessage("~r~Error: ~w~Invalid vehicle name.");
                return;
            }
            Random random = new Random();
            Vehicle vehicle = NAPI.Vehicle.CreateVehicle(hash, player.Position.Around(5), player.Rotation.Z, random.Next(160), random.Next(160));
            return;
        }
    }
}
 

 

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.

×
×
  • Create New...