Jump to content
DcrClub

How to move items to inventory on the server side

Recommended Posts

Simply on the server side, I have tried several ways to generate an item on the map and then transfer the item to the designated inventory, for example:

Man.c file

    ServerTakeEntityToCargo

    ServerTakeEntityToInventory

    ServerTakeEntityAsAttachment

    ServerTakeEntityToTargetCargo

Methods of this class, Occasionally, there will be a problem. After several items are moved to the inventory, the items will be stacked, that is, all the items are crowded on the first grid, or the moved items cannot be moved in the target inventory, and the data of the server and the client are not synchronized correctly.

However, in the implementation of these methods, I have observed that the refresh operation has been called. Will this be network synchronization?

Or which method can be perfectly solved, operating items on the server side and synchronizing perfectly with the client side?

Share this post


Link to post
Share on other sites
On 7/18/2024 at 6:54 AM, DcrClub said:

Simply on the server side, I have tried several ways to generate an item on the map and then transfer the item to the designated inventory, for example:

Man.c file

    ServerTakeEntityToCargo

    ServerTakeEntityToInventory

    ServerTakeEntityAsAttachment

    ServerTakeEntityToTargetCargo

Methods of this class, Occasionally, there will be a problem. After several items are moved to the inventory, the items will be stacked, that is, all the items are crowded on the first grid, or the moved items cannot be moved in the target inventory, and the data of the server and the client are not synchronized correctly.

However, in the implementation of these methods, I have observed that the refresh operation has been called. Will this be network synchronization?

Or which method can be perfectly solved, operating items on the server side and synchronizing perfectly with the client side?

Man, why do you need to move item to the inventory when you can simply create it inside player's inventory?

 

If you need to create a single item that can be stucked you quantity of EntityAI, that will make the trick. Like create item on the ground -> EntityAI itemOnGround;

itemOnGround.SetQuantity(1);

That's will done your trick and you can do the same in the loops if it's required to create many items of same class.

Exactly the same working for Players/Cars/Containers. Like EntityAI item = player.GetaInventory().CreateInInventory("class");

item.set Quantity(1);

And so on, so on, ...

If you wish to get Entity as Attachment - use slots names for Accessing the EntiryAI Item and spawn on it. In default main.c theres example when create character and checking shirt or foots, or legs - it's using slot. That the point get slot -> get item from slot -> create attachment.

But keep in mind that when you got EntityAI from Slot -> always check is EntityAI NULL or not. If NULL -> slot is empty, if not - go on. Same for item you shall check is SholderL slit has Weapon or is it a shovel?

That's most important stuff yeah many checks long code but will cover most of possible "soft points" causing death of server in any bad cases...

Share this post


Link to post
Share on other sites
On 7/21/2024 at 7:56 PM, Sid Debian said:

Man, why do you need to move item to the inventory when you can simply create it inside player's inventory?

 

If you need to create a single item that can be stucked you quantity of EntityAI, that will make the trick. Like create item on the ground -> EntityAI itemOnGround;

itemOnGround.SetQuantity(1);

That's will done your trick and you can do the same in the loops if it's required to create many items of same class.

Exactly the same working for Players/Cars/Containers. Like EntityAI item = player.GetaInventory().CreateInInventory("class");

item.set Quantity(1);

And so on, so on, ...

If you wish to get Entity as Attachment - use slots names for Accessing the EntiryAI Item and spawn on it. In default main.c theres example when create character and checking shirt or foots, or legs - it's using slot. That the point get slot -> get item from slot -> create attachment.

But keep in mind that when you got EntityAI from Slot -> always check is EntityAI NULL or not. If NULL -> slot is empty, if not - go on. Same for item you shall check is SholderL slit has Weapon or is it a shovel?

That's most important stuff yeah many checks long code but will cover most of possible "soft points" causing death of server in any bad cases...

The application scenario requires that because I have some independent item attributes that need to persist in the context, I don't want to delete and create this item frequently. Then transfer the variable attributes, so I need to maintain a method frequently, add or delete variables.

That's why I need to transfer items in different containers.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×