Jump to content

Player.position change


indrikh

Recommended Posts

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 by indrikh
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

В 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!

Link to comment
Share on other sites

  • 4 weeks later...
[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)));

}

 

Link to comment
Share on other sites

  • 4 weeks later...

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...