Servus bin gerade am lernen und habe mir ein Tutorial angeschaut um Fahrzeuge zu spawnen.
Wenn ich nun z.B. "/veh Adder" benutze bekomme ich in der Konsole folgenden Fehler:
Code: Konsole
Exception has been thrown by the target of an invocation.
UNHANDLED EXCEPTION IN COMMAND veh FOR RESOURCE Testscript
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.MissingMethodException: Method not found: 'GTANetworkAPI.Vector3 GTANetworkAPI.Entity.get_Position()'.
at void Testscript.Commands.AdminCommands.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)
Das Script:
AdminCommands.cs:
Code: AdminCommands.cs
public class AdminCommands : Script
{
public AdminCommands() { }
[Command("veh", "~o~ Benutze: /veh [Vehicle Name]", GreedyArg = true)]
public void CMD_CreateVehicle(Player player, string vehicleName)
{
if (PlayerData.Data.ReturnPlayerData(player).AdminLevel < Admin.Rank.Admin_Lead)
{
player.SendChatMessage("~r~Fehler: ~w~Du bist nicht berechtigt diesen Befehl auszuführen");
return;
}
VehicleHash hash = NAPI.Util.VehicleNameToModel(vehicleName);
if (hash == 0)
{
player.SendChatMessage("~r~Fehler: ~w~Kein gültiger Fahrzeugname!");
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($"{Testscript.Utils.Colors.COLOR_Info}Info: ~w~Du hast einen {vehicle.DisplayName} gespawnt.");
return;
}
[Command("makemeadmin")]
public void CMD_MakeMeAdmin(Player player)
{
PlayerData.Data.ReturnPlayerData(player).AdminLevel = Admin.Rank.Admin_Owner;
}
}
}
Alles anzeigen
C#: Admin.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace Testscript
{
class Admin
{
public enum Rank : int
{
Admin_None,
Admin_Junior,
Admin_Lead,
Admin_Owner
}
}
}
Alles anzeigen
Verstehe nicht woher dieser Vector3 Fehler kommt
Danke im vorraus für jegliche Hilfe