public void GenerateAccount(Torch.API.IPlayer player) { ulong steamid = player.SteamId; PlayerAccountData data = new PlayerAccountData(); bool found = false; foreach (var Account in PlayersAccounts) { if (Account.SteamID == steamid) { found = true; break; } } if (!found) { Log.Info($"Creating new account object for {player.Name}"); data.SteamID = steamid; data.Player = player.Name; PlayersAccounts.Add(data); SaveHomeData(); return; } }
public PlayerData(List <int> items, string name, PlayerAccountData _accountData) { avatarItems = items; houseItems = new List <Furniture>(); purchasedItems = items; avatarName = name; accountData = _accountData; }
public void SetPlayerAccountData(PlayerAccountManager pm) { CreditAccountData data = new CreditAccountData(pm.CreditAccount.Balance, pm.CreditAccount.CutDate, pm.CreditAccount.InterestRate, pm.CreditAccount.CurrentCredit.CreditLimit, pm.CreditAccount.transactions); List <CreditAccountData> historial = new List <CreditAccountData>(); for (int i = 0; i < pm.WeeklyCreditState.Count; i++) { historial.Add(new CreditAccountData(pm.WeeklyCreditState[i].Balance, pm.WeeklyCreditState[i].CutDate, pm.WeeklyCreditState[i].InterestRate, pm.WeeklyCreditState[i].CurrentCredit.CreditLimit, pm.WeeklyCreditState[i].transactions)); } accountData = new PlayerAccountData(pm.Gold, pm.CreditAccount.InterestRate, pm.CreditAccount.CurrentCredit.CreditLimit, data, historial, pm.transactions); }
public void UpdatePlayerAccount(PlayerAccountData obj) { var objectToRepalce = PlayersAccounts.Where(i => i.SteamID == obj.SteamID).First(); var index = PlayersAccounts.IndexOf(objectToRepalce); if (index != -1) { PlayersAccounts[index] = obj; } SaveAccountData(); }
public void SavePlayerData() { List <int> holdedItems = new List <int>(); foreach (Item item in holder.currentItems) { holdedItems.Add(item.itemID); } PlayerAccountData data = new PlayerAccountData(0, 0, 0, new CreditAccountData(), new List <CreditAccountData>(), new List <Transaction>()); PlayerData newPlayer = new PlayerData(holdedItems, nameField.text, data); SaveData.Save(newPlayer); SceneManager.LoadScene("MainScene"); }
public string GetRank(ulong steamID) { PlayerAccountData data = new PlayerAccountData(); foreach (var Account in PlayersAccounts) { if (Account.SteamID == steamID) { data = Account; break; } } return(data.Rank); }
public PlayerAccountData GetAccount(ulong steamID) { PlayerAccountData data = new PlayerAccountData(); data = null; foreach (var Account in PlayersAccounts) { if (Account.SteamID == steamID) { data = Account; break; } } return(data); }
public void GenerateAccount(Torch.API.IPlayer player) { try { var state = new MyP2PSessionState(); Sandbox.Engine.Networking.MyGameService.Peer2Peer.GetSessionState(player.SteamId, ref state); var ip = new IPAddress(BitConverter.GetBytes(state.RemoteIP).Reverse().ToArray()); ulong steamid = player.SteamId; PlayerAccountData data = new PlayerAccountData(); bool found = false; foreach (var Account in PlayersAccounts) { if (Account.SteamID == steamid) { if (!Account.KnownIps.Contains(ip.ToString()) && ip.ToString() != "0.0.0.0") { Account.KnownIps.Add(ip.ToString()); } if (Account.IdentityID == 0L && !string.IsNullOrEmpty(Account.Player)) { Account.IdentityID = Utilities.GetIdentityByNameOrIds(Account.Player)?.IdentityId ?? 0L; UpdatePlayerAccount(Account); } found = true; break; } } if (!found) { Log.Info($"Creating new account object for {player.Name}"); data.SteamID = steamid; data.Player = player.Name; data.Rank = EssentialsPlugin.Instance.Config.DefaultRank; data.KnownIps.Add(ip.ToString()); PlayersAccounts.Add(data); SaveAccountData(); return; } } catch (Exception e) { Log.Error($"Exception creating account for {player.Name} {e.ToString()}"); } }
public void SetAccountData() { PlayerAccountData accountData = RoomManager.GetInstance().avatarData.accountData; CreditAccountData creditData = accountData.currentCreditAccountData; List <Transaction> allTransactions = accountData.allTransactions; List <CreditAccountData> historial = new List <CreditAccountData>(); for (int i = 0; i < accountData.weeklyHistorial.Count; i++) { historial.Add(accountData.weeklyHistorial[i]); } Gold = accountData.Gold; CreditAccount = new CreditAccountState(creditData.Balance, creditData.CutDate, new Credit(accountData.InterestRate, accountData.CreditLimit)); transactions = allTransactions; for (int i = 0; i < historial.Count; i++) { WeeklyCreditState.Add(new CreditAccountState(historial[i].Balance, historial[i].CutDate, new Credit(historial[i].interestRate, historial[i].creditLimit))); } // end for }
public void GenerateAccount(Torch.API.IPlayer player) { try { ulong steamid = 0; var steamid_backup = MyEventContext.Current.Sender.Value; System.Net.IPAddress ip; if (player == null || player.SteamId == 0) { steamid = steamid_backup; } else { steamid = player.SteamId; } if (steamid != 0) { var state = new MyP2PSessionState(); Sandbox.Engine.Networking.MyGameService.Peer2Peer.GetSessionState(steamid, ref state); ip = new IPAddress(BitConverter.GetBytes(state.RemoteIP).Reverse().ToArray()); if (ip == null) { return; } } else { ip = null; } // Disconnect client with Ip 0.0.0.0 to prevent SteamLib Crash. if (ip != null) { if (ip.ToString() == "0.0.0.0") { MyMultiplayer.Static.DisconnectClient(steamid); Log.Info($"Detected IP: {ip} from SteamID {steamid} Client was disconnected"); } } PlayerAccountData data = new PlayerAccountData(); bool found = false; foreach (var Account in PlayersAccounts) { if (Account.SteamID == steamid) { if (!Account.KnownIps.Contains(ip.ToString()) && ip.ToString() != "0.0.0.0") { Account.KnownIps.Add(ip.ToString()); } if (Account.IdentityID == 0L && !string.IsNullOrEmpty(Account.Player)) { Account.IdentityID = Utilities.GetIdentityByNameOrIds(Account.Player)?.IdentityId ?? 0L; UpdatePlayerAccount(Account); } if (ip != null) { if (!Account.KnownIps.Contains(ip.ToString()) && ip.ToString() != "0.0.0.0") { if (Account != null && Account.KnownIps != null) { Account.KnownIps.Add(ip.ToString()); } else { Log.Info($"No account KnowIps exist for IP: {ip}"); } } } found = true; break; } } if (!found) { if (player == null) { Log.Info($"Cannont Create new account Player is Null"); return; } Log.Info($"Creating new account object for {player.Name}"); if (steamid != 0) { data.SteamID = steamid; } else { data.SteamID = steamid_backup; } data.Player = player.Name; data.Rank = EssentialsPlugin.Instance.Config.DefaultRank; if (ip != null) { data.KnownIps.Add(ip.ToString()); } PlayersAccounts.Add(data); SaveAccountData(); return; } if (steamid == 0) { Log.Info($"Cannont Create new account for player, no steamid or IP detected, maybe next time."); } } catch { Log.Error($"Creating NEW account for {player.Name}, Player was not found in List."); } }