indrikh Posted September 9, 2020 Posted September 9, 2020 (edited) Hi! I tried to change the player's position and got an error. What am I doing wrong? (api ver. 1.1) Code: [Command("tp")] public void Teleport(Player player, float x, float y, float z) { NAPI.Chat.SendChatMessageToPlayer(player, $"Teleporting to x:{x} y:{y} z:{z}"); player.Position = new Vector3(x, y, z); } Console output result: Exception has been thrown by the target of an invocation. UNHANDLED EXCEPTION IN COMMAND tp FOR RESOURCE MyServer/MyServer System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Void GTANetworkAPI.Entity.set_Position(GTANetworkAPI.Vector3)'. at void MyServer.Utils.Teleport(Player player, float x, float y, float z) --- 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) Edited September 10, 2020 by indrikh
Tonytza Posted September 11, 2020 Posted September 11, 2020 Not sure but you might not be using the correct Bootstrapper.dll? Make sure you reference the one from the rage-mp/server-files/dotnet/runtime folder (In visual studio, change reference) And make sure to run the updater for the server, for the latest version.
indrikh Posted September 13, 2020 Author Posted September 13, 2020 В 12.09.2020 в 01:15, Tonytza сказал: Not sure but you might not be using the correct Bootstrapper.dll? Make sure you reference the one from the rage-mp/server-files/dotnet/runtime folder (In visual studio, change reference) And make sure to run the updater for the server, for the latest version. Thank you so much, it helped!
lotrazza Posted October 7, 2020 Posted October 7, 2020 [Command("tp")] public void Teleport(Player player, float x, float y, float z) { NAPI.Chat.SendChatMessageToPlayer(player, $"Teleporting to x:{x} y:{y} z:{z}"); //player.Position = new Vector3(x, y, z); NAPI.Entity.SetEntityPosition(player.Handle, (new Vector3(x, y, z))); }
LT.Steiner Posted November 3, 2020 Posted November 3, 2020 (edited) @indrikhUse double not float, float is for Rotation Edited November 4, 2020 by LT.Steiner
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now