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
{
I tried to create a command but it didn't work and I got this error.
in Discussion
Posted
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;
}
}
}