public static void TrackTrades(User user, string userOrItemName) { LinkedUser linkedUser = LinkedUserManager.LinkedUserByEcoUser(user); if (linkedUser == null) { ChatManager.ServerMessageToPlayer(new LocString($"You have not linked your Discord Account to DiscordLink on this Eco Server.\nLog into the game and use the `\\dl-link` command to initialize account linking."), user); return; } int trackedTradesCount = DLStorage.WorldData.GetTrackedTradesCountForUser(ulong.Parse(linkedUser.DiscordId)); if (trackedTradesCount >= DLConfig.Data.MaxTrackedTradesPerUser) { ChatManager.ServerMessageToPlayer(new LocString($"You are already tracking {trackedTradesCount} trades and the limit is {DLConfig.Data.MaxTrackedTradesPerUser} tracked trades per user.\nUse the `\\dl-StopTrackTrades` command to remove a tracked trade to make space if you wish to add a new one."), user); return; } // Fetch trade data using the trades command once to see that the command parameters are valid string result = SharedCommands.Trades(userOrItemName, out string matchedName, out bool isItem, out StoreOfferList groupedBuyOffers, out StoreOfferList groupedSellOffers); if (!string.IsNullOrEmpty(result)) { ChatManager.ServerMessageToPlayer(new LocString(result), user); return; } bool added = DLStorage.WorldData.AddTrackedTradeItem(ulong.Parse(linkedUser.DiscordId), matchedName).Result; result = added ? $"Tracking all trades for {matchedName}." : $"Failed to start tracking trades for {matchedName}"; ChatManager.ServerMessageToPlayer(new LocString(result), user); }
public static LinkedUser AddLinkedUser(User user, string discordId, string guildId) { LinkedUser linkedUser = new LinkedUser(user.SlgId, user.SteamId, discordId, guildId); DLStorage.PersistentData.LinkedUsers.Add(linkedUser); DLStorage.Instance.Write(); return(linkedUser); }
public static void ListTrackedTrades(User user) { LinkedUser linkedUser = LinkedUserManager.LinkedUserByEcoUser(user); if (linkedUser == null) { ChatManager.ServerMessageToPlayer(new LocString($"You have not linked your Discord Account to DiscordLink on this Eco Server.\nLog into the game and use the `\\dl-link` command to initialize account linking."), user); return; } EcoUtil.SendAnnouncementMessage("Tracked Trades", DLStorage.WorldData.ListTrackedTrades(ulong.Parse(linkedUser.DiscordId)), user); }
public static void StopTrackTrades(User user, string userOrItemName) { LinkedUser linkedUser = LinkedUserManager.LinkedUserByEcoUser(user); if (linkedUser == null) { ChatManager.ServerMessageToPlayer(new LocString($"You have not linked your Discord Account to DiscordLink on this Eco Server.\nLog into the game and use the `\\dl-link` command to initialize account linking."), user); return; } bool removed = DLStorage.WorldData.RemoveTrackedTradeItem(ulong.Parse(linkedUser.DiscordId), userOrItemName).Result; string result = removed ? $"Stopped tracking trades for {userOrItemName}." : $"Failed to stop tracking trades for {userOrItemName}.\nUse `\\dl-ListTrackedStores` to see what is currently being tracked."; ChatManager.ServerMessageToPlayer(new LocString(result), user); }
public static bool VerifyLinkedUser(ulong discordUserId) { // Find the linked user for the sender and mark them as verified LinkedUser user = LinkedUserByDiscordId(discordUserId, false); bool result = user != null; if (result) { user.Verified = true; DLStorage.Instance.Write(); OnLinkedUserVerified?.Invoke(null, user); } return(result); }
public static bool RemoveLinkedUser(User user) { bool deleted = false; LinkedUser linkedUser = LinkedUserByEcoUser(user, requireVerification: false); if (linkedUser != null) { if (linkedUser.Verified) { OnLinkedUserRemoved?.Invoke(null, linkedUser); } DLStorage.PersistentData.LinkedUsers.Remove(linkedUser); deleted = true; DLStorage.Instance.Write(); } return(deleted); }
private void HandleLinkedUserRemoved(object sender, LinkedUser user) { WorldData.PlayerTrackedTrades.Remove(ulong.Parse(user.DiscordId)); }