Jump to content
Sign in to follow this  
MrSanchez

Dedicated Server spawned weaponholders take > 1,5 mins to sync (network issue?)

Recommended Posts

Hey everyone,

I'm experiencing some issues with a script that spawns random weapons, mags, items and backpacks in buildings within a certain radius.

Now the weapons won't spawn immediately after executing the code, instead they all mass-spawn at once (only when executed on the dedicated server) after a ~1:45 min delay.

Executed client sided while on the dedi, the weapons spawn and sync instantly.

I've verified the code is executed using diag_logs, there are no errors.

A snippet of the weapon part:

	if (random 100 < 95 && (((_position) select 0 > 0))) then 
	{
	_selected = _weps select (_keys select floor(random(count _keys)));
	_weapon = _selected select 0;
	_mag=(getArray (configFile/"Cfgweapons"/_weapon/"magazines")) select 0;
	_weap = "GroundWeaponHolder" createVehicle [0,0];
	sleep sDelay;
	_weap addMagazineCargoGlobal [_mag,(2 + (round (random 4)))];
	_weap addWeaponCargoGlobal [_weapon,1];
	diag_log format ["weap = %1; weapon = %2, mag = %3",typeof _weap,_weapon, _mag];
	_weap setPos [(_position select 0),(_position select 1),((_position select 2))];
	};

I've tried adding a delay between the spawning of the weaponholder and the adding of cargo to it, I've tried sDelay up to 0.10 seconds.

I've also used a debug console while on the dedi and spawned in a single weaponholder using "Server Exec" and it spawned immediately (and synced for everyone else) on my position..

There's no trace of any errors in the server log, though there is something that pops up on the log which may be related:

2015/05/28, 13:37:57 "complete"
2015/05/28, 13:40:30 Performance warning: SimpleSerialization::Read 'BIS_fnc_MP_packet' is using type of ,'CODE' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types

Does anyone have any idea what may be causing this? When executing this script on a client, it spawns and syncs these weapons (for everyone on the server) immediately, that's what's really bothering me...

Kind regards,

Sanchez

Edited by PhonicStudios

Share this post


Link to post
Share on other sites

After taking painkillers to suppress the headache that I've received from having this issue, I finally found the issue. It is not the creation of the weaponholders nor the adding of weapons that is causing a huge delay, it is the teleportation (setPos) of these items that is.

The weapons were synced alright but they spawned at [0,0] on the ocean floor and were teleported much much later.

So this might be an issue with setPos, but now that I found the cause, I'm sure I can fix this.

:yay:

Kind regards,

Sanchez

Share this post


Link to post
Share on other sites

Regarding the setPos part of your post, I have the exact same issue when trying to move two fences apart (kind of sliding gates style). Even if the pos update is like 0.5+/- or whatever it takes too much time to sync...

I also figured that no matter what type of object you try to setPos (big or small ones) the time needed to complete a sync is inconstant, well I guess that also depends on the queue length you might say but still I'm 100% sure that the command effects can be optimized a bit.

Share this post


Link to post
Share on other sites

Do you create your weapon holder right at the server start? (CfgFunctions preinit\postinit, vehicles init line execution time)

Share this post


Link to post
Share on other sites

I was able to hotfix the issue by using the position parameter on createvehicle itself, setPos(ATL) was definitely the problem.

SaMatra, in my case, I used a heavily modified version of an old script you once helped me with that spawns weapons in buildings in a certain radius. This happened after mission start using init.sqf

I haven't checked whether the issue still persists since this thread though (Not sure if this thread was made before or after 1.46)

Kind regards,

Sanchez

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
Sign in to follow this  

×