Advertisement
Elioriel

init.sqf

Jan 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 6.80 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 format["------------------------------------------ Version %1 -------------------------------------------",(LIFE_SETTINGS(getText,"framework_version"))];
  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 civilian: {
  69.         life_paycheck = LIFE_SETTINGS(getNumber,"paycheck_civ");
  70.     };
  71.     case independent: {
  72.         life_paycheck = LIFE_SETTINGS(getNumber,"paycheck_med");
  73.     };
  74.     case east: {
  75.         life_paycheck = LIFE_SETTINGS(getNumber,"paycheck_adac");  
  76.     };
  77. };
  78.  
  79. switch (playerSide) do {
  80.     case west: {
  81.         _handle = [] spawn life_fnc_initCop;
  82.         waitUntil {scriptDone _handle};
  83.     };
  84.     case civilian: {
  85.         //Initialize Civilian Settings
  86.         _handle = [] spawn life_fnc_initCiv;
  87.         waitUntil {scriptDone _handle};
  88.     };
  89.     case independent: {
  90.         //Initialize Medics and blah
  91.         _handle = [] spawn life_fnc_initMedic;
  92.         waitUntil {scriptDone _handle};
  93.     };
  94.     case east: {
  95.         //Initialize Adac and blah  
  96.         _handle = [] spawn life_fnc_initAdac;          
  97.         waitUntil {scriptDone _handle};      
  98.     };
  99. };
  100.  
  101. player setVariable ["restrained",false,true];
  102. player setVariable ["Escorting",false,true];
  103. player setVariable ["transporting",false,true];
  104. player setVariable ["playerSurrender",false,true];
  105.  
  106. diag_log "Past Settings Init";
  107. //[] execFSM "core\fsm\client.fsm";
  108.  
  109. diag_log "Executing client.fsm";
  110. waitUntil {!(isNull (findDisplay 46))};
  111.  
  112. diag_log "Display 46 Found";
  113. if (isNil "The_programmer_initialised") then {
  114. (findDisplay 46) displayAddEventHandler ["KeyDown", "_this call life_fnc_keyHandler"];};
  115.  
  116. [player,life_settings_enableSidechannel,playerSide] remoteExecCall ["TON_fnc_manageSC",RSERV];
  117. 0 cutText ["","BLACK IN"];
  118. [] call life_fnc_hudSetup;
  119.  
  120. /* Set up frame-by-frame handlers */
  121. LIFE_ID_PlayerTags = ["LIFE_PlayerTags","onEachFrame","life_fnc_playerTags"] call BIS_fnc_addStackedEventHandler;
  122. LIFE_ID_RevealObjects = ["LIFE_RevealObjects","onEachFrame","life_fnc_revealObjects"] call BIS_fnc_addStackedEventHandler;
  123.  
  124. player setVariable ["steam64ID",getPlayerUID player];
  125. player setVariable ["realname",profileName,true];
  126.  
  127. life_fnc_moveIn = compileFinal
  128. "
  129.    life_disable_getIn = false;
  130.    player moveInCargo (_this select 0);
  131.    life_disable_getOut = true;
  132. ";
  133.  
  134. life_fnc_RequestClientId = player;
  135. publicVariableServer "life_fnc_RequestClientId"; //Variable OwnerID for HeadlessClient
  136.  
  137. [] spawn life_fnc_survival;
  138.  
  139. [] spawn {
  140.     for "_i" from 0 to 1 step 0 do {
  141.         waitUntil {(!isNull (findDisplay 49)) && {(!isNull (findDisplay 602))}}; // Check if Inventory and ESC dialogs are open
  142.         (findDisplay 49) closeDisplay 2; // Close ESC dialog
  143.         (findDisplay 602) closeDisplay 2; // Close Inventory dialog
  144.     };
  145. };
  146.  
  147. life_paycheck = compile (if (life_paycheck isEqualType "") then {life_paycheck} else {str(life_paycheck)}); //Make the paycheck static.
  148. if (LIFE_SETTINGS(getNumber,"enable_fatigue") isEqualTo 0) then {player enableFatigue false;};
  149.  
  150. if (LIFE_SETTINGS(getNumber,"pump_service") isEqualTo 1) then {
  151.     [] execVM "core\fn_setupStationService.sqf";
  152. };
  153.  
  154. /*
  155.     https://feedback.bistudio.com/T117205 - disableChannels settings cease to work when leaving/rejoining mission
  156.     Universal workaround for usage in a preInit function. - AgentRev
  157.     Remove if Bohemia actually fixes the issue.
  158. */
  159. {
  160.     _x params [["_chan",-1,[0]], ["_noText","false",[""]], ["_noVoice","false",[""]]];
  161.  
  162.     _noText = [false,true] select ((["false","true"] find toLower _noText) max 0);
  163.     _noVoice = [false,true] select ((["false","true"] find toLower _noVoice) max 0);
  164.  
  165.     _chan enableChannel [!_noText, !_noVoice];
  166.  
  167. } forEach getArray (missionConfigFile >> "disableChannels");
  168.  
  169. if (life_HC_isActive) then {
  170.     [getPlayerUID player,player getVariable ["realname",name player]] remoteExec ["HC_fnc_wantedProfUpdate",HC_Life];
  171. } else {
  172.     [getPlayerUID player,player getVariable ["realname",name player]] remoteExec ["life_fnc_wantedProfUpdate",RSERV];
  173. };
  174.  
  175. life_hideoutBuildings = [];
  176. {
  177.     private _building = nearestBuilding getMarkerPos _x;
  178.     life_hideoutBuildings pushBack _building;
  179.     false
  180. } count ["gang_area_1","gang_area_2","gang_area_3"];
  181.  
  182. [] spawn theprogrammer_core_fnc_clientInit;
  183.  
  184. diag_log "----------------------------------------------------------------------------------------------------";
  185. diag_log format ["               End of Altis Life Client Init :: Total Execution Time %1 seconds ",(diag_tickTime) - _timeStamp];
  186. diag_log "----------------------------------------------------------------------------------------------------";
  187.  
  188. [] spawn The_programmer_Duty_fnc_init_Service;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement