Page MenuHomeFeedback Tracker

RegisterNetSyncVariable on server side in PlayerBase class cause cuts and bleeding wihout blood loss for players who do not have client part of server mod
Closed, ResolvedPublic

Description

We use server mod for admins and client part of this mod on admin players and server
RegisterNetSyncVariableBool (and may be RegisterNetSyncVariableInt) on server side cause cuts and bleeding wihout blood loss for players who not have client part of our admin mod
Also Restraining stops working correctly - unrestraining menu is not activated, not blocked inventory opens and locked restrain item can be removed from the hands and drop on ground or put to inventory

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Operating System Version
Windows Server 2008 R2
Category
General
Steps To Reproduce

modded class PlayerBase extends ManBase
{
private bool m_isAdmin = false;

void PlayerBase()
{

		RegisterNetSyncVariableBool("m_isAdmin");

}

override void OnVariablesSynchronized()
{

		super.OnVariablesSynchronized();
		setAdminPlayer(m_isAdmin);

}

void setAdminPlayer(bool state)
{

		if (!IsAlive()) return;
		m_isAdmin = state;
		SetFlags(EntityFlags.SYNCHRONIZATION_DIRTY, true);
		SetSynchDirty();

}
}

Additional Information

That code is enough to cause these bugs

Event Timeline

borizz.k created this task.Sep 11 2019, 8:45 PM
borizz.k edited Steps To Reproduce. (Show Details)
Geez changed the task status from New to Assigned.Sep 12 2019, 2:50 PM

-ignoreMod is not a planned feature IIRC so this will never be a problem.

Geez added a subscriber: Geez.Sep 13 2019, 1:27 PM
This comment was removed by Geez.

This is a constructor and cannot be override.
Attempting to call super.PlayerBase() cause an error

Geez added a comment.Sep 13 2019, 2:52 PM

void Init() has to be called in class constructor in order to initialize and register other synced variables. This is likely the reason for the broken bleeding and other issues besides.
Safest way to achieve this would be:
void PlayerBase()
{

Init();
RegisterNetSyncVariableBool("m_isAdmin");

}
This would ensure the new variable is registered after the original ones are, and avoid possible mismatch in variable indexing. Alternatively, you can just modify the void Init() function and add the synced variable at the end of the list there. Either approach should work

borizz.k added a comment.EditedSep 13 2019, 2:56 PM

Dear Geez

//
void PlayerBase()
{

Init();
RegisterNetSyncVariableBool("m_isAdmin");

}
//

As a result, we have 2 calls init()
Becouse Constructor in native class and modded class will be combined
Try it yourself

NiiRoZz added a subscriber: NiiRoZz.EditedSep 13 2019, 7:06 PM

In expansion we have multiple of registernetsync and never experienced this issue.

This sounds more a mod that you are using breaking it.

Did you tried only your mod ?

And prefer to override Init instead inside contructor, and call super. More friendly for any other mods

NiioZz
If i use init() result the same
If i register and sync network variables on server and not register this variables on clients, clients bleeding

Why you would register variable on server but on client, for sure this will make clients bleeding or anything related, a net sync variable should be client side and server side. If you are doing it only server side this will make a shift in bitstream and fucked up every other system using netsyncvar on the client.

Just for a reply to this report, it's something due to how you handle net sync var, not how the game has been made, you should ask this in dayz modding discord before here.

nonsense...
why blеeding? why not death immediately?
why it is impossible to filter on client side and process only registered variables? is it difficult for programmers?

It's not nonsense, you have a bitstream between client and server, if you send more bit from the server to the client ( by adding only a registernetsync at server side) you will have a shift inside your bitstream, and why you bleeding ? because bleeding is just only 1 bit, so if you have a shift of one, there is a bit of 1 shifting to the right for example, and so make you bleeding.

NetSync variable should be added client side and server side ONLY. You can't have only client side or only server side.

You can't process only registered variable, because registered variable is send to a bitstream, so you are processing only in the order you have registered variable, so you are sure server and client get exactly the same info.

@Geez Sorry to ping you, but you can close this ticket, it's not a problem inside the game, but just a problem how the guy used it. If this would be the case every mod would already have been reported this bug. Because everyone using RegisterNetSync. I'm in Expansion team, and never had this problem. Problem only occurs if mod actually not registerNetSync var client side AND server side.

NiiRoZz
I understood this and already rebuild our mod...
Thx

Geez closed this task as Resolved.Sep 18 2019, 10:21 AM
Geez claimed this task.