addserver function to set inventory show
This commit is contained in:
@@ -21,14 +21,14 @@
|
|||||||
invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html');
|
invBrowser = mp.browsers.new('package://assets/html/inventory/inventory.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add('inventoryShow', () => {
|
mp.events.add('inventoryShow', (force = undefined) => {
|
||||||
if (!globalData.InMenu && !loaded) {
|
if (!globalData.InMenu && !loaded || force === true) {
|
||||||
globalData.InMenu = true;
|
globalData.InMenu = true;
|
||||||
mp.gui.cursor.show(true, true);
|
mp.gui.cursor.show(true, true);
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
invBrowser.execute(`showInventory()`);
|
invBrowser.execute(`showInventory()`);
|
||||||
} else if (loaded) {
|
} else if (loaded || force === true) {
|
||||||
globalData.InMenu = false;
|
globalData.InMenu = false;
|
||||||
mp.gui.cursor.show(false, false);
|
mp.gui.cursor.show(false, false);
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
|||||||
@@ -769,7 +769,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
if (!player.IsLoggedIn() || player.GetData<bool>("isDead")) return;
|
if (!player.IsLoggedIn() || player.GetData<bool>("isDead")) return;
|
||||||
if (player.GetData<bool>("isDead")) return;
|
if (player.GetData<bool>("isDead")) return;
|
||||||
|
|
||||||
player.TriggerEvent("inventoryShow");
|
player.ToggleInventory();
|
||||||
InventoryManager.SetBackpackItems(player);
|
InventoryManager.SetBackpackItems(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -477,5 +477,17 @@ namespace ReallifeGamemode.Server.Extensions
|
|||||||
if (player.GetUser().Wanteds > 0)
|
if (player.GetUser().Wanteds > 0)
|
||||||
PositionManager.cuffPoints.Add(player);
|
PositionManager.cuffPoints.Add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ToggleInventory(this Player player, InventoryToggleOption option = InventoryToggleOption.TOGGLE)
|
||||||
|
{
|
||||||
|
if(option == InventoryToggleOption.TOGGLE)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("inventoryShow");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.TriggerEvent("inventoryShow", option == InventoryToggleOption.SHOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
ReallifeGamemode.Server/Util/InventoryToggleOption.cs
Normal file
11
ReallifeGamemode.Server/Util/InventoryToggleOption.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Util
|
||||||
|
{
|
||||||
|
public enum InventoryToggleOption
|
||||||
|
{
|
||||||
|
TOGGLE, SHOW, HIDE
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user