Jump to content

Recommended Posts

Hello guys,

I have a strange problem with the following script:

tsk = format ["tsk%1", random 100];
[allPlayers, tsk, ["Hack the watchtower to get information about the position of the opposing players!", "Watchtower", ""], laptop, "ASSIGNED", 99, true, "download", true] call BIS_fnc_taskCreate;

[laptop,
"Activate watchtower",
"\a3\ui_f\data\igui\cfg\holdactions\holdaction_connect_ca.paa",
"\a3\ui_f\data\igui\cfg\holdactions\holdaction_connect_ca.paa",
"player distance laptop < 5",
"player distance laptop < 3",
{num = execVM "watchtower\durring.sqf";},
{},
{nul = execVM "watchtower\gegner_markieren_v3.sqf",
nul = execVM "watchtower\sleep.sqf",
[tsk, "SUCCEEDED", true] remoteExec ["BIS_fnc_taskSetState", 0, true],
sleep 0.1,
[tsk, allPlayers, true] remoteExec ["BIS_fnc_deleteTask", 0, true];},
{["Hacking canceled!"] remoteExec ["hintSilent", 0, true],
sleep 1;
[""] remoteExec ["hintSilent", 0, true],
call{playSound "cancel";},
execVM "watchtower\deletion_sound.sqf";},
[],
15,
0,
true,
false]
remoteExec ["bis_fnc_holdactionadd", 0, true];

With the script I add a holdaction function to a laptop. When I start the mission in the Eden editor in singleplayer or multiplayer everything works as it should. The script is executed by the init.sqf and the holdaction function is displayed on the laptop. When I complete it with the spacebar it disappears again as it should.
However, when I host the mission on my dedicated Arma server, the holdaction appears twice for some reason. Once with text and once without. Both run the same code when I use it and then disappear, but reappearing twice when I run the script again.
Can any of you help me further? And tell me why this happens?

Thanks

Share this post


Link to post
Share on other sites

Init.sqf executes on server and all clients as they join. 

remoteExec ["bis_fnc_holdactionadd", 0, true];

When your server starts, it remoteExecs to all clients, current and future (the third param is JIP, which you have set to "true").

When a client joins, they receive the remoteExec'd code and also run it themselves locally. Hence the doubling. 

 

Try using initServer.sqf instead.

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, Harzach said:

Init.sqf executes on server and all clients as they join. 


remoteExec ["bis_fnc_holdactionadd", 0, true];

When your server starts, it remoteExecs to all clients, current and future (the third param is JIP, which you have set to "true").

When a client joins, they receive the remoteExec'd code and also run it themselves locally. Hence the doubling. 

 

Try using initServer.sqf instead.

 

If I set the script to false with the third parameter, I also have two stopping options. When I run the code through the initServer.sqf, nothing is displayed. I also tried the initServerPlayer.sqf and nothing is displayed as well.

The goal is that when a player finish the holdAction, the option should be cleared for all players.
Do you have any idea how to fix this?

 

Share this post


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

 

If I set the script to false with the third parameter, I also have two stopping options. When I run the code through the initServer.sqf, nothing is displayed. I also tried the initServerPlayer.sqf and nothing is displayed as well.

The goal is that when a player finish the holdAction, the option should be cleared for all players.
Do you have any idea how to fix this?

 

i am a noob at sqf so please take what i say with a pinch of salt <<< (also just realised that Harzach has a much more clearer and shorter explanation for some stuff that I say here)

originally when you put it into init.sqf, the remoteExec is executing it for the SERVER and ALL CLIENTS (all players) ON MISSION START & everytime a player joins, that's probably why it appears twice, and there'd be a lot more actions if you weren't testing solo on the dedicated server

(if the below is in initServer.sqf where it is initially executed once on server)
the second parameter determines what machines/computers/ it is executed on. (0 = all clients + server; in other words, every player including the server)

the third parameter (boolean true/false) determines whether the addaction is given to JIP players (people who hotjoin / join after mission start).
true = people who hotjoin after mission start will have the action (as it is executed on their computer upon joining)
false = people who hotjoin after mission start will not have the action


initServer.sqf should work on dedicated for what Harzach said, so I'm not really sure what the problem is tbh
make sure the object that the action is attached to isnt too large because of the distance conditions

you can always try something with bis_fnc_holdactionremove (i think that's the name anyways) but i can't check the wiki right now. dont know if it's actually necessary
 

Share this post


Link to post
Share on other sites
3 hours ago, Lukas Lee said:

The goal is that when a player finish the holdAction, the option should be cleared for all players.
Do you have any idea how to fix this?

 


I don't know if this will actually help you, but you can create a variable for the action inside the action itself, and then request the same action remove itself (again).
The action will recognize it as "select # 2", so you could try:

 

_holdForDelete = _this select 2;	// add it in the first lines of the action

/*/ add all the code you wish for the action here /*/

_player removeAction _holdForDelete;	// this at the very end of codes inside the action, so to it remove itself


But this will probably remove that action ONLY from the player who executes it. I can't suggest how could you adapt it to remove the action from everybody's list.

Edited by JCataclisma
  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, LittleAndy said:

i am a noob at sqf so please take what i say with a pinch of salt <<< (also just realised that Harzach has a much more clearer and shorter explanation for some stuff that I say here)

originally when you put it into init.sqf, the remoteExec is executing it for the SERVER and ALL CLIENTS (all players) ON MISSION START & everytime a player joins, that's probably why it appears twice, and there'd be a lot more actions if you weren't testing solo on the dedicated server

(if the below is in initServer.sqf where it is initially executed once on server)
the second parameter determines what machines/computers/ it is executed on. (0 = all clients + server; in other words, every player including the server)

the third parameter (boolean true/false) determines whether the addaction is given to JIP players (people who hotjoin / join after mission start).
true = people who hotjoin after mission start will have the action (as it is executed on their computer upon joining)
false = people who hotjoin after mission start will not have the action


initServer.sqf should work on dedicated for what Harzach said, so I'm not really sure what the problem is tbh
make sure the object that the action is attached to isnt too large because of the distance conditions

you can always try something with bis_fnc_holdactionremove (i think that's the name anyways) but i can't check the wiki right now. dont know if it's actually necessary
 

Thanks for your answer. 🙂

I have now copied the script directly into initServer.sqf and there it works as it should. The only problem is that the task that is created at the beginning is only executed locally and therefore it is not visible. Do you have any idea how I can do this with remoteExec?
 

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, Lukas Lee said:

Do you have any idea how I can do this with remoteExec?

 

BIS_fnc_taskCreate is global and so locality shouldn't be an issue here, the BIKI states that allplayers may not return the full player list properly when called at mission start, try using this instead:

_playerList = (call BIS_fnc_listPlayers)
[_playerList, tsk, ["Hack the watchtower to get information about the position of the opposing players!", "Watchtower", ""], laptop, "ASSIGNED", 99, true, "download", true] call BIS_fnc_taskCreate;

It's also worth noting that any global variables you make in initServer.sqf still only exist on the server, to pass a variable to all clients you need to make the variable public with publicVariable.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Chuggacharles said:

BIS_fnc_taskCreate is global and so locality shouldn't be an issue here, the BIKI states that allplayers may not return the full player list properly when called at mission start, try using this instead:


_playerList = (call BIS_fnc_listPlayers)
[_playerList, tsk, ["Hack the watchtower to get information about the position of the opposing players!", "Watchtower", ""], laptop, "ASSIGNED", 99, true, "download", true] call BIS_fnc_taskCreate;

It's also worth noting that any global variables you make in initServer.sqf still only exist on the server, to pass a variable to all clients you need to make the variable public with publicVariable.

 Okay thanks.

I found out that you can just set allPlayers to true and it works fine. But now the task is not switched to successful and deleted. I already tried not doing it with remoteExec since both actually have global effects but somehow it still doesn't work. 
Do you have any idea?

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, Lukas Lee said:

 Okay thanks.

I found out that you can just set allPlayers to true and it works fine. But now the task is not switched to successful and deleted. I already tried not doing it with remoteExec since both actually have global effects but somehow it still doesn't work. 
Do you have any idea?

I think the issue is most likely that that the action you are adding is local to each client, and so the script that runs upon the action being completed or interrupted etc is also run locally. This would not be a problem except that the functions refer to the 'tsk' variable which only exists on the server and does not exist on the players machine. You therefore need to make 'tsk' public like so:

tsk = format ["tsk%1", random 100];
publicVariable "tsk";

If this is what's occuring, you should also be aware that any other script that any of your scripts that are being called from the action with execVM are also being run locally, you should make sure if you don't want them to run on a players machine, that they are remoteExec'd on the server, and similarly if you want all machines or clients to run those scripts you should remoteExec them appropriately as well.

  • Like 1

Share this post


Link to post
Share on other sites
24 minutes ago, Chuggacharles said:

I think the issue is most likely that that the action you are adding is local to each client, and so the script that runs upon the action being completed or interrupted etc is also run locally. This would not be a problem except that the functions refer to the 'tsk' variable which only exists on the server and does not exist on the players machine. You therefore need to make 'tsk' public like so:


tsk = format ["tsk%1", random 100];
publicVariable "tsk";

If this is what's occuring, you should also be aware that any other script that any of your scripts that are being called from the action with execVM are also being run locally, you should make sure if you don't want them to run on a players machine, that they are remoteExec'd on the server, and similarly if you want all machines or clients to run those scripts you should remoteExec them appropriately as well.

Thank you very much now everything works as it should. I just have to find a way that the holdAction is visible for all players at the same time and is deleted again for all after ending.
Thanks for your help 🙂

Share this post


Link to post
Share on other sites
39 minutes ago, Lukas Lee said:

Thank you very much now everything works as it should. I just have to find a way that the holdAction is visible for all players at the same time and is deleted again for all after ending.
Thanks for your help 🙂

No problem! Removing the action on all clients should be quite simple, you just need to retrieve the actionID and then remove it locally again on each players machine. The easiest way to do this would probably be to move BIS_fnc_holdActionAdd to its own script file and execVM it from remoteExec like so:

"tskAction.sqf" remoteExec ["execVM", 0,true];

Inside tskAction.sqf would be the BIS_fnc_holdActionAdd  but instead you call it and assign it a variable e.g:

tskActionID = [//whatever params you have] call BIS_fnc_holdActionAdd;

This variable will then return the actionID which you can refer to in order to remove the action, such as by adding this to the script that runs when the action is complete:

[player, tskActionID] remoteExec ["removeAction", 0, true];

I can't guarantee that this will work as expected with JIP players as i haven't messed around with that much myself but this should at least provide a start! Also if removeAction doesn't work try:

[player, tskActionID] remoteExec ["BIS_fnc_holdActionRemove", 0, true];

 

  • Like 1

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

×