Add drop to Inventory
This commit is contained in:
@@ -57,13 +57,13 @@ namespace reallife_gamemode.Server.Managers
|
||||
return itemList.Find(i => i.Name.ToLower() == name.ToLower());
|
||||
}
|
||||
|
||||
public static void RemoveUserItem(Entities.User user, UserItem item)
|
||||
public static void RemoveUserItem(Entities.User user, UserItem item, int amount)
|
||||
{
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
var userItem = dbContext.UserItems.FirstOrDefault(i => i.Id == item.Id);
|
||||
|
||||
userItem.Amount--;
|
||||
userItem.Amount -= amount;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
@@ -250,7 +250,6 @@ namespace reallife_gamemode.Server.Managers
|
||||
{
|
||||
usableItemObj.Use(userItem, player);
|
||||
player.TriggerEvent("removeItem", itemId, amount);
|
||||
fItem.Amount -= amount;
|
||||
}
|
||||
break;
|
||||
case "drop":
|
||||
@@ -269,10 +268,9 @@ namespace reallife_gamemode.Server.Managers
|
||||
|
||||
if (iItem is IUsableItem usableItemObj2)
|
||||
{
|
||||
fItem.Amount -= amount;
|
||||
usableItemObj2.Use(userItem, player);
|
||||
NAPI.Object.CreateObject(1017479830, new Vector3(player.Position.X, player.Position.Y, player.Position.Z), new Vector3(0, 0, 0), 0);
|
||||
NAPI.TextLabel.CreateTextLabel(iItem.Name + " ~s~(~y~" + amount + "~s~)", new Vector3(player.Position.X, player.Position.Y, player.Position.Z), 5, 0.5f, 4, new Color(255, 255, 255), false, 0);
|
||||
Random r = new Random();
|
||||
//fItem.Amount -= amount;
|
||||
usableItemObj2.Drop(userItem, player);
|
||||
player.TriggerEvent("removeItem", itemId, amount);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user