So yeah.. If someone saw a thread that i said "I accidently deleted the plugin".. i rewrote it today.. its exactly the same but its like doing non sense thing.
I will show you the code bcs it will be a public plugin anyway:
What can fix this issue (PROBABLY) ?
Config.. but if i do it with a classic way like Config["Teleport", "ToX"] = 0; then it keeps overwriting.
The problem is that .. after the 5seconds OnceTimer you can see i teleport the player. This should teleport the player to the config xyz. What it does.. it just teleports the player to his position.. but i dont even tell it to teleport to player.transform.position... WEIRD
Code:using System.Collections.Generic; using System; using System.Reflection; using UnityEngine; using Oxide.Core; using System.Linq;namespace Oxide.Plugins { [Info("Rules Agreement", "PaiN", 0.1, ResourceId = 1231)] [Description("On connect the player gets teleported to the set location in config. After he types /agree he goes back to his spawn")] public class RulesAgreement : RustPlugin { private class LoginInfo { public BasePlayer Player { get; set; } public Vector3 LoginPosition { get; set; } public LoginInfo(BasePlayer player) { Player = player; LoginPosition = player.transform.position; } } List<LoginInfo> loginagreed = new List<LoginInfo>(); class StoredData { public HashSet<PlayerInfo> Players = new HashSet<PlayerInfo>(); public StoredData() { } } class PlayerInfo { public string UserId; public PlayerInfo() { } public PlayerInfo(BasePlayer player) { UserId = player.userID.ToString(); } } StoredData storedData; void Loaded() { LoadDefaultConfig(); storedData = Interface.GetMod().DataFileSystem.ReadObject<StoredData>("RulesAgreementData"); } protected override void LoadDefaultConfig() { //Teleport Coordinates if(Config["Teleport", "ToX"] == null) Config["Teleport", "ToX"] = 0; if(Convert.ToInt32(Config["Teleport", "ToX"]) != 0) return; if(Config["Teleport", "ToY"] == null) Config["Teleport", "ToY"] = 0; if(Convert.ToInt32(Config["Teleport", "ToY"]) != 0) return; if(Config["Teleport", "ToZ"] == null) Config["Teleport", "ToZ"] = 0; if(Convert.ToInt32(Config["Teleport", "ToZ"]) != 0) return; //Messages if(Config["Messages", "ConnectMessage"] == null) Config["Messages", "ConnectMessage"] = "Welcome {player}!\n Please read the rules and type /agree to teleport back to your spawn."; if((Config["Messages", "ConnectMessage"].ToString()) != "Welcome {player}!\n Please read the rules and type /agree to teleport back to your spawn.") return; if(Config["Messages", "AgreeMessage"] == null) Config["Messages", "AgreeMessage"] = "Thank you for accepting the rules. Have Fun!"; if((Config["Messages", "AgreeMessage"].ToString()) != "Thank you for accepting the rules. Have Fun!") return; SaveConfig(); } [ChatCommand("test")] void cmdTest(BasePlayer player, string cmd, string[] args) { string steamId = Convert.ToString(player.userID); if (storedData.Players.Any(p => p.UserId == steamId)) return; loginagreed.Add(new LoginInfo(player)); timer.Once(5, () => { Vector3 teleportexit = new Vector3(Convert.ToInt32(Config["Teleport", "ToX"]), Convert.ToInt32(Config["Teleport", "ToY"]), Convert.ToInt32(Config["Teleport", "ToZ"])); player.StartSleeping(); player.ClientRPCPlayer(null, player, "ForcePositionTo", new object[] { teleportexit }); player.TransformChanged(); player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, true); player.UpdateNetworkGroup(); player.UpdatePlayerCollider(true, false); player.SendNetworkUpdateImmediate(false); player.ClientRPCPlayer(null, player, "StartLoading"); player.SendFullSnapshot(); player.SetPlayerFlag(BasePlayer.PlayerFlags.ReceivingSnapshot, false); player.ClientRPCPlayer(null, player, "FinishLoading" ); string message = Config["Messages", "ConnectMessage"].ToString(); SendReply(player, message); }); } [ChatCommand("agree")] void cmdAgree(BasePlayer player, string cmd, string[] args) { string steamId = Convert.ToString(player.userID); if (storedData.Players.Any(p => p.UserId == steamId)) return; foreach (LoginInfo current in loginagreed) { var info = new PlayerInfo(player); storedData.Players.Add(info); string messagee = Config["Messages", "AgreeMessage"].ToString(); SendReply(player, messagee); current.Player.ClientRPCPlayer(null, current.Player, "ForcePositionTo", new object[] { current.LoginPosition }); Interface.GetMod().DataFileSystem.WriteObject("RulesAgreementData", storedData); } } } }
ForcePositionTo problems C#
Discussion in 'Rust Development' started by PaiN, Jul 17, 2015.