delete illegal items when dead
This commit is contained in:
@@ -47,6 +47,8 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.ToggleInventory(InventoryToggleOption.HIDE);
|
||||||
|
|
||||||
if (player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant"))
|
if (player.HasData("IsCarryingPlant") || player.GetData<bool>("IsCarryingPlant"))
|
||||||
{
|
{
|
||||||
var currentModel = player.GetData<int>("HoldingCannabisPlant");
|
var currentModel = player.GetData<int>("HoldingCannabisPlant");
|
||||||
@@ -241,6 +243,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
public void RespawnPlayerAtHospital(Player player)
|
public void RespawnPlayerAtHospital(Player player)
|
||||||
{
|
{
|
||||||
logger.LogInformation("Player {0} respawned at the hospital", player.Name);
|
logger.LogInformation("Player {0} respawned at the hospital", player.Name);
|
||||||
|
InventoryManager.RemoveIllegalItemsFromInventory(player);
|
||||||
player.SetData("isDead", false);
|
player.SetData("isDead", false);
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -685,5 +685,24 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
//client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
//client.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void RemoveIllegalItemsFromInventory(Player player)
|
||||||
|
{
|
||||||
|
if (!player.IsLoggedIn())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = player.GetUser();
|
||||||
|
|
||||||
|
List<UserItem> items = GetUserItems(player);
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (!GetItemById(item.ItemId).Legal)
|
||||||
|
{
|
||||||
|
RemoveUserItem(user, item, item.Amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user