Jump to content
Kreu

Get id of client and other questions

Recommended Posts

Im creating a multiplayer mission where i want that only the pilot of a chopper can use a certain BIS_fnc_holdActionAdd.
Several things are confusing me.
First i have a container with following code in the init line:

Spoiler

[
this, "change loadout", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa",  "_this == driver heli1 AND allowRearm",  "true", {},  {}, {sc1 = execVM  "scripts\rearm.sqf";
},
 {allowRearm = true},  [],
 1, 0,
 false,
 false  
] remoteExec ["BIS_fnc_holdActionAdd", 0, this];


 

I actually expected that the pilot would now see the enty several times, one entry for each player.
But to my happy suprise the pilot can only see the entry once.
So this is the first thing i can't understand.

But it keeps getting more confusing. Once the pilot completes the hold action, a script gets started (rearm.sqf).
In this script a new hold action gets created in exactly the same way as the first one:
 

Spoiler

[
loadoutChanger, "cancel",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa",  
"_this == driver heli1 AND allowCancel",  "true", {},  {},
{
terminate sc1;
allowRearm = TRUE;
while {cancelVar < 20} do
{
    [loadoutChanger, cancelVar] remoteExec ["BIS_fnc_holdActionRemove", 0, loadoutChanger];
    cancelVar = cancelVar + 1;
};
pylonSelect = FALSE;
allowCancel = FALSE;
},
{},  [],
1, 0,
false,
false  
] remoteExec ["BIS_fnc_holdActionAdd", 0, loadoutChanger];

this time suddenly the action gets added once for every player. Why does it behave different this time?

I then decided to change my script. I try to get the id of the player who is controlling the pilot:

pilotID = 0;
pilotID = owner heli1D;

I made two tests. The first time the host was playing heli1D. in that case pilotID was 2. Why was the pilotID 2?
The host wasn't able to see the holdAction (he should have been).

Second test the clients controlls heli1D. pilotID is 2 again. the client can see the hold action and it also got added only once.
Again i don't understand whats going on.

Im totally confused now. Help would be highly appreaciated.

Share this post


Link to post
Share on other sites

Start out easy.

 

Try to only use BIS_fnc_holdActionAdd in its simplest form. Do not do it in an init line, and do not use remoteExec.

 

Then expand with your customization of it one step at a time.

 

When the code works, route it to the correct machine. You might use remoteExec or publicVariable with a publicVariableEventhandler.

 

And also, maybe you will need scheduled execution, and in that case you might need to use ”spawn” inside the eventhandler.

  • Like 2

Share this post


Link to post
Share on other sites
On 7/5/2020 at 10:59 PM, engima said:

Start out easy.

 

Try to only use BIS_fnc_holdActionAdd in its simplest form. Do not do it in an init line, and do not use remoteExec.

 

Then expand with your customization of it one step at a time.

 

When the code works, route it to the correct machine. You might use remoteExec or publicVariable with a publicVariableEventhandler.

 

And also, maybe you will need scheduled execution, and in that case you might need to use ”spawn” inside the eventhandler.

Thanks for the answer. Somehow didn't get a notification that somebody replied to my thread.
The hold action is working in multiplayer. Not a smooth as in singleplayer but im ok with that.
Im currently making tests to find out how locality works exactly. Thinks don't seem to be very consistent sometimes. But im sure i will understand it sooner or later ^^

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

×