Solved GiveItem batch slow

Discussion in 'Rust Development' started by NexusBR, Jan 14, 2015.

  1. So i developed a plugin called Inventory Guardian that saves and restores players inventories.
    The problem is that sometimes it does not fully restore the inventory, Normally that happens when the players open the inventory it stops the item give process.

    So i put a print on start of the process and at the end.

    Then the plugin batch give item restoration finishes about half-second or so, But the items restoration finishes about 5 seconds later, And if the player opens the inventory before that the inventory is not fully restored.

    So my question is: There is a way to block the inventory from being opened before X seconds? Or if there is anyway to speed the process or something like that?

    Any help will be much appreciated.
     
  2. Mb just give items after 3-5 Sec when player spawned
     
  3. But that is not the problem, The player spawn is not the problem, Because on my plugin there is a command to restore the inventory manually and if i open the inventory before 5 seconds it stops the restoration process.

    The problem is not the player spawn, but the slow give Item process, I don't know if is there a time that GiveItem takes to send the package to the client, or it is really slow by purpose.
     
  4. For me, that problem occurs only when player spawns
     
  5. I can't say about the button block, because i tried to remove button bit from 'inputState' on OnReceiveTick and this has no effect. But you can catch when client press BUTTON.INVENTORY and don't give items.
     
  6. But that is not the problem Since the loop to giveItem takes less then half-second, What takes time is to send that item to the client.
    So detect if the player have the inventory is open doesn't really matter.

    The problem is not with the lua plugin but the delay between i run GiveItem and the item reach the player inventory.
     
  7. You could disable the inventory keybind and rebind it after everything is done.
    However thats a very dirty and in no way a recommended way to handle this.
     
  8. So what you recommend? And as i said the problem is not the plugin that is too slow to loop by all the table and give the items, But the GiveItem itself that takes too long to send each item to the client/inventory.
     
  9. GiveItem is a rust function and not something oxide controls, if it is slow then its because of how they have it coded. You will need to test and debug a method that gets around that limitation.
    You could use SendSnapshot() by modifing the ItemContainers of the fields:
    containerMain, containerBelt, and containerWear.
    Another option is using SendUpdatedInventory(PlayerInventory.Type type, ItemContainer container, bool bSendInventoryToEveryone = false) and pass it the container instead.
     
  10. Well look like that would do the trick.

    Hatemail if is not to ask too much, Can you give me a simple example to how to use those functions?

    And player:SendFullSnapshot() would do the same thing? or player:SendNetworkUpdateImmediate() would help too?
     
  11. Try getting them to work yourself first, I'm not really the one to give out code as the receiver doesn't learn much from it usually. If you have no success I'll look into it when I get time.
     
  12. I ask because there is no documentation for such functions, Well there is no documentation for almost nothing anyway.

    Is hard to develop any plugins without any documentation, The wiki documentation is for legacy and is totally outdated.
     
    Last edited by a moderator: Jan 15, 2015
  13. We all need to go through the server files and find what we can use for what we want to achieve, this also includes a lot of trial and error. Just grab a decompiler and start going through the inventory functions :) (DotPeek, Telerik JustDecompiler, .NET Reflector, ...)
     
  14. Or Oxide team would take a spare time to develop a documentation.

    We should be doing a lot more awesome plugins if we had the right documentation.
    Is hard to do something without knowing it, And to know we need a good documentation.

    And you will spend much more time to research the oxide and rust classes, hooks and libraries then developing the plugin itself, That kind of thing is not viable or even pratical
     
  15. Wulf

    Wulf Community Admin

    Oxide 2's hooks are documented, there isn't really anything else to document. Rust server documentation is something entirely different. Any external libraries, Rust functions, etc are the responsibility of their authors, though the community is always welcomed to contribute.

    There is no full API in Oxide 2, the documentation is the hooks.txt.
     
  16. yeah Rust documentation i guess he ment :p
     
  17. Wulf

    Wulf Community Admin

    Yeah, that's not really the responsibility of Oxide, but I do agree that it'd be nice to have.
     
  18. Well we cant do a lot of things only with hooks.
    On the wiki there is a small list of documented libraries and classes, If Oxide Team could update to work with Experimental rust and add a little more of documentation would be nice.
     
  19. Wulf

    Wulf Community Admin

    That wiki is only for Legacy, and will likely remain that way. As I've stated in other threads, once the new site design is ready and Oxide 2 is ready for a full release, we'll have better documentation prepared specifically for it. Right now Oxide 2 is still an alpha version for an alpha game.