I'm writing a little script that gives players rewards, but I'd like to check whether player has space before I run it.
Is there an easy way to check there is space in the current player inventory before I drop the reward?
I'm currently using:
Thanks.Code:foreach(BasePlayer player in BasePlayer.activePlayerList) { CODE...}
Checking inventory space?
Discussion in 'Rust Development' started by Rebajas, Oct 11, 2017.
-
I'd do it this way...
Code:if (!player.inventory.containerMain.IsFull() || !player.inventory.containerBelt.IsFull()) { //CODE }
-
You probably wouldn't want to just check .IsFull if you are giving out more than 1 item.
Check out
Kits for Rust | Oxide
Kits plugin does this type of check
Search for the line that has "if ((player.inventory.containerBelt.capacity". It checks to see if the number of available slots is less than the amount of items you are trying to give. -
Thanks - I'm only giving out one item; I'm not that generous
I'll give that a go! -
Code:if (!item.MoveToContainer(container)) { //failed to move! (full) }
-
Thanks Shady, that also is useful to know