Jump to content

Recommended Posts

Hello all,

this is a helper function that converts a side into their side number, and side number into side.

Thought I might just share.

There may be other ways to do this, I'm open and excited to hear your alternatives if you have them.

/*
  Author: Midnight

  Description:
  Helper script, side converter

  Parameter(s):
  0 - Number OR side :
  if side, this will be converted to a number
  if number, this will be converted to a side

  Returns:
  number or side
*/
params[["_s",NO_SIDE,[civilian,0],1]];
switch(_s) do
{
  case 0:{east};
  case 1:{west};
  case 2:{resistance};
  case 3:{civilian};
  case east:{0};
  case west:{1};
  case resistance:{2};
  case guerilla:{2};
  case civilian:{3};
  default{false};
};

 

Share this post


Link to post
Share on other sites

There already is BIS_fnc_sideID, already updated using enum define, probably as optimal as it gets.

 

/*
	Author: 
		Karel Moricky, optimised by Killzone_Kid

	Description:
		Returns side ID (as used in config).

	Parameter(s):
		0: SIDE

	Returns:
		NUMBER
*/

/// --- engine constants
#define SIDES_ENUM [east, west, independent, civilian, sideUnknown, sideEnemy, sideFriendly, sideLogic, sideEmpty, sideAmbientLife]

private _side = param [0, sideLogic];

/// --- validate input
#include "..\paramsCheck.inc"
paramsCheck(_side,isEqualType,sideUnknown)

SIDES_ENUM find _side

Only a dedicated script command would be more efficient.

 

Cheers

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

×