Drop WeaponDeal Items on Disconnect, And equip WeaponDeal Box on Login (in case of Server Crash).

This commit is contained in:
2021-04-14 03:38:00 +02:00
parent f006fdffe9
commit 590abf5165
2 changed files with 45 additions and 2 deletions

View File

@@ -11,6 +11,8 @@ using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Wanted;
using ReallifeGamemode.Database.Entities;
using System;
using System.Collections.Generic;
using ReallifeGamemode.Server.Inventory.Interfaces;
/**
* @overview Life of German Reallife - Event Login (Login.cs)
@@ -148,6 +150,19 @@ namespace ReallifeGamemode.Server.Events
player.Dimension = 0;
}
List<UserItem> fItem = dbContext.UserItems.Where(u => u.UserId == user.Id).ToList();
foreach (var item in fItem)
{
IItem iItem = InventoryManager.GetItemById(item.ItemId);
if (iItem is IWeaponDealItem obj)
{
player.SyncAnimation("carryBox");
player.AddAttachment("ammobox", false);
NAPI.Player.SetPlayerCurrentWeapon(player, WeaponHash.Unarmed);
break;
}
}
player.TriggerEvent("draw", player.Name, player.Handle.Value);
NAPI.Task.Run(() =>
{