Jump to content

"red" names inside cars


Recommended Posts

9 minutes ago, Gnashes said:

 

abc645c0fe11554c7c7a38d862923961.png

 

As an aside; I've also fixed cops' names not stacking in vehicles.

This is follows along one of the solutions I saw. But why loop through the vehicle crew again (in the new code) instead of just doing the gang/aggression check when looping through the vehicle crew on lines 82-90 (relevant code below) and if one of the occupants should be red, set a flag and you can use it in the if block on line 100. This removes the need to loop again.

 

case !(_x isKindOf "Man"):
{
	_name = "";
	{
		_extra = if (_forEachIndex > 0) then {", "} else {""};
		_name = _name + _extra + (_x getVariable['life_name', name _x]);
	} forEach (crew _x);
	_name;
};

 

BioHazard likes this
Link to comment
7 minutes ago, Serpico said:

This is follows along one of the solutions I saw. But why loop through the vehicle crew again (in the new code) instead of just doing the gang/aggression check when looping through the vehicle crew on lines 82-90 (relevant code below) and if one of the occupants should be red, set a flag and you can use it in the if block on line 100. This removes the need to loop again.

 


case !(_x isKindOf "Man"):
{
	_name = "";
	{
		_extra = if (_forEachIndex > 0) then {", "} else {""};
		_name = _name + _extra + (_x getVariable['life_name', name _x]);
	} forEach (crew _x);
	_name;
};

 

I completely understand what you just said. :kappa:

Link to comment
2 hours ago, Gnashes said:

Have to remember that you're doing a switch here. From my understanding, because we're doing "_text = switch do", you can only define "_text = {Code Result} when (Case = true)" within the switch cases.

Hence why we're determining _color separately using its own set of cases.

At least from what I understand, anyway

So what I mean is that when you're in the switch/case you would set a private variable like "_isAggressive" (which is declared at the top and initalized to false. And when you loop and find that one of the passengers is aggressive set _isAggressive to true. So when it comes to color, you can just check if _isAggressive is true. You can even improve from there so that is you did find one of passengers is aggressive you can stop checking the rest of the passengers and not do more checks that are not needed. 

In the end I don't think you need to change what you did since the performance difference would be negligible IMO.

 

Ghouh likes this
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...