Jump to content
xjoker_

[Solved] player inventory not synchronized between client/server ?

Recommended Posts

Hello. 

I have a problem on my server. 

So here is a video

 

 

What does it show

  1. I'm totally naked, no items
  2. I execute this code locally
player setUnitLoadout [[],[],[],["U_C_Poloshirt_redwhite",[]],[],["B_Carryall_oli",[["30Rnd_556x45_Stanag",3,7]]],"","",[],["","","","","",""]];
  • I execute this code globally (civ_6 is the player)
_who = if(isDedicated) then {"SERVER"} else {"PLAYER"};
diag_log format["%1 || inventory : %2",_who,(getMagazineCargo backpackContainer civ_6)];
  • At this point, both client and server logs show 3 mags in my backpack
  • I drop 3 mags on the floor
  • I diag_log again
  • Now client logs show nothing (empty array) which is normal, but the server logs still show 3 mags in the backpack. 

Note : i used getMagazineCargo backpackContainer, but I have the same results with other commands like getUnitLoadout . 

Note2 : If I execute 

player setUnitLoadout getUnitLoadout player

The server is updated with the right values. 

 

Why it's a problem : Because I save the loadout of players in a database, using the onPlayerDisconnected event which is executed on the server. So if the server isn't synchronized as it should, I save the wrong gear and people usually spawns with it when they reconnects...

Share this post


Link to post
Share on other sites

Someone told me that it comes from setUnitLoadout which seems to create a broken backpack and that i should use addBackpack instead... 

So i guess i'll have to make my own version of setUnitLoadout 😑

Share this post


Link to post
Share on other sites
3 hours ago, killzone_kid said:

or wait for the fix (not actually saying there will be one)

I'm not even sure that BIS is aware of this

 

12 hours ago, xjoker_ said:

Someone told me that it comes from setUnitLoadout which seems to create a broken backpack and that i should use addBackpack instead... 

So i guess i'll have to make my own version of setUnitLoadout 😑

I confirm that using a custom script to set the loadout fix the issue. 

Problem "solved" . 

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

×