1. Greetings.
    Is there a way to close player's inventory except sending "inventory.endloot" console command or sending him to sleep?
     
    Last edited by a moderator: Apr 3, 2015
  2. Is it already solved? Because I see you used it in your Plugin...
     
  3. I used the ways i've wrote about in my message.
    As i can see they are not so "clear".
    I've tried to call "EndLooting" but it just don't do anythin...
     
  4. Which coding language do you use?
     
  5. C# ofc.
     
  6. While there is no explicit way to do this, as Facepunch has no use case for making the server close inventory, I found an RPC which is harmless to use while a player is alive which will also close the inventory UI as a side effect.

    The following should work for your use case:
    Code:
    player.ClientRPC(null, player, "OnRespawnInformation", new RespawnInformation { spawnOptions = new List<RespawnInformation.SpawnOptions>() }.ToProtoBytes());
     
  7. Looks like it's not a way better then ways i use :/
    So there is no CLEAR and proper way to close player's inventory?
     
  8. I looked at all possible methods of accomplishing this after reading your question and as I stated before, there is no explicit method of doing this since Facepunch has no use case for it.

    The above RPC should be far better than any other method which can be used to implicitly close the inventory since it will not change player state at all or cause any other side effects. The OnRespawnInformation RPC causes no client-side action other than closing the inventory UI, so it is completely safe to use for your use case.
     
  9. What's about sending "inventory.close" command to player? Why this isn't better than RPC?
     
  10. There is no such command, so it will do nothing... I'm not sure how you can think that is useful or what made you think such a command exists, but if there was a client command called "inventory.close", you would have no reason to have made this thread.
     
  11. player.SendConsoleCommand("inventory.endloot");
    It does.
    But the problem is, what this is still console command. And not usage of game's methods. And the thread was about to ask about Oxide calls like, EndLooting, Clear, etc... which is related to PlayerLoot class.
     
  12. You said "inventory.close" previously, not "inventory.endloot".

    1) "inventory.endloot" does exist, but it only closes the bottom right looting UI, it does not close the inventory screen.
    2) If all you want to do is close the loot UI, then there is no reason not to use this.
    3) You asked for a method of closing the users inventory, which is exactly what I gave you.
     
  13. Sorry for missunderstanding then. Thanks.
     
  14. I just took a look at "inventory.close", that is actually a server command, not a client command. It calls "player.inventory.loot.Clear();" on the server, so instead of using that command, you should run "player.inventory.loot.Clear();" directly on the server to stop looting.

    You will still need to use the RPC mentioned if you want to close the entire inventory UI screen.
     
  15. I've tried to use it, but it doesn't close looting windows inside inventory ui, even after i've sended frame to player.
     
  16. Code:
    player.ClientRPC(null, player, "OnRespawnInformation", new RespawnInformation { spawnOptions = new List<RespawnInformation.SpawnOptions>() }.ToProtoBytes());
    Tries this today. doesn't work, may be i'm doing something wrong?
    [DOUBLEPOST=1428682966][/DOUBLEPOST]Also looks like there is new advansed ways was added to close looting :)