SetEntityPosition

From GT-MP
Jump to: navigation, search
SetEntityPosition
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript

Repositions an entity.

Syntax

In C#
Server-Side Function

API.setEntityPosition(NetHandle handle, Vector3 position);
  • handle: parameter input should be in NetHandle type.
  • position: parameter input should be in Vector3 type.

In Javascript
Client-Side Function

API.setEntityPosition(NetHandle handle, Vector3 position, Boolean ground = false);
  • handle: parameter input should be in NetHandle type.
  • position: parameter input should be in Vector3 type.
  • ground: parameter input should be in Boolean type.

Usage example(s)

Command /goto player_name which teleports you to a player

[Command("goto", "/goto [player name]")]
public void GotoPlayer(Client player, string targetName)
{
    Client targetHandle = API.getPlayerFromName(targetName);
    if (targetHandle != null)
    {
        Vector3 targetPos = API.getEntityPosition(targetHandle);
        API.setEntityPosition(player, targetPos);
    }
}
API.setEntityPosition(someNetHandle, new Vector3(1234, 2345, 1234));
API.setEntityPosition(someNetHandle, new Vector3(1234, 2345, 1234), true)

References