Jump to content
Fiodor

spawnGroup in Dedicated Multiplayer

Recommended Posts

Hi there, name's Fedor again, this time around I am trying to spawn units in a dedicated server. 
Currently I tried the following to no avail:

if (!isServer) exitWith {};   
if (isServer) then{   
//tried both with and without the isServer? verification

_spawnUnits = ["O_Soldier_F"];  

_obj_base = _this select 3 select 0;
_count = _this select 3 select 1;

_skill = [0.1, 0.15, 0.25];
_ammo_count = [0.0, 0.1];

_max_distance = 2;  
_max_azimuth = 360;  


 for "_x" from 0 to _count do  
 {  
  _spawnRadius = random _max_distance;  
  _spawnAzimuth = random _max_azimuth;


  _spawnObj = selectRandom synchronizedObjects _obj_base;


  _randomPos = _spawnObj getPos [_spawnRadius, _spawnAzimuth];  
  
  _curElem = selectRandom _spawnUnits;


 //first try, should only be local, doesn't do nothing in dedicated server
  [_randomPos, EAST, _spawnUnits, [], [], _skill, _ammo_count, [], random 360] call BIS_fnc_spawnGroup; 

  //Afterwards I tried this
 //same deal, try to exectute it through BIS_fnc_MP, nothing on dedicated server works in SP
 _parameters = [_randomPos, EAST, _spawnUnits, [], [], _skill, _ammo_count, [], random 360];
 [_parameters, "BIS_fnc_spawnGroup", true] spawn BIS_fnc_MP;

   //And also, this.
 //try to execute it through remoteExec, still nothing... this one doesn't work in neither SP nor MP
 [_randomPos, EAST, _spawnUnits, [], [], _skill, _ammo_count, [], random 360] remoteExec ["call BIS_fnc_spawnGroup", 0, true]; 
 };  
 
};

I have tried all combinations of isServer and the simple BIS_fnc_spawnGroup in combination with BIS_fnc_MP  or remoteExec. Meaning I tried 6 versions

  • one with isServer verification and spawnGroup,
  • one without isServer and with spawnGroup
  • one with isServer verification and with remoteExec + spawnGroup
  • one without isServer and with remoteExec + spawnGroup
  • one with isServer verification and with BIS_fnc_MP + spawnGroup
  • one without isServer and with BIS_fnc_MP + spawnGroup

 

It is after this extensive and quite puzzling testing, that I've come here to ask for your wisdom in spawning units in a dedicated server (hosted as a dedicated machine).

 

Have I perhaps flunked a parameter in function (in SP works fine) or perhaps is there some sort of MP previous steps I haven't properly followed?

 

Edit:

I have to mention that I've tried to run this from addAction in a laptop, this is the code inside the laptop

//uses spawn group only
this addAction ["spawn 5 units", "scripts\spawnOnSyncedObjs.sqf", [trigger_spawn, 5] ]; 
this addAction ["noSrv - spawn 5 units", "scripts\spawnOnSyncedObjs_noSrv.sqf", [trigger_spawn, 5] ]; 


//uses spawn group with remote
this addAction ["r - spawn 5 units", "scripts\spawnOnSyncedObjs_remote.sqf", [trigger_spawn, 5] ]; 
this addAction ["rNoSrv - spawn 5 units", "scripts\spawnOnSyncedObjs_remoteNoSrv.sqf", [trigger_spawn, 5] ]; 


//uses BIS_fnc_MP
this addAction ["mp - spawn 5 units", "scripts\spawnOnSyncedObjs_mp.sqf", [trigger_spawn, 5] ]; 
this addAction ["mpNoSrv - spawn 5 units", "scripts\spawnOnSyncedObjs_mpNoSrv.sqf", [trigger_spawn, 5] 

Share this post


Link to post
Share on other sites
_this select 3 select 0;

That leads me to believe you're running this from an addAction, which will never be run as a server since only clients can activate it so you never run your code.

 

You'll need to use remoteExec to trigger the spawn on the server or some kind of variable based thing.

 

This appears to work.  Had a gameLogic named myBase sync'd to two helipads.  Used this to call it.  Got 4 guys (usually 3 on one pad 1 on the other)

this addAction["Spawn", "spawnStuff.sqf",[myBase, 3]];
params["_object", "_caller", "_id", "_args"];
_args params["_obj_base", "_count"];

_spawnUnits = ["O_Soldier_F"];  
_skill = [0.1, 0.15, 0.25];
_ammo_count = [0.0, 0.1];
_max_distance = 2;  
_max_azimuth = 360;  

for "_x" from 0 to _count do {  
	_spawnRadius = random _max_distance;  
	_spawnAzimuth = random _max_azimuth;
	_spawnObj = selectRandom synchronizedObjects _obj_base;
	_randomPos = _spawnObj getPos [_spawnRadius, _spawnAzimuth];  
	_curElem = selectRandom _spawnUnits;

	//Run BIS_fnc_spawnGroup on the server only.
	[_randomPos, EAST, _spawnUnits, [], [], _skill, _ammo_count, [], random 360] remoteExec ["BIS_fnc_spawnGroup", 2]; 
};  

Share this post


Link to post
Share on other sites

Indeed I am using an action to trigger it, I forgot to mention it, sorry. Will add it now to the original post. 

Will definetly try this tonight and check the results.

 

Thanks for the reply.

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

×