Jump to content
Sign in to follow this  
iceman77

call compile preprocessFile

Recommended Posts

Will the script that's being call compile preProcessFile be loaded into memory more than once? Say on JIP or w/e? How is this working exactly? In the script that's call compile preprocessFile, I store some code into a global variable (loadChange). The loadChange variable/function can be called by clients at any given time, and no doubt it will be called several times. Is this the right way to go about this? Also, is there any point in call compile preProccessFile on exclusively the client? Say for JIP players too? Should I execVM the loadChange script to store the code into the global variable (loadChange) that way?

init.sqf

 [] call compile preprocessFile "digitalLoadout\loadChange.sqf"; 

digitalLoadout\loadChange.sqf


[color=#ff0000]loadChange[/color] = 
{ 

/*-----------------------------------------------------------------------
SET SOME LOCAL VARIABLES PRIVATE OVER THE ENTIRE FUNCTIONS SCOPE
-----------------------------------------------------------------------*/
private ["_itemPic", "_count", "_unit"];

/*-----------------------------
PASS THE PLAYER TO THE SCRIPT
-----------------------------*/
_unit = _this select 0;

/*-------------------
DEFINE SOME CONTROLS
-------------------*/
disableSerialization; 

_display = uiNamespace getVariable "Dload"; 
_nameCtrl = _display displayCtrl 61500;
_PWeaponCtrl = _display displayCtrl 71500;
_SWeaponCtrl = _display displayCtrl 71501;
_BPackCtrl = _display displayCtrl 71502;
_PisCtrl = _display displayCtrl 71503;
_PWAmmoCtrl = _display displayCtrl 71504;
_SWAmmoCtrl = _display displayCtrl 71505;
_PisAmmoCtrl = _display displayCtrl 71506;
_HEGreAmmoCtrl = _display displayCtrl 71522;
_PWAmmoTextCtrl = _display displayCtrl 71507;
_SWAmmoTextCtrl = _display displayCtrl 71508;
_PisAmmoTextCtrl = _display displayCtrl 71509;
_HEGreAmmoTextCtrl = _display displayCtrl 71523;

/*---------------------------------------------
 DEFINE MAGAZINE TYPES & COUNT THE UNITS AMMO 
---------------------------------------------*/
_PWAmmoType = primaryWeaponMagazine _unit;
_SWAmmoType = secondaryWeaponMagazine _unit;
_PisAmmoType = handgunMagazine _unit;
_HEGreCountType = ({_x == "1Rnd_HE_Grenade_shell"} count magazines _unit);
_SWCountType = ({_x == _SWAmmoType select 0} count magazines _unit) + (count secondaryWeaponMagazine _unit);
_PisCountType = ({_x == _PisAmmoType select 0} count magazines _unit) + (count handgunMagazine _unit);
_PWCountType = ({_x == _PWAmmoType select 0} count magazines _unit);
_nameCtrl ctrlSetText format["%1: %2",rank _unit,name _unit];

/*--------------------------------------------------
      WIPE THE BACK PACK ITEM CONTROLS CLEAN
--------------------------------------------------*/
for [{_i=0},{_i < 13},{_i=_i+1}] do {
    _BPitemCtrl = _display displayCtrl 71510 + _i;
    _BPItemCtrl ctrlSetText format [""];
    _BPTextCtrl = _display displayCtrl 26500 + _i;
    _BPTextCtrl ctrlSetText format [""];
  };

for [{_i=0},{_i < 3},{_i=_i+1}] do {
   _attachCtrl = _display displayCtrl 80500 + _i;
   _attachCtrl ctrlSetText format [""];
  };


/*----------------------------------------------------------------
IF THE UNIT HAS A PRIMARY WEAPON THEN DISPLAY THE WEAPONS PICTURE
----------------------------------------------------------------*/
if (primaryWeapon _unit !="") then {
   _PWPicture = getText (configfile >> "CfgWeapons" >> primaryWeapon _unit >> "picture");
   _PWeaponCtrl ctrlSetText format ["%1", _PWPicture];
   ((uiNamespace getVariable "DLoad") displayCtrl 40500) ctrlSetTextColor [1,1,1,0];

} else {
   _PWeaponCtrl ctrlSetText format [""];
   ((uiNamespace getVariable "DLoad") displayCtrl 40500) ctrlSetTextColor [1,1,1,1];
};

/*------------------------------------------------------------------
IF THE UNIT HAS A SECONDARY WEAPON THEN DISPLAY THE WEAPONS PICTURE
-------------------------------------------------------------------*/
if (secondaryWeapon _unit !="") then {
   _SWPicture = getText (configfile >> "CfgWeapons" >> SecondaryWeapon _unit >> "picture");
   _SWeaponCtrl ctrlSetText format ["%1", _SWPicture];
   ((uiNamespace getVariable "DLoad") displayCtrl 40501) ctrlSetTextColor [1,1,1,0];
} else {
   _SWeaponCtrl ctrlSetText format [""];
   ((uiNamespace getVariable "DLoad") displayCtrl 40501) ctrlSetTextColor [1,1,1,1];
};

/*-------------------------------------------------------------------------------------------------------
IF THE UNIT HAS A BACKPACK THEN DISPLAY THE BACKPACKS PICTURE ALONG WITH ITS CONTENTS PICTURES AND COUNT
--------------------------------------------------------------------------------------------------------*/
if (backPack _unit != "") then {
   _BPPicture = getText (configfile >> "CfgVehicles" >> backPack _unit >> "picture");
   _BPackCtrl ctrlSetText format ["%1", _BPPicture];
   _items = [];
  {
   if (!(_x in _items)) then {
    _items set [count _items, _x];
   };
  } forEach backpackItems _unit; 

for [{_i=0},{_i < count _items },{_i=_i+1}] do {
    _BPPicCtrl = _display displayCtrl 71510 + _i;
    _BPTextCtrl = _display displayCtrl 26500 + _i;
    if (isClass (configFile >> "cfgWeapons" >> _items select _i)) then {
    _itemPic = getText (configfile >> "CfgWeapons" >> _items select _i >> "picture");
    _Count = ({_x == _items select _i} count items _unit);
   };
    if (isClass (configFile >> "cfgMagazines" >> _items select _i)) then {
    _itemPic = getText (configfile >> "CfgMagazines" >> _items select _i >> "picture");
    _Count = ({_x == _items select _i} count magazines _unit);
   };
    _BPPicCtrl ctrlSetText format ["%1", _itemPic]; 
    _BPTextCtrl ctrlSetText format ["%1", _count];
   };
     ((uiNamespace getVariable "DLoad") displayCtrl 40503) ctrlSetTextColor [1,1,1,0];
} else {
    _BPackCtrl ctrlSetText format [""];
    ((uiNamespace getVariable "DLoad") displayCtrl 40503) ctrlSetTextColor [1,1,1,1];
};

/*-------------------------------------------------------------------------------------------------------
IF THE UNIT HAS A HANDGUN THEN DISPLAY THE HANDGUN'S PICTURE 
--------------------------------------------------------------------------------------------------------*/
if (handGunWeapon _unit != "") then {
    _PisPicture = getText (configfile >> "CfgWeapons" >> handgunWeapon _unit >> "picture");
    _PisCtrl ctrlSetText format ["%1", _PisPicture];
    ((uiNamespace getVariable "DLoad") displayCtrl 40502) ctrlSetTextColor [1,1,1,0];
} else {
    _PisCtrl ctrlSetText format [""];
   ((uiNamespace getVariable "DLoad") displayCtrl 40502) ctrlSetTextColor [1,1,1,1];
};

/*-------------------------------------------------------------------------------
IF THE UNIT HAS ATLEAST 1 PRIMARY MAGAZINE THEN DISPLAY IT'S PICTURE AND COUNT
-------------------------------------------------------------------------------*/
if (count primaryWeaponMagazine _unit > 0) then {
    _PWAmmoPicture = getText (configfile >> "CfgMagazines" >> primaryWeaponMagazine _unit select 0 >> "picture");
    _PWAmmoCtrl ctrlSetText format ["%1", _PWAmmoPicture];
    _PWAmmoTextCtrl ctrlSetText format ["%1", _PWCountType];
} else {
    _PWAmmoCtrl ctrlSetText format [""];
    _PWAmmoTextCtrl ctrlSetText format [""];
};

/*-------------------------------------------------------------------------------------------------------
IF THE UNIT HAS ATLEAST 1 SECONDARY MAGAZINE THEN DISPLAY IT'S PICTURE AND COUNT
--------------------------------------------------------------------------------------------------------*/
if (count secondaryWeaponMagazine _unit > 0) then {
    _SWAmmoPicture = getText (configfile >> "CfgMagazines" >> secondaryWeaponMagazine _unit select 0 >> "picture");
    _SWAmmoCtrl ctrlSetText format ["%1", _SWAmmoPicture];
    _SWAmmoTextCtrl ctrlSetText format ["%1", _SWCountType];
} else {
    _SWAmmoCtrl ctrlSetText format [""];
   _SWAmmoTextCtrl ctrlSetText format [""];
};

/*-------------------------------------------------------------------------------------------------------
IF THE UNIT HAS ATLEAST 1 HAND GUN MAGAZINE THEN DISPLAY IT'S PICTURE AND COUNT
--------------------------------------------------------------------------------------------------------*/
if (count handGunMagazine _unit > 0) then {
   _PisAmmoPicture = getText (configfile >> "CfgMagazines" >> handgunMagazine _unit select 0 >> "picture");
   _PisAmmoCtrl ctrlSetText format ["%1", _PisAmmoPicture];
   _PisAmmoTextCtrl ctrlSetText format ["%1", _PisCountType];
} else {
   _PisAmmoCtrl ctrlSetText format [""];
   _PisAmmoTextCtrl ctrlSetText format [""];
};

/*-------------------------------------------------------------------------------------------------------
IF THE UNIT HAS ATLEAST 1 HE GRENADE THEN DISPLAY IT'S PICTURE AND COUNT
--------------------------------------------------------------------------------------------------------*/
if (_HEGreCountType > 0) then {
   _PWHEAmmoPicture = getText (configfile >> "CfgMagazines" >> primaryWeaponMagazine _unit select 1 >> "picture");
   _HEGreAmmoCtrl ctrlSetText format ["%1", _PWHEAmmoPicture];
   _HEGreAmmoTextCtrl ctrlSetText format ["%1", _HEGreCountType];
} else {
   _HEGreAmmoCtrl ctrlSetText format [""];
   _HEGreAmmoTextCtrl ctrlSetText format [""];
};

/*-------------------------------------------------------------------------------------------------------
IF THE UNIT HAS ATLEAST 1 WEAPON ATTATCHEMENT THEN DISPLAY THEIR PICTURES AND COUNT
--------------------------------------------------------------------------------------------------------*/
if (count primaryWeaponItems _unit > 0) then {
   for [{_i=0},{_i < count primaryWeaponItems _unit},{_i=_i+1}] do {
   _attachCtrl = _display displayCtrl 80500 + _i;
   _attachPicture = getText (configfile >> "CfgWeapons" >> primaryWeaponItems _unit select _i >> "picture");
   _attachCtrl ctrlSetText format ["%1", _attachPicture];
  };
 };
};

Edited by Iceman77

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
Sign in to follow this  

×