Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

buy item

  • Product: WRobot General
  • Type: Bug
  • Status: Unconfirmed

 

Hi. The function

Vendor.BuyItem();

does not work correctly.Instead of the required amount,just one good is always bought.

 

User Feedback

Recommended Comments

hi,

You need to call this method several time

                                for (int i = 0; i < b.Quantity && b.NeedToBuy(); i++)
                                {
                                    var qToBuy = b.Quantity - ItemsManager.GetItemCountByNameLUA(b.ItemName);
                                    if (qToBuy > MaxItemsQuantityToBuyByRequest)
                                        qToBuy = MaxItemsQuantityToBuyByRequest;
                                    Vendor.BuyItem(b.ItemName, qToBuy);
                                    Thread.Sleep(Usefuls.Latency + 400);
                                }

 

Pudge

WRobot user

 

 

I am already using code similar to yours, but this is a workaround, it just worked fine in older versions, and I noticed that the bot owes a debt to the vendor, when before the purchase took a couple of seconds. Thanks for the answer.

vendor-buy-work-fine.PNG

TheSmokie

Banned

i use this function to buy stuff from venders if it helps. 

public static void BuyItem(string name, int amount)
    {
        Lua.LuaDoString(string.Format(@"
        local itemName = ""{0}""
        local quantity = {1}
        for i=1, GetMerchantNumItems() do
            local name = GetMerchantItemInfo(i)
            if name and name == itemName then 
                BuyMerchantItem(i, quantity)
            end
        end", name, amount));
    }

 

I won't back to old version of code (change was do 1 year ago).

Current code:

        public static void BuyItem(string name, int number)
        {
            try
            {
                Lua.LuaDoString($@"
local n = '{name.Replace("'", @"\'")}'; 
local q = {number}; 
for i=1,100 do 
    local name, _, _, quantity = GetMerchantItemInfo(i) 
    if name and n==name then 
        if q > quantity then 
            q = quantity 
        end 
        BuyMerchantItem(i,q) 
    end 
end");
            }
            catch (Exception e)
            {
                Logging.WriteError("BuyItem(string name, int number): " + e);
            }
        }

to get old code remove:

        if q > quantity then 
            q = quantity 
        end 

 

TheSmokie

Banned

@Droidz can you a gold check before going to buy food?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.