How teleport player without: sleeping and kicking violation level.
My code
Code:player.Teleport(pos)
Teleporting without violation kick?
Discussion in 'Rust Development' started by bazuka5801, Apr 12, 2017.
-
Create function like this, and use it to teleport player.
Code:public void Teleport(BasePlayer player, Vector3 position) { if (player.net?.connection != null) player.ClientRPCPlayer(null, player, "StartLoading", null, null, null, null, null); if (player.IsSleeping()) return; player.SetPlayerFlag(BasePlayer.PlayerFlags.Sleeping, true); if (!BasePlayer.sleepingPlayerList.Contains(player)) BasePlayer.sleepingPlayerList.Add(player); player.CancelInvoke("InventoryUpdate"); player.MovePosition(position); if (player.net?.connection != null) player.ClientRPCPlayer(null, player, "ForcePositionTo", position); if (player.net?.connection != null) player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, true); player.UpdateNetworkGroup(); player.SendNetworkUpdateImmediate(false); if (player.net?.connection == null) return; try { player.ClearEntityQueue(null); } catch { } player.SendFullSnapshot(); }
-
Wulf Community Admin
Oxide's API has numerous methods to make use of teleporting, you don't really need to duplicate it. Look in the Libraries in our GitHub repo for Oxide.Game.Rust. Both the Covalence API and the game-specific API has methods for this.