Advertisement
Guest User

init.sqf

a guest
Mar 8th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.20 KB | None | 0 0
  1. #include "..\script_macros.hpp"
  2. /*
  3. File: init.sqf
  4. Author: Bryan "Tonic" Boardwine
  5.  
  6. Description:
  7. Master client initialization file
  8. */
  9.  
  10. private ["_handle","_timeStamp","_extDB_notLoaded"];
  11. life_firstSpawn = true;
  12. life_session_completed = false;
  13. 0 cutText[localize "STR_Init_ClientSetup","BLACK FADED"];
  14. 0 cutFadeOut 9999999;
  15. _timeStamp = diag_tickTime;
  16. _extDB_notLoaded = "";
  17. diag_log "----------------------------------------------------------------------------------------------------";
  18. diag_log "--------------------------------- Starting Altis Life Client Init ----------------------------------";
  19. diag_log "------------------------------------------ Version 5.0.0 -------------------------------------------";
  20. diag_log "----------------------------------------------------------------------------------------------------";
  21. waitUntil {!isNull player && player == player}; //Wait till the player is ready
  22. [] call compile preprocessFileLineNumbers "core\clientValidator.sqf";
  23. enableSentences false;
  24.  
  25. //Setup initial client core functions
  26. diag_log "::Life Client:: Initialization Variables";
  27. [] call compile preprocessFileLineNumbers "core\configuration.sqf";
  28.  
  29. diag_log "::Life Client:: Variables initialized";
  30. diag_log "::Life Client:: Setting up Eventhandlers";
  31. [] call life_fnc_setupEVH;
  32.  
  33. diag_log "::Life Client:: Eventhandlers completed";
  34. diag_log "::Life Client:: Setting up user actions";
  35. [] call life_fnc_setupActions;
  36.  
  37. diag_log "::Life Client:: User actions completed";
  38. diag_log "::Life Client:: Waiting for server functions to transfer..";
  39. waitUntil {(!isNil "TON_fnc_clientGangLeader")};
  40.  
  41. diag_log "::Life Client:: Received server functions.";
  42. 0 cutText [localize "STR_Init_ServerReady","BLACK FADED"];
  43. 0 cutFadeOut 99999999;
  44.  
  45. diag_log "::Life Client:: Waiting for the server to be ready..";
  46. waitUntil {!isNil "life_server_isReady"};
  47. waitUntil {!isNil "life_HC_isActive" && {!isNil "life_server_extDB_notLoaded"}};
  48.  
  49. if (life_server_extDB_notLoaded) exitWith {
  50. 999999 cutText [localize "STR_Init_ExtdbFail","BLACK FADED"];
  51. 999999 cutFadeOut 99999999;
  52. };
  53.  
  54. waitUntil {life_server_isReady};
  55. [] call SOCK_fnc_dataQuery;
  56. waitUntil {life_session_completed};
  57. 0 cutText[localize "STR_Init_ClientFinish","BLACK FADED"];
  58. 0 cutFadeOut 9999999;
  59.  
  60. //diag_log "::Life Client:: Group Base Execution";
  61. [] spawn life_fnc_escInterupt;
  62.  
  63. //Set bank amount for new players
  64. switch (playerSide) do {
  65. case west: {
  66. life_paycheck = LIFE_SETTINGS(getNumber,"paycheck_cop");
  67. };
  68. case east: {
  69. life_paycheck = LIFE_SETTINGS(getNumber,"paycheck_adac");
  70. };
  71. case civilian: {
  72. life_paycheck = LIFE_SETTINGS(getNumber,"paycheck_civ");
  73. };
  74. case independent: {
  75. life_paycheck = LIFE_SETTINGS(getNumber,"paycheck_med");
  76. };
  77. };
  78.  
  79. switch (playerSide) do {
  80. case west: {
  81. _handle = [] spawn life_fnc_initCop;
  82. waitUntil {scriptDone _handle};
  83. };
  84. case east: {
  85. //Initialize Adac and blah
  86. _handle = [] spawn life_fnc_initAdac;
  87. waitUntil {scriptDone _handle};
  88. };
  89. case civilian: {
  90. //Initialize Civilian Settings
  91. _handle = [] spawn life_fnc_initCiv;
  92. waitUntil {scriptDone _handle};
  93. };
  94. case independent: {
  95. //Initialize Medics and blah
  96. _handle = [] spawn life_fnc_initMedic;
  97. waitUntil {scriptDone _handle};
  98. };
  99. };
  100.  
  101. if(life_bankingpin == 0 && getNumber(missionConfigFile >> "Life_Banking" >> "pin_system") isEqualTo 1) then {
  102. 0 cutText["","BLACK FADED"];
  103. 0 cutFadeOut 9999999;
  104. [-1] spawn life_fnc_createPinMenu;
  105. waitUntil{!isNull (findDisplay 45010)};
  106. waitUntil{isNull (findDisplay 45010)};
  107. waitUntil{!isNull (findDisplay 45000)};
  108. waitUntil{isNull (findDisplay 45000)};
  109. };
  110.  
  111.  
  112. player setVariable ["restrained",false,true];
  113. player setVariable ["Escorting",false,true];
  114. player setVariable ["transporting",false,true];
  115. player setVariable ["playerSurrender",false,true];
  116.  
  117. diag_log "Past Settings Init";
  118. [] execFSM "core\fsm\client.fsm";
  119.  
  120. diag_log "Executing client.fsm";
  121. waitUntil {!(isNull (findDisplay 46))};
  122.  
  123. diag_log "Display 46 Found";
  124. (findDisplay 46) displayAddEventHandler ["KeyDown", "_this call life_fnc_keyHandler"];
  125.  
  126. [player,life_settings_enableSidechannel,playerSide] remoteExecCall ["TON_fnc_manageSC",RSERV];
  127. 0 cutText ["","BLACK IN"];
  128. [] call life_fnc_hudSetup;
  129.  
  130. /* Set up frame-by-frame handlers */
  131. LIFE_ID_PlayerTags = ["LIFE_PlayerTags","onEachFrame","life_fnc_playerTags"] call BIS_fnc_addStackedEventHandler;
  132. LIFE_ID_RevealObjects = ["LIFE_RevealObjects","onEachFrame","life_fnc_revealObjects"] call BIS_fnc_addStackedEventHandler;
  133.  
  134. player setVariable ["steam64ID",getPlayerUID player];
  135. player setVariable ["realname",profileName,true];
  136.  
  137. life_fnc_moveIn = compileFinal
  138. "
  139. life_disable_getIn = false;
  140. player moveInCargo (_this select 0);
  141. life_disable_getOut = true;
  142. ";
  143.  
  144. life_fnc_RequestClientId = player;
  145. publicVariableServer "life_fnc_RequestClientId"; //Variable OwnerID for HeadlessClient
  146.  
  147. [] spawn life_fnc_survival;
  148.  
  149. [] spawn {
  150. for "_i" from 0 to 1 step 0 do {
  151. waitUntil {(!isNull (findDisplay 49)) && {(!isNull (findDisplay 602))}}; // Check if Inventory and ESC dialogs are open
  152. (findDisplay 49) closeDisplay 2; // Close ESC dialog
  153. (findDisplay 602) closeDisplay 2; // Close Inventory dialog
  154. };
  155. };
  156.  
  157. CONSTVAR(life_paycheck); //Make the paycheck static.
  158. if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 0) then {player enableFatigue false;};
  159.  
  160. if (LIFE_SETTINGS(getNumber,"pump_service") isEqualTo 1) then {
  161. [] execVM "core\fn_setupStationService.sqf";
  162. };
  163.  
  164. /*
  165. https://feedback.bistudio.com/T117205 - disableChannels settings cease to work when leaving/rejoining mission
  166. Universal workaround for usage in a preInit function. - AgentRev
  167. Remove if Bohemia actually fixes the issue.
  168. */
  169. {
  170. _x params [["_chan",-1,[0]], ["_noText","false",[""]], ["_noVoice","false",[""]]];
  171.  
  172. _noText = [false,true] select ((["false","true"] find toLower _noText) max 0);
  173. _noVoice = [false,true] select ((["false","true"] find toLower _noVoice) max 0);
  174.  
  175. _chan enableChannel [!_noText, !_noVoice];
  176.  
  177. } forEach getArray (missionConfigFile >> "disableChannels");
  178.  
  179. if (life_HC_isActive) then {
  180. [getPlayerUID player,player getVariable ["realname",name player]] remoteExec ["HC_fnc_wantedProfUpdate",HC_Life];
  181. } else {
  182. [getPlayerUID player,player getVariable ["realname",name player]] remoteExec ["life_fnc_wantedProfUpdate",RSERV];
  183. };
  184.  
  185. life_hideoutBuildings = [];
  186. {
  187. private _building = nearestBuilding getMarkerPos _x;
  188. life_hideoutBuildings pushBack _building;
  189. false
  190. } count ["gang_area_1","gang_area_2","gang_area_3"];
  191.  
  192. {
  193. _x setObjectTexture [0, (_x getVariable ["life_uniform", ""])];
  194. } forEach ((allUnits - playableUnits) select {!((_x getVariable ["life_uniform", ""]) isEqualTo "")});
  195.  
  196. diag_log "----------------------------------------------------------------------------------------------------";
  197. diag_log format [" End of Altis Life Client Init :: Total Execution Time %1 seconds ",(diag_tickTime) - _timeStamp];
  198. diag_log "----------------------------------------------------------------------------------------------------";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement