SHARE
TWEET

Untitled

a guest Mar 19th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "script_macros.hpp"
  2. /*
  3.     File: init.sqf
  4.     Author: Bryan "Tonic" Boardwine
  5.  
  6.     Edit: Nanou for HeadlessClient optimization.
  7.     Please read support for more informations.
  8.  
  9.     Description:
  10.     Initialize the server and required systems.
  11. */
  12. private ["_dome","_rsb","_timeStamp","_extDBNotLoaded"];
  13. DB_Async_Active = false;
  14. DB_Async_ExtraLock = false;
  15. life_server_isReady = false;
  16. _extDBNotLoaded = "";
  17. serv_sv_use = [];
  18. publicVariable "life_server_isReady";
  19. life_save_civilian_position = if (LIFE_SETTINGS(getNumber,"save_civilian_position") isEqualTo 0) then {false} else {true};
  20. fn_whoDoneIt = compile preprocessFileLineNumbers "\life_server\Functions\Systems\fn_whoDoneIt.sqf";
  21.  
  22. /*
  23.     Prepare the headless client.
  24. */
  25. life_HC_isActive = false;
  26. publicVariable "life_HC_isActive";
  27. HC_Life = false;
  28. publicVariable "HC_Life";
  29.  
  30. if (EXTDB_SETTING(getNumber,"HeadlessSupport") isEqualTo 1) then {
  31.     [] execVM "\life_server\initHC.sqf";
  32. };
  33.  
  34. /*
  35.     Prepare extDB before starting the initialization process
  36.     for the server.
  37. */
  38.  
  39. if (isNil {uiNamespace getVariable "life_sql_id"}) then {
  40.     life_sql_id = round(random(9999));
  41.     CONSTVAR(life_sql_id);
  42.     uiNamespace setVariable ["life_sql_id",life_sql_id];
  43.         try {
  44.         _result = EXTDB format ["9:ADD_DATABASE:%1",EXTDB_SETTING(getText,"DatabaseName")];
  45.         if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
  46.         _result = EXTDB format ["9:ADD_DATABASE_PROTOCOL:%2:SQL:%1:TEXT2",FETCH_CONST(life_sql_id),EXTDB_SETTING(getText,"DatabaseName")];
  47.         if (!(_result isEqualTo "[1]")) then {throw "extDB3: Error with Database Connection"};
  48.     } catch {
  49.         diag_log _exception;
  50.         _extDBNotLoaded = [true, _exception];
  51.     };
  52.     if (_extDBNotLoaded isEqualType []) exitWith {};
  53.     EXTDB "9:LOCK";
  54.     diag_log "extDB3: Connected to Database";
  55. } else {
  56.     life_sql_id = uiNamespace getVariable "life_sql_id";
  57.     CONSTVAR(life_sql_id);
  58.     diag_log "extDB3: Still Connected to Database";
  59. };
  60.  
  61.  
  62. if (_extDBNotLoaded isEqualType []) exitWith {
  63.     life_server_extDB_notLoaded = true;
  64.     publicVariable "life_server_extDB_notLoaded";
  65. };
  66. life_server_extDB_notLoaded = false;
  67. publicVariable "life_server_extDB_notLoaded";
  68.  
  69. /* Run stored procedures for SQL side cleanup */
  70. ["CALL resetLifeVehicles",1] call DB_fnc_asyncCall;
  71. ["CALL deleteDeadVehicles",1] call DB_fnc_asyncCall;
  72. ["CALL deleteOldHouses",1] call DB_fnc_asyncCall;
  73. ["CALL deleteOldGangs",1] call DB_fnc_asyncCall;
  74.  
  75. _timeStamp = diag_tickTime;
  76. diag_log "----------------------------------------------------------------------------------------------------";
  77. diag_log "---------------------------------- Starting Altis Life Server Init ---------------------------------";
  78. diag_log "------------------------------------------ Version 5.0.0 -------------------------------------------";
  79. diag_log "----------------------------------------------------------------------------------------------------";
  80.  
  81. if (LIFE_SETTINGS(getNumber,"save_civilian_position_restart") isEqualTo 1) then {
  82.     [] spawn {
  83.         _query = "UPDATE players SET civ_alive = '0' WHERE civ_alive = '1'";
  84.         [_query,1] call DB_fnc_asyncCall;
  85.     };
  86. };
  87.  
  88. /* Map-based server side initialization. */
  89. master_group attachTo[bank_obj,[0,0,0]];
  90.  
  91. {
  92.     _hs = createVehicle ["Land_Hospital_main_F", [0,0,0], [], 0, "NONE"];
  93.     _hs setDir (markerDir _x);
  94.     _hs setPosATL (getMarkerPos _x);
  95.     _var = createVehicle ["Land_Hospital_side1_F", [0,0,0], [], 0, "NONE"];
  96.     _var attachTo [_hs, [4.69775,32.6045,-0.1125]];
  97.     detach _var;
  98.     _var = createVehicle ["Land_Hospital_side2_F", [0,0,0], [], 0, "NONE"];
  99.     _var attachTo [_hs, [-28.0336,-10.0317,0.0889387]];
  100.     detach _var;
  101.     if (worldName isEqualTo "Tanoa") then {
  102.         if (_forEachIndex isEqualTo 0) then {
  103.             atm_hospital_2 setPos (_var modelToWorld [4.48633,0.438477,-8.25683]);
  104.             vendor_hospital_2 setPos (_var modelToWorld [4.48633,0.438477,-8.25683]);
  105.             "medic_spawn_3" setMarkerPos (_var modelToWorld [8.01172,-5.47852,-8.20022]);
  106.             "med_car_2" setMarkerPos (_var modelToWorld [8.01172,-5.47852,-8.20022]);
  107.             hospital_assis_2 setPos (_hs modelToWorld [0.0175781,0.0234375,-0.231956]);
  108.         } else {
  109.             atm_hospital_3 setPos (_var modelToWorld [4.48633,0.438477,-8.25683]);
  110.             vendor_hospital_3 setPos (_var modelToWorld [4.48633,0.438477,-8.25683]);
  111.             "medic_spawn_1" setMarkerPos (_var modelToWorld [-1.85181,-6.07715,-8.24944]);
  112.             "med_car_1" setMarkerPos (_var modelToWorld [5.9624,11.8799,-8.28493]);
  113.             hospital_assis_2 setPos (_hs modelToWorld [0.0175781,0.0234375,-0.231956]);
  114.         };
  115.     };
  116. } forEach ["hospital_2","hospital_3"];
  117.  
  118. {
  119.     if (!isPlayer _x) then {
  120.         _npc = _x;
  121.         {
  122.             if (_x != "") then {
  123.                 _npc removeWeapon _x;
  124.             };
  125.         } forEach [primaryWeapon _npc,secondaryWeapon _npc,handgunWeapon _npc];
  126.     };
  127. } forEach allUnits;
  128.  
  129. [8,true,12] execFSM "\life_server\FSM\timeModule.fsm";
  130.  
  131. life_adminLevel = 0;
  132. life_medicLevel = 0;
  133. life_copLevel = 0;
  134. CONST(JxMxE_PublishVehicle,"false");
  135.  
  136. /* Setup radio channels for west/independent/civilian */
  137. life_radio_west = radioChannelCreate [[0, 0.95, 1, 0.8], "Side Channel", "%UNIT_NAME", []];
  138. life_radio_civ = radioChannelCreate [[0, 0.95, 1, 0.8], "Side Channel", "%UNIT_NAME", []];
  139. life_radio_indep = radioChannelCreate [[0, 0.95, 1, 0.8], "Side Channel", "%UNIT_NAME", []];
  140.  
  141. /* Set the amount of gold in the federal reserve at mission start */
  142. fed_bank setVariable ["safe",count playableUnits,true];
  143. [] spawn TON_fnc_federalUpdate;
  144.  
  145. /* Event handler for disconnecting players */
  146. addMissionEventHandler ["HandleDisconnect",{_this call TON_fnc_clientDisconnect; false;}];
  147. [] call compile preprocessFileLineNumbers "\life_server\functions.sqf";
  148.  
  149. /* Set OwnerID players for Headless Client */
  150. TON_fnc_requestClientID =
  151. {
  152.     (_this select 1) setVariable ["life_clientID", owner (_this select 1), true];
  153. };
  154. "life_fnc_RequestClientId" addPublicVariableEventHandler TON_fnc_requestClientID;
  155.  
  156. /* Event handler for logs */
  157. "money_log" addPublicVariableEventHandler {diag_log (_this select 1)};
  158. "advanced_log" addPublicVariableEventHandler {diag_log (_this select 1)};
  159.  
  160. /* Miscellaneous mission-required stuff */
  161. life_wanted_list = [];
  162.  
  163. cleanupFSM = [] execFSM "\life_server\FSM\cleanup.fsm";
  164.  
  165. [] spawn {
  166.     for "_i" from 0 to 1 step 0 do {
  167.         uiSleep (30 * 60);
  168.         {
  169.             _x setVariable ["sellers",[],true];
  170.         } forEach [Dealer_1,Dealer_2,Dealer_3];
  171.     };
  172. };
  173.  
  174. [] spawn TON_fnc_initHouses;
  175. cleanup = [] spawn TON_fnc_cleanup;
  176.  
  177. TON_fnc_playtime_values = [];
  178. TON_fnc_playtime_values_request = [];
  179.  
  180. //Just incase the Headless Client connects before anyone else
  181. publicVariable "TON_fnc_playtime_values";
  182. publicVariable "TON_fnc_playtime_values_request";
  183.  
  184.  
  185. /* Setup the federal reserve building(s) */
  186. private _vaultHouse = [[["Altis", "Land_Research_house_V1_F"], ["Tanoa", "Land_Medevac_house_V1_F"]]] call TON_fnc_terrainSort;
  187. private _altisArray = [16019.5,16952.9,0];
  188. private _tanoaArray = [11074.2,11501.5,0.00137329];
  189. private _pos = [[["Altis", _altisArray], ["Tanoa", _tanoaArray]]] call TON_fnc_terrainSort;
  190.  
  191. _dome = nearestObject [_pos,"Land_Dome_Big_F"];
  192. _rsb = nearestObject [_pos,_vaultHouse];
  193.  
  194. for "_i" from 1 to 3 do {_dome setVariable [format ["bis_disabled_Door_%1",_i],1,true]; _dome animateSource [format ["Door_%1_source", _i], 0];};
  195. _dome setVariable ["locked",true,true];
  196. _rsb setVariable ["locked",true,true];
  197. _rsb setVariable ["bis_disabled_Door_1",1,true];
  198. _dome allowDamage false;
  199. _rsb allowDamage false;
  200.  
  201. /* Tell clients that the server is ready and is accepting queries */
  202. life_server_isReady = true;
  203. publicVariable "life_server_isReady";
  204.  
  205. /* Initialize hunting zone(s) */
  206. aiSpawn = ["hunting_zone",30] spawn TON_fnc_huntingZone;
  207.  
  208. // We create the attachment point to be used for objects to attachTo load virtually in vehicles.
  209. life_attachment_point = "Land_HelipadEmpty_F" createVehicle [0,0,0];
  210. life_attachment_point setPosASL [0,0,0];
  211. life_attachment_point setVectorDirAndUp [[0,1,0], [0,0,1]];
  212.  
  213. // Sharing the point of attachment with all players.
  214. publicVariable "life_attachment_point";
  215.  
  216. diag_log "----------------------------------------------------------------------------------------------------";
  217. diag_log format ["               End of Altis Life Server Init :: Total Execution Time %1 seconds ",(diag_tickTime) - _timeStamp];
  218. diag_log "----------------------------------------------------------------------------------------------------";
  219. // Initialisation de la bourse (DynMarket).
  220. [] execVM "\life_server\Functions\DynMarket\fn_config.sqf";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top