How can I get when the player open his inventory by binding a key.
But if he close the inventory with ESC there is nothing I can do.
What can I do to get if he did close his inventory?
Check if user is using his inventory
Discussion in 'Rust Development' started by Reynostrum, Jul 1, 2016.
-
Wulf Community Admin
Take a look at my QuickSort plugin, it has something that does that.
-
Hi Wulf. I did look the code, but I don't get it.
Thats what I need?Code:class UIDestroyer : MonoBehaviour { void PlayerStoppedLooting(BasePlayer player) { // Destroy existing UI string gui; if (guiInfo.TryGetValue(player.userID, out gui)) { CuiHelper.DestroyUi(player, gui); } Destroy(this); } } -
What that code doing is saying if (player) is in the guiInfo then remove his GUI.Code:
void OnLootPlayer(BasePlayer player) => SortUi(player); void OnLootEntity(BasePlayer player) => SortUi(player);
So essentially when a player loots himself(opens his inventory) it triggers a hook which adds him to a dictionary or list. When that player ends looting then it removes his GUI and him from the dictionary. T
Code:guiInfo[player.userID] = CuiHelper.GetGuid();//Adds the player to a list/dictionary.
At least i'm fairly certain that's what it doesCode:class UIDestroyer : MonoBehaviour { void PlayerStoppedLooting(BasePlayer player) { // Destroy existing UI string gui; if (guiInfo.TryGetValue(player.userID, out gui)) { CuiHelper.DestroyUi(player, gui); } Destroy(this); } }//This is saying if the player has his gui open(added upon looting) then destroy it.
-
Yes, but OnLootEntity, and OnLootPlayer does not work with the player it self. Just for other players, entities. I think.
-
I'm not sure exactly. I can't do much as im on a laptop D:
