Jump to content
Luft08

Weird, just too weird... AI with no torso or legs

Recommended Posts

In the mission I'm working on I spawn a zippo and AI unit for each player. When I run the mission on my PC it's all good but when tested on a dedicated server the AI that I group to each player turns out as a floating disembodied head with floating arms.

 

BTW I spawn many units but only the ones I group to the players come out without legs and torso.

 

One more thing and I don't know if it's important but the head and arms are bare. (No helmet and no shirt/armor)

 

I'm at a loss and am almost ready to give up on multiplayer missions. It's always something... Always...

 

Any Ideas what could cause this. I really have no clue where to even start looking.

 

Here is the code that spawns the opening scene:

if(!isServer) exitWith {};

private _playerCount = count activePlayers;
for "_c" from 1 to _playerCount do {
	private _pos = [];
	private _dir = 0;
	private _unitPos = [];
	switch (_c) do {
		case 1: {
			_pos = [9090.05,7411.64,0];
			_dir = 268.824;
			_unitPos = [9091.51,7409.89,0]; // direction for all units is: 181.759
		};

		case 2: {
			_pos = [9102.89,7409.81,0];
			_dir = 279.820;	
			_unitPos = 	[9103.71,7408.25,0];		
		};

		case 3: {
			_pos = [9110.54,7407.27,0];
			_dir =	279.820;
			_unitPos = [9111.25,7405.63,0];
		};

		case 4: {
			_pos = [9118.3,7405.51,0];
			_dir = 	279.820;
			_unitPos = [9118.9,7403.93,0];
		};

	};

	private _zippo = "uns_M132" createVehicle _pos;
	_zippo setDir _dir;
	_zippo addMagazineCargoGlobal ["APERSBoundingMine_Range_Mag",30];	

	zippoArray pushBack _zippo;
	private _group = createGroup[west,true];
	private _unit = _group createUnit["uns_US_2MI_DRV", _unitPos, [], 0, "FORM"];
	private _index = _c - 1;
	private _player = activePlayers select _index;
	[_unit] joinSilent _player;

};

private _handle = [] execVM "scripts\common\getBldgList.sqf";
waitUntil{scriptDone _handle};

[] execVM "scripts\setupRiverAmbushes.sqf";

private _mortarCount = (floor random 6) + 3;

_handle = [_mortarCount] execVM "scripts\spawnEnemyMortar.sqf";
waitUntil{scriptDone _handle};

[] execVM "scripts\spawn25thInf.sqf";

 

Share this post


Link to post
Share on other sites

UPDATE:

I changed from using the createUnit to using the BIS_fnc_spawnGroup function but no joy. Then I thought maybe I was setting the scene before the Arma mission could properly initialize so as a test I put a 10 sec delay before spawning the unit. That worked but obviously not a good solution.

 

At the beginning of my init.sqf file I do have: 

waituntil {!isnil "bis_fnc_init"};  

 

Is there a proper way to wait for all the mission stuff to initialize when running on a dedicated server? Why doesn't this problem pop up when I run the mission from my PC?

Share this post


Link to post
Share on other sites
waitUntil{ getClientStateNumber >= 10 /*"BRIEFING READ"*/ && { time > 0 } };

?

  • Like 2

Share this post


Link to post
Share on other sites
6 hours ago, pierremgi said:

activePlayers ? I know allPlayers... for playableUnits (probably in your case)

 

see also initialization order.

insert a little sleep just after creating a unit/vehicle. (0.1 sec.)

 

 

 

 

activePlayers is a global variable. I should have mentioned that. 

activePlayers = [] call BIS_fnc_listPlayers;

Share this post


Link to post
Share on other sites
2 hours ago, Larrow said:

waitUntil{ getClientStateNumber >= 10 /*"BRIEFING READ"*/ && { time > 0 } };

?

Thanks, I'll give it a shot.

 

UPDATE: It worked! Thanks.  (So much to learn...)

  • Like 1

Share this post


Link to post
Share on other sites

Not sure to understand how getClientStateNumber works in a server only code, for several clients...
 

Spoiler

 

What I do, for players after JIP, is a code in initPlayerLocal.sqf, or initPlayerServer.sqf,  or in init field of the unit waiting for isPlayer ...

If you spawn a vehicle/unit (which will be owned by player anyway), no matter if you spawn it on server or client.

 

 

  • Like 1

Share this post


Link to post
Share on other sites
19 hours ago, pierremgi said:

Not sure to understand how getClientStateNumber works in a server only code, for several clients

As it is not. The code is server execute only and getClientStateNumber is checking just the servers current state. As per the wiki page getClientStateNumber works on clients and server including dedicated, perhaps the name is confusing and should have been called getGameStateNumber rather than client.

 

  • Like 3

Share this post


Link to post
Share on other sites
4 hours ago, Larrow said:

As it is not. The code is server execute only and getClientStateNumber is checking just the servers current state. As per the wiki page getClientStateNumber works on clients and server including dedicated, perhaps the name is confusing and should have been called getGameStateNumber rather than client.

 

That was a head scratcher for me also but I finally came to that conclusion. I wish that there was a definitive book outlining all of the intricacies of mission programming for Arma but thank god there are so many people willing to share their knowledge or I would be sunk. 

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

×