public static OfflinePlayer FindOffline(string name) { OfflinePlayer offPlayer = new OfflinePlayer("", "", "", "", 0); Database.AddParams("@Name", name); using (DataTable playerDB = Database.fillData("SELECT * FROM Players WHERE Name = @Name")) { if (playerDB.Rows.Count == 0) return offPlayer; else { offPlayer.name = playerDB.Rows[0]["Name"].ToString().Trim(); offPlayer.title = playerDB.Rows[0]["Title"].ToString().Trim(); offPlayer.titleColor = c.Parse(playerDB.Rows[0]["title_color"].ToString().Trim()); offPlayer.color = c.Parse(playerDB.Rows[0]["color"].ToString().Trim()); offPlayer.money = int.Parse(playerDB.Rows[0]["Money"].ToString()); if (offPlayer.color == "") { offPlayer.color = GetGroup(offPlayer.name).color; } } } return offPlayer; }
/// <summary> /// Called from <c>BasePlayer.OnDisconnected()</c> . /// </summary> public static void On_PlayerDisconnected(BasePlayer basePlayer) { Player player = Server.GetPlayer(basePlayer); if (Server.GetInstance().serverData.ContainsKey("OfflinePlayers", player.SteamID)) { OfflinePlayer offlinePlayer = (Server.GetInstance().serverData.Get("OfflinePlayers", player.SteamID) as OfflinePlayer); offlinePlayer.Update(player); Server.GetInstance().OfflinePlayers[basePlayer.userID] = offlinePlayer; } else { OfflinePlayer offlinePlayer = new OfflinePlayer(player); Server.GetInstance().OfflinePlayers.Add(basePlayer.userID, offlinePlayer); } if (Server.GetInstance().Players.ContainsKey(basePlayer.userID)) Server.GetInstance().Players.Remove(basePlayer.userID); OnNext("On_PlayerDisconnected", player); }
public static OfflinePlayer FindOffline(string name) { OfflinePlayer offPlayer = new OfflinePlayer("", "", "", "", 0); string query = "SELECT * FROM Players WHERE Name = '" + name + "'"; using (DataTable playerDB = Server.useMySQL ? MySQL.fillData(query) : SQLite.fillData(query)) { if (playerDB.Rows.Count == 0) return offPlayer; else { offPlayer.name = playerDB.Rows[0]["Name"].ToString().Trim(); offPlayer.title = playerDB.Rows[0]["Title"].ToString().Trim(); offPlayer.titleColor = c.Parse(playerDB.Rows[0]["title_color"].ToString().Trim()); offPlayer.color = c.Parse(playerDB.Rows[0]["color"].ToString().Trim()); offPlayer.money = int.Parse(playerDB.Rows[0]["Money"].ToString()); if (offPlayer.color == "") { offPlayer.color = GetGroup(offPlayer.name).color; } } } return offPlayer; }
// Start is called before the first frame update void Start() { thePlayer = FindObjectOfType<OfflinePlayer>(); theRb = GetComponent<Rigidbody>(); }