Beispiel #1
0
        public void RemoveWorldItemObject(IPlayer player, uint entityId, int itemID)
        {
            CharacterEntity sender = player.GetAccountEntity().characterEntity;

            DynamicObject dynamicObject = EntityHelper.GetById(entityId);

            dynamicObject.TryGetData("dynamicObject:ownerAccountId", out int dynamicObjectOwnerId);

            Alt.Log($"Account ID: ${dynamicObjectOwnerId}");

            CharacterEntity dynamicObjectOwner = PlayerExtenstion.GetPlayerByAccountId(dynamicObjectOwnerId).characterEntity;

            if (sender != dynamicObjectOwner)
            {
                player.SendErrorNotify("Wystąpił bląd", "Nie jesteś właścicielem tego obiektu");
                return;
            }

            ItemEntity itemToDelete = player.GetAccountEntity().characterEntity.ItemsInUse.FirstOrDefault(item => item.Id == itemID);

            player.GetAccountEntity().characterEntity.ItemsInUse.Remove(itemToDelete);

            EntityHelper.Remove(dynamicObject);
            dynamicObject.Destroy();
        }