Jump to content
SeelieKnight

If Then not working in MP

Recommended Posts

I'm having major issues getting a small script to work in MP and I've narrowed it down to the IF THEN statement I'm using.

For reference, this works: 

while {alive p1} do{
	{hint "HE ALIVE";} spawn Bis_fnc_spawn;
}

But this does not:
 

while {alive p1} do{
	if (lifeState p1 == "INCAPACITATED") then {
		{hint "HE DEAD";} spawn Bis_fnc_spawn;
	};
}

Why? The code is placed in the Init field of unit named 'p1'.

Share this post


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

maybe he's "DEAD" and not "INCAPACITATED" 

 

https://community.bistudio.com/wiki/lifeState

 

 

Nah, the code will ultimately use Incapacitated instead of dead. Got  ACE settings so that players never actually die. To check my code I'm just knocking myself out with grenades and then checking my unit's lifeState. It is "INCAPACITATED" but the hint never fires. 

Share this post


Link to post
Share on other sites
2 minutes ago, SeelieKnight said:

 

Nah, the code will ultimately use Incapacitated instead of dead. Got  ACE settings so that players never actually die. To check my code I'm just knocking myself out with grenades and then checking my unit's lifeState. It is "INCAPACITATED" but the hint never fires. 

 

ok well maybe alive returns false when INCAPACITATED

Share this post


Link to post
Share on other sites

New twist. Got it to work in SP by wrapping it in a [] spawn {} and adding a sleep of 2 sec. Apparently you just need a sleep between checks. However, this is still not working in MP. Does some part of this have weird locality issues? 

[] spawn{
	while {alive p1} do{
		if (lifeState p1 == "INCAPACITATED") then {
			{hint "HE DEAD";} spawn Bis_fnc_spawn;
		};
		sleep 2;
	}
}

 

  • Confused 1

Share this post


Link to post
Share on other sites

What i the added value of bis_fnc_spawn ?? when you just have to use spawn command?? (it's a real question, not a criticism)

 

For MP (and SP):

 

[] spawn {
  waitUntil {sleep 1; lifeState p1 == "incapacitated"};
  "P1 is unconscious" remoteExec ["hint"];
  waitUntil {sleep 1; lifeState p1 != "incapacitated"};
};

 

 

  • Like 2

Share this post


Link to post
Share on other sites
4 minutes ago, pierremgi said:

What i the added value of bis_fnc_spawn ?? when you just have to use spawn command?? (it's a real question, not a criticism)

 

For MP (and SP):

 

[] spawn {
  waitUntil {sleep 1; lifeState p1 == "incapacitated"};
  "P1 is unconscious" remoteExec ["hint"];
  waitUntil {sleep 1; lifeState p1 != "incapacitated"};
};

 

 

It was a combination of my poor understanding of MP scripting and a holdover from previous script testing. Your code actually does precisely what I want, so thank you!

  • Like 1

Share this post


Link to post
Share on other sites

OK, but the interest of BIS_fnc_spawn remains not evident. This function is not a very old one (introduced in Arma3 V 0.56) ....

If somebody could explain why using it instead of spawn command, thanks.

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

OK, but the interest of BIS_fnc_spawn remains not evident. This function is not a very old one (introduced in Arma3 V 0.56) ....

If somebody could explain why using it instead of spawn command, thanks.

I was kind of using it in place of remoteExec. It basically just sends the hint to all players. (I think)

Share this post


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

OK, but the interest of BIS_fnc_spawn remains not evident. If somebody could explain why using it instead of spawn command

2 hours ago, SeelieKnight said:

I was kind of using it in place of remoteExec. It basically just sends the hint to all players. (I think)

 

You cannot use it in place of remoteExec as all it does is call the given code locally( it does not send the code to all players ).

What it is useful for is remoteExecuting some code, as the commands spawn/call are not remoteExecutable, and you may not particularly need/want your own function to remoteExec.

[[_some,_args],{/*some code*/}] remoteExec["spawn",0]; //Does not work, command spawn is not remoteExecutable

[[_some,_args],{/*some code*/}] remoteExec["BIS_fnc_spawn",0]; //remoteExecute the code with args on all machines

 

  • Like 2

Share this post


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

 

You cannot use it in place of remoteExec as all it does is call the given code locally( it does not send the code to all players ).

What it is useful for is remoteExecuting some code, as the commands spawn/call are not remoteExecutable, and you may not particularly need/want your own function to remoteExec.


[[_some,_args],{/*some code*/}] remoteExec["spawn",0]; //Does not work, command spawn is not remoteExecutable

[[_some,_args],{/*some code*/}] remoteExec["BIS_fnc_spawn",0]; //remoteExecute the code with args on all machines

 

 

The command spawn seems to me remote executable...

[arrayOfObjects ,{{_x hideObjectGlobal true} foreach _this}] remoteExec ["spawn",2];

works from client.

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

I apologise, I now see that I was working with old information and note that CfgRemoteExecCommands is obsolete.

Which means any command is now remoteExecutable unless specifically blocked in CfgRemoteExec.

  • Like 2

Share this post


Link to post
Share on other sites
21 hours ago, Larrow said:

What it is useful for is

 

Looks like it was added to support BIS_fnc_MP, before we had remoteExec and its relatives.

  • Like 2

Share this post


Link to post
Share on other sites

Yes, and the question is:

if you can legally remoteExec some spawned home-made functions/scripts (from scenario or signed mods, here not a question of hack), how reacts battlEye is this case?

I mean, if you add a teleport (scenario or shared signed mod), is there a risk for players to be banned?

I guess not but... for dedicated server where battlEye is paramount (imho) , can we guarantee that undue ban will not occur in this case?

  • 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

×