예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }