Jump to content
Vdauphin

Problem to get owner unit for debug Headless client

Recommended Posts

Hello guys,

 

I am currently implementing the Headless client in Hearts and Minds mission.

 

For debug, I am using a fonction (btc_fnc_marker_debug) to track allunits on map. 

 

To do so, I was using "createmarker" but when there are a lot of units, the map start to lag ...

So thanks to KK blog , now I am using "drawIcon" with a "ctrlAddEventHandler".

 

My function btc_fnc_marker_debug is drawing icon (see code here.).

And is fire by init_player.sqf with :

((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", btc_fnc_marker_debug];

I would like to customize icons differently depending on the "owner" (server,HC,player). Here, I choose to reduce alpha of the icon for every units not own by server.

 

To get the "owner" of each units, btc_fnc_marker_debug is currently using a "remoteexec" to fire server side :

btc_int_ask_data_owner = _target apply {owner _x};

Then, server send back the array with owner (btc_int_ask_data_owner) to player. And in btc_fnc_marker_debug :

waitUntil {(!(isNil "btc_int_ask_data_owner"))};

But, this is not working because btc_fnc_marker_debug don't support script suspension.

 

How can I get unit owner without script suspension  ? Should I change my approach ?

 

Thanks for the help !

Share this post


Link to post
Share on other sites

I do not knew if that fits your needs but:

fnc_get_owner = {

 if !(isServer) exitWith {};
 
    params ["_unit"];
    
    private _clientID = owner _unit;

    _unit setVariable ["owneridx", _clientID, true];

};
_unit remoteExecCall ["fnc_get_owner", 2, false];
_unit_ownerID = _unit getVariable "owneridx";

Share this post


Link to post
Share on other sites

Or in the initPlayerLocal.sqf, simply:

player setVariable ["ownerID", clientOwner];
Then access as stated above by davidoss. Well this will work with the players at least :P, I really should wake up a little before posting sometimes...but anyhow davidoss got you covered.

Share this post


Link to post
Share on other sites

 

I do not knew if that fits your needs but:

fnc_get_owner = {

 if !(isServer) exitWith {};
 
    params ["_unit"];
    
    private _clientID = owner _unit;

    _unit setVariable ["owneridx", _clientID, true];

};
_unit remoteExecCall ["fnc_get_owner", 2, false];
_unit_ownerID = _unit getVariable "owneridx";

Thks  jshock for help x)

 

Hello davidoss, I thought about your solution. This will work but if I understood fore each unit (100 to 200) the server will brodcast the setvariable to all client which is not very good. In arma it is better to use network as less as possible.

 

 

But you gave me an idea. Server side, I should spawn a script, witch is actualised every second the btc_int_ask_data_owner array .

btc_int_ask_data_owner = allunits apply {[_x, owner _x]};

And send it to the client using the debug feature.

By this way  I will send only an array each second with allunits and corresponding owner.

The btc_fnc_marker_debug fonction will display player side btc_int_ask_data_owner everytime and no more need any script interruption.

 

Sound good nop ?

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

×