Jump to content
Sign in to follow this  
jacmac

Getting a Player ID for publicVariableClient

Recommended Posts

I need some advice for getting a player ID for publicVariableClient. Normally, I would simply have the client publicVariableServer and get the info via "owner player". The catch here is that I'm trying to do this with a headless client. The headless client connect just fine, but to publicVariableServer the player information, I'm trying to waitUntil {sleep 0.1;!isNull player}, but the headless client never got past that. So I've logged what the player is reporting as at the beginning of init.sqf to the ARMA.rpt and the headless client is reporting that the player is Null-Object! Yikes! A Headless Client appears to not be considered a 'player'. How can I get the ID of this non-player player to the server?

This is what the log looks like for a headless client on startup. Notice that PostInit is messed up:

[30627,348.452,0,"XEH: PreInit Started. v1.0.4.198. MISSINIT: missionName=Test_HC, worldName=Altis, isMultiplayer=true, isServer=false, isDedicated=false"]
[30627,348.5,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_cache_disable.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
[color="#0000CD"][b]"<NULL-object>, 0.26 Checking for !isNull player"
[31143,359.573,3.832,"WARNING: PostInit did not finish in a timely fashion"]
[31144,359.593,3.852,"WARNING: TimedOut waiting for player object to be ready. Continueing PostInit without Player ready"][/b][/color]
[31145,359.612,3.852,"XEH: PostInit Started"]
[31145,359.64,3.852,"CBA_VERSIONING: cba=1.0.4.198, "]
[31145,359.648,3.852,"XEH: PostInit Finished. State: _isClient=true, _isJip=true, _isDedClient=true, _isServer=false, _isDedServer=false, _playerCheckDone=true, _sp=false, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=2, _sessionId=4, _level=0, _timeOut=true, _game=3, BIS_functions=L Alpha 1-1:1 REMOTE, group=L Alpha 1-1, player=<NULL-object>, _playerType="", _playerGroup=<NULL-group>"]
[31145,359.65,3.872,"CBA_VERSIONING_SERVER: cba=1.0.4.198, "]

Here is what it looks like for a regular player:

[59158,1368.63,0,"XEH: PreInit Started. v1.0.4.198. MISSINIT: missionName=Test_HC, worldName=Altis, isMultiplayer=true, isServer=false, isDedicated=false"]
[59158,1368.67,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_cache_disable.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
[color="#0000CD"][b]"BLUEFOR_Leader, 0 Checking for !isNull player"
"BLUEFOR_Leader, 0 player !isNull"
"player UID: 56667188932011711"
[59159,1368.89,0,"XEH: PostInit Started"][/b][/color]
[59159,1368.89,0,"CBA_VERSIONING: cba=1.0.4.198, "]
[59159,1368.9,0,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=true, _isServer=false, _isDedServer=false, _playerCheckDone=true, _sp=false, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=2, _sessionId=11, _level=0, _timeOut=false, _game=3, BIS_functions=L Alpha 1-1:1 REMOTE, group=L Alpha 1-1, player=BLUEFOR_Leader, _playerType="B_officer_F", _playerGroup=B Alpha 1-2"]
[59160,1368.96,0,"CBA_VERSIONING_SERVER: cba=1.0.4.198, "]

Edited by Jacmac

Share this post


Link to post
Share on other sites

Do you have an example? I assume you're not hard coding the uid into the mission?

If the client is a headless client, "player" returns NULL-OBJECT, so this fails:

_uid = getPlayerUID player;

I don't know how to get the ID, UID, or even the name of a headless client if player returns NULL-OBJECT. What I do know is the player slot (Alpha 1-1 on BLUFOR) the HC is occupying.

Edited by Jacmac

Share this post


Link to post
Share on other sites

this is how it's done...

init mission

TW_HC_ClientSlot = objNull;

in the init of the HC ...

TW_HC_ClientSlot = player;
publicVariable "TW_HC_ClientSlot";

and

every test is done with

if (isnull TW_HC_ClientSlot) then 

So you don't need to get the id or the uid

Share this post


Link to post
Share on other sites

If that init code in the HC will pass the player object to the server, then I'll test it and see if TW_HC_ClientSlot ends up being a NULL-object or the HC. I'm not sure if you understand what I'm trying to do, but basically I want to pass information between only the server and HC. To do that from the server to the HC, I need the ID of the HC (or UID if you say that will work).

I put the code in the HC player's init:

TW_HC_ClientSlot = player;
publicVariable "TW_HC_ClientSlot"; 

The server init.sqf never made it past:

TW_HC_ClientSlot = objNull;
if (isServer) then {sleep 0.1;waitUntil {!isNull TW_HC_ClientSlot}};

Edited by Jacmac

Share this post


Link to post
Share on other sites

use publicvariableserver and you will send it only to server...

First of all, start the server normally and never wait until a client is ok in any case.

The server is the master of the game but not the HC. The HC will not start until the server is not ready.

So start the server and then do test for AI distribution between HC and server later in the mission.

for example i'm using the old version of EOS and this how i've done.

			_houseGroupsspawned=0;
		while {_houses > _houseGroupsspawned} do {sleep 1;
				_houseGroupsspawned=_houseGroupsspawned + 1;
					//null = [_currentMKR,_enemyFactionType,_spotAttack,true,_object] spawn eos_SpawnReinf;
					if (isnull TW_HC_ClientSlot) then {
						null = [_currentMKR,_enemyFactionType,_spotAttack,true,_object] spawn eos_SpawnReinf;
						}else{
						null = [[[_currentMKR,_enemyFactionType,_spotAttack,true,_object],eos_SpawnReinf], "BIS_fnc_spawn",TW_HC_ClientSlot, false] spawn BIS_fnc_MP;
						};
					};

The mission can work with or without HC but it always work.

Don't forget to test if the HC is working, (use diag_log at the end of the init)

Edited by Mariodu62

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  

×