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
Assigned, UrgentPublic

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.Wed, Sep 11, 8:45 PM
borizz.k edited Steps To Reproduce. (Show Details)
Geez changed the task status from New to Assigned.Thu, Sep 12, 2:50 PM

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

Geez added a subscriber: Geez.Fri, Sep 13, 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.Fri, Sep 13, 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.EditedFri, Sep 13, 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.EditedFri, Sep 13, 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.