Jump to content
Sign in to follow this  
tryteyker

How to check if Headless Client owns unit?

Recommended Posts

Hi,

 

bit of a tricky one here I'm assuming. I need to check whether or not a unit is controlled by a headless client or not. Null checks have already been done, so HC is guaranteed to be slotted on the server. I've tried going through owner and groupOwner etc, but the problem with that is that these commands always return 0 when executed server side (owner HC1, owner someUnit etc). I've got a dedicated server I'm testing this on but I'm not really getting anywhere using the owner command approach. Besides, I think there'll be another key issue with using owner: the function that's executed when checking for ownership is always executed client-side and never on the server, which practically guarantees a return of 0. There's a few other approaches using time etc as HC usually takes 15-20 seconds to transfer ownership of units to it, but I'm reluctant to use these as I want a function that's usable in 5-10 different scripts (too lazy to write these 5-10 exitWiths).

 

Anyone got any ideas?

Share this post


Link to post
Share on other sites

I dont know if this is still a known issue but after eden update the HC detection was broken the way you described. (always returning servers ID).

Since then I stopped working on my HC.

Do you use windows or linux for dedi/hc ?

cause if u use linux dedi and linux hc there is another issue u have to notice.

Hmm tried to find any topic about that without success. Looks like I dreamed that.

I ve an alternative method of checking for HC presence:

hc_present = false;

if (!hasInterface and !isServer) then
{
 hc_present = true;
 publicVariableServer "hc_present";
};

Share this post


Link to post
Share on other sites

HC presence itself isn't an issue (entities "HeadlessClient_F" will return any slotted HC), rather seeing if that HC owns any unit is the issue. I'm aware of the Virtual Entities bugs introduced with Eden, but they've been fixed now as far as I know. 

Share this post


Link to post
Share on other sites

i ve the alternative code for detecting units hc locality at home. i think i did it by sending uid from hc to server by publicvariable. i ll post that later

Share this post


Link to post
Share on other sites

AFAIK Eden issues are solved, so assuming HC checks are ok and you have named your HC with a variable, for example HC_1, it´s as easy as

 

if (owner HC_1 == owner _unit) then {hint "HC_1 is the owner"}

 

Also, from the server you can check using local command

 

if !(local _unit) then {hint "It's not local for the server"}, executed on a hosted should work too.

Share this post


Link to post
Share on other sites

Does owner work client side? This is the key issue, since this function is run client side and as far as I know (according to the BIKI anyway) owner always returns 0 client side.

Share this post


Link to post
Share on other sites

but the problem with that is that these commands always return 0 when executed server side

 

 owner always returns 0 client side

 

Both commands must be executed server side. However even on the server they can return 0 if you query non existent unit. So make sure it is not null before hand:

if (isNull _obj) then {diag_log format ["%1 is NULL", _obj]};

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  

×