1. I have searched and do not know of any lua plugin that does what I need to study it. I have a loop through players inventory looking for item name with x stack, when found, I would like to remove it from their inventory. This is where I am stuck, I find the item stack but can't remove it. Any help or guidance in the right direction is much appreciated. Thanks.
     
  2. You should be able to call the method Remove on the item.
    Code:
    public void Remove(float fTime)
    {
        if (this.removeTime <= 0f)
        {
            foreach (ItemMod mod in this.info.itemMods)
            {
                mod.OnRemove(this);
            }
            this.onCycle = null;
            this.removeTime = Time.time + fTime;
            this.OnDirty = null;
            this.position = -1;
            if (this.isServer)
            {
                ItemManager.RemoveItem(this, fTime);
            }
        }
    }
    So you'll most likely need something like this in lua: (untested)
    Code:
    ...
    foundItem:Remove(0)
    ...
     
  3. I had found something like player. Inventory:Take(item)
    There was a second arg but i forgot it. It worked totally fine for me.
     
  4. Thanks for the replies. Laser's reply is the closest I have gotten to getting it working. Still not quite there yet. Do you still have the lua script you had working?
     
  5. Take was changed a while back and does no longer take a single item to remove and is used for crafting to remove a list of items.
    Did you actually try to use Remove(float fTime)? Remove works perfectly for what you need, you just grab the Item object you want to remove and call Remove(0)
    Below example will remove one stack of Wood from your inventory when you run /test.

    Code:
    PLUGIN.Title = "Lua Tests"
    PLUGIN.Version = V(9, 9, 9)
    PLUGIN.Description = "Lua test plugin"
    PLUGIN.Author = "Mughisi"function PLUGIN:Init()    
        command.AddChatCommand("test",  self.Plugin, "cmdTest")
    endfunction PLUGIN:cmdTest( player, cmd, args )
        local item = player.inventory:FindItemID(3655341)
        item:Remove(0)
    end
     
  6. Thanks, I see what I did wrong. Trying to get the item id from the name instead of the id itself. The "0" in Remove, does this indicate the slot? Trying to remove a specific stack of x instead of a random stack. Thanks again.
     
    Last edited by a moderator: Aug 23, 2015
  7. 0 is the time, which should be 0, to remove a specific item stack just search the inventory for that item, there are multiple ways to do that, I just used the easiest thing there is for an example on how the remove actually works.
    I can recommend using a tool like .NET Reflector or Telerik JustDecompile to browse the Assembly-CSharp.dll to get to know the available fields, structs, methods, ...
     
  8. Thanks for all the help. I will check out the decompiled dll information.
     
  9. Search for PlayerInventory and check the Take method. I used it in CSharp but I think you should br able to use it in LUA too. I can post you an example code in the next hours.
    [DOUBLEPOST=1440348826][/DOUBLEPOST]
    I don't think so, its still working. I used it in a shop plugin. Its currently running on a server.
     
  10. Of course it still works, but it is slower than Remove, especially from Lua as it takes a List<Item> which isn't easily created in Lua.
     
  11. Ye you are propably right with that. Just saying it works. I used it in CSharp.
     
  12. I never said it doesn't work :) I just said it takes a List and not a single item ^^
     
  13. I did not remember that fully. Gonna check my code again :p
     
  14. Ok, I loop the inventory, find the stack with x amount of wood that I want to remove, but I cannot figure out even with the dll decompiled how to remove that stack. It still removes a random stack. Since they all have the same itemid, trying to compare the name returned "Item.woodx##..." is always the same. I know im probably missing someting simple.
     
  15. With the :Take method you can specify the amount of taken items.
     
  16. I tried take but keep getting invalid arguments to method. I have the list, id and amount unless the list is wrong in some way.
     
  17. Try Take(nil, <id_here>, <amount_here>)
     
  18. Well, thats that. Thanks for the help. :)
    [DOUBLEPOST=1440440837,1440412116][/DOUBLEPOST]How would I go about removing a blueprint? I can get the flags of items to determine if it is a blueprint but they have the same name and id as the item they provide.
    [DOUBLEPOST=1440587793][/DOUBLEPOST]I have tried all I know or what could possibly work. I can get the position of a BP, but how do I remove it? Is it possible to remove a specific slot? I know X amount can be removed and items once found with an itemid, but they have the same ids.