Add /eat command
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Commands;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Inventory.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -45,5 +47,28 @@ namespace reallife_gamemode.Server.Managers
|
||||
{
|
||||
return itemList.Find(i => i.Id == id);
|
||||
}
|
||||
|
||||
public static IItem GetItemByName(string name)
|
||||
{
|
||||
return itemList.Find(i => i.Name == name);
|
||||
}
|
||||
|
||||
public static void RemoveUserItem(Entities.User user, UserItem item)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var userItem = dbContext.UserItems.FirstOrDefault(i => i.Id == item.Id);
|
||||
|
||||
userItem.Amount--;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
if(userItem.Amount == 0)
|
||||
{
|
||||
dbContext.Remove(userItem);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user