Hello all, I'm trying to make a plugin which teleports players to a certian position when Initialize, but im not sure how to go about that. I'll share my code and any help is appreciated.
Code:private const string UsePerm = "customspawn.use"; private void Init() { permission.RegisterPermission(UsePerm, this); } private void OnPlayerInit(BasePlayer player) { if (!permission.UserHasPermission(player.UserIDString, UsePerm)) { // do nothing because player does not have correct permission to teleport to spawn location } else { // if player has correct permission teleport to spawn location string x = 12.68355; string y = 6.220349; string z = -33.45345; TeleportToPosition(player, x, y, z); } }
Solved Teleporting player to position?
Discussion in 'Rust Development' started by Sonny-Boi, Jan 7, 2018.
-
Wulf Community Admin
Where is TeleportToPosition defined and what is the actual issues?
-
Code:
using Oxide.Core.Libraries.Covalence; using System.Collections.Generic; using Oxide.Core.Plugins; using System; using System.Linq;namespace Oxide.Plugins { [Info("CustomSpawn", "Sonny-Boi", "1.0.0")] [Description("Teleport all players to set position when first connected to the server")] class CustomSpawn : RustPlugin { private const string UsePerm = "customspawn.use"; private void Init() { permission.RegisterPermission(UsePerm, this); } private void OnPlayerInit(BasePlayer player) { if (!permission.UserHasPermission(player.UserIDString, UsePerm)) { // do nothing because player does not have correct permission to teleport to spawn location } else { // if player has correct permission teleport to spawn location string x = 12.68355; string y = 6.220349; string z = -33.45345; TeleportToPosition(player, x, y, z); } } } }
-
Wulf Community Admin
You should be able to use player.Teleport(new Vector3(x, y, z)) if I'm recalling correctly.
-
Sorry for being such a nuisance, it's just that its hard to find coverage on this type of stuff. Thanks alot man, have a great day
-
Wulf Community Admin
-
Code:
string x = "12.68355"; string y = "6.220349"; string z = "-33.45345"; player.Teleport(new Vector3(x, y, z));
-
Wulf Community Admin
-
float f = f;
float x = Config["x"]'f';
float y = Config["y"]'f';
float z = Config["z"]'f';
player.Teleport(new Vector3(x, y, z)); -
i.e Convert.ToSingle(Config["value"]) -
thank you man, ill try not to post as much