Get name of player using command?Solved
server.Command("tp 1815 10 1518");
how do i make that teleport the player that runs the command, as in how do i get there name automatically?
That depends entirely on what is supplying the IPlayer or other player object. Generally you'd need a hook that provides it, a lookup, a command, or a loop of players. You can get the name of the IPlayer object with player.Name though.
        [Command("tp")]
        private void TeleportCommand(IPlayer player, string command, string[] args)
        {
            player.Teleport(1815, 10, 1518);
            player.Reply($"Hi {player.Name}, you were teleported to: 1815 10 1518");
        }​
[Command("tp")]
private void CommandTeleport(IPlayer player, string command, string[] args)
{
    // Only let players run this command
    if (player.IsServer)
        return;

    // Parse arguments
    float x, y, z;
    if (args.Length < 3 ||
        !float.TryParse(args[0], out x) ||
        !float.TryParse(args[1], out y) ||
        !float.TryParse(args[2], out z))
    {
        player.Reply("Syntax: tp <x> <y> <z>");
        return;
    }

    player.Teleport(x, y, z);
}
There are other considerations as well. For instance, if they are going far, you'll probably want to put them asleep to allow their surroundings to load first. You can check out the NTeleportation plugin which does this.
thanks so much!
5f1792699e67b.jpg WhiteThunder
There are other considerations as well. For instance, if they are going far, you'll probably want to put them asleep to allow their surroundings to load first. You can check out the NTeleportation plugin which does this.

I'm not sure that's needed. From my experience and testing, Covalence handles all that is necessary. See https://github.com/OxideMod/Oxide.Rust/blob/develop/src/Libraries/Player.cs#L189-L226

Locked automatically