Jump to content
  • 0

Humanity for mission clearing


Airwaves Man

Question

8 answers to this question

Recommended Posts

  • 1
28 minutes ago, A Man said:

Yes but if we use count we get a number back. Or did I read it wrong?

Thats the error message I got:


23:36:27 Error in expression <n", 30]);

_humanity = (_nearestPlayers select 0) getVariable["humanity", 0];
(_>
23:36:27   Error position: <select 0) getVariable["humanity", 0];
(_>
23:36:27   Error select: Type Number, expected Array,Config entry

 

 

Ahhhhh yes - a mistake on my part, nice catch! We are going to need to break this into a couple more lines.

 

We need to use nearEntities however in order to get the nearest possible player (the one that set it off).

 

Please try this:

{if (isPlayer _x) exitWith {_player = _x};} count (_objective nearEntities["Man", 30]);
	
_currentHumanity = _player getVariable["humanity", 0];
_player setVariable["humanity", _currentHumanity + 50, true];

 

Link to comment
Share on other sites

  • 0

I just whipped this together, could probably do it better but idk why this wouldn't work:

 

Find this line in your DZMSFunctions.sqf:

call compile format["waitUntil{sleep 1; ({isPlayer _x && _x distance _objective <= 30} count playableUnits > 0) && ({alive _x} count %1 <= (_numSpawned - _numKillReq));};",_unitArrayName];

 

Below it add:

_nearestPlayers = {isPlayer _x} count (_objective nearEntities["Man", 30]);
	
_currentHumanity = (_nearestPlayers select 0) getVariable["humanity", 0];
(_nearestPlayers select 0) setVariable["humanity", _humanity + 50, true];

 

Be sure to add the variables to the private array.

 

Let me know if it works man :)

 

Link to comment
Share on other sites

  • 0
1 minute ago, A Man said:

That is no working because if we use nearEntities in that way we get number back not a unique player ID or something we can set the humanity on.

nearEntities returns an array of the nearest entities, not a number.

 

Please refer to this post for more information:

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

Link to comment
Share on other sites

  • 0

Yes but if we use count we get a number back. Or did I read it wrong?

Thats the error message I got:

23:36:27 Error in expression <n", 30]);

_humanity = (_nearestPlayers select 0) getVariable["humanity", 0];
(_>
23:36:27   Error position: <select 0) getVariable["humanity", 0];
(_>
23:36:27   Error select: Type Number, expected Array,Config entry

 

 

Link to comment
Share on other sites

  • 0
Just now, A Man said:

Ive wrote it that way:


	_nearPlayers = _objective nearEntities ["CAManBase", 30];
	_player = _nearPlayers select 0;
	if ( isPlayer _player) then {
		_humanity = _player getVariable["humanity", 0];
		_player setVariable["humanity", _humanity + 50, true];
	};

Your version works as well. Thank you @BigEgg

Be sure to use mine, as it checks each nearby unit. Yours only checks the first nearby unit, which could fail should it be an AI. Mine will keep going to the next unit if it is an AI, if you get what I am saying.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...