Inventory System

English Variant: (I used a translator so there may be mistakes) I have created an inventory system for weapons, but there is a problem. The game will be online and work on a dedicated server. The system itself works fine, but there is a nuance. Let’s say I have two clients. I play for the first client. If I pick up a weapon on the first client, it will be added to the first and second client. Here is a similar log:

Before picking up:
Client 0: Inventory empty
Client 1: Inventory empty

After picking up from the first client, total two clients:
Client 0: Inventory has one weapon
Client 1: Inventory has one weapon

Help me to make it so that if I pick up a weapon on the first client, it would be added to the first client, but not to all clients.

Русский вариант:

Я создал систему инвентаря для оружия, но есть проблема. У меня будет онлайн игра, и она будет работать на выделенном сервере. Система сама по себе работает нормально, но есть нюанс. Допустим, у меня два клиента. Я играю за первого клиента. Если я подбираю оружие на первом клиенте, оно добавляется ко второму клиенту и первому клиенту. Вот похожий лог:

До подбора :
Клиент 0: Инвентарь пустой
Клиент 1: Инвентарь пустой

После подбора с первого клиента, всего два клиента:
Клиент 0: Инвентарь имеет одно оружие
Клиент 1: Инвентарь имеет одно оружие

Помогите мне сделать так, чтобы если я подобрал оружие на первом клиенте, оно добавлялось к первому клиенту, но не ко всем клиентам.

Извините за возможные ошибки!

Hey,

Have you got more info here or can you post some screenshots? It sounds like your picking it up on the Client and then sending that information to the server where it is adding to all Players. I think this is likely where your going wrong. Alternatively if your using a Multicast to tell Clients that a specific Client picked something up then you will need to ensure your telling them which client it was.

Hi, sorry, I can’t send screenshots because I completely deleted the inventory system to remake it correctly from scratch.

However, my player has a line trace. If it hits the right object, it sends a message from the Blueprint Interface, and then this message adds the item to the actor component inventory weapon.

I can create a rough logic of how it was, but with fewer checks and so on.
Here’s the approximate logic. It’s not complete; I just need to understand how to replicate it correctly:


sorry for the mistakes

as long as the component replicates and the Inventory is set to replicated you’re all good.

But make sure it happens on server, so whatever calls the Interface should be RunOnServer.

and while i assume the above is just an exmaple, the inventory should be on the Actor not the target yeah?

To answer your last question, my inventory is in the actor component, and it is in the player character.

Thank you all for your help, I was fix the problem. :grinning: