Jxrdan62160

init.sqf

Sep 2nd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. #define __CONST__(var1,var2) var1 = compileFinal (if(typeName var2 == "STRING") then {var2} else {str(var2)})
  2. DB_Async_Active = false;
  3. DB_Async_ExtraLock = false;
  4. life_server_isReady = false;
  5. publicVariable "life_server_isReady";
  6.  
  7. [] execFSM "\life_server\cleanup.fsm";
  8. [] execVM "\life_server\functions.sqf";
  9. [] execVM "\life_server\eventhandlers.sqf";
  10.  
  11. //I am aiming to confuse people including myself, ignore the ui checks it's because I test locally.
  12.  
  13. _extDB = false;
  14.  
  15. //Only need to setup extDB once.
  16. if(isNil {uiNamespace getVariable "life_sql_id"}) then {
  17. life_sql_id = round(random(9999));
  18. __CONST__(life_sql_id,life_sql_id);
  19. uiNamespace setVariable ["life_sql_id",life_sql_id];
  20.  
  21. //extDB Version
  22. _result = "extDB" callExtension "9:VERSION";
  23. diag_log format ["extDB: Version: %1", _result];
  24. if(_result == "") exitWith {};
  25. if ((parseNumber _result) < 14) exitWith {diag_log "Error: extDB version 14 or Higher Required";};
  26.  
  27. //Initialize the database
  28. _result = "extDB" callExtension "9:DATABASE:Database2";
  29. if(_result != "[1]") exitWith {diag_log "extDB: Error with Database Connection";};
  30. _result = "extDB" callExtension format["9:ADD:DB_RAW_V2:%1",(call life_sql_id)];
  31. if(_result != "[1]") exitWith {diag_log "extDB: Error with Database Connection";};
  32. "extDB" callExtension "9:LOCK";
  33. _extDB = true;
  34. diag_log "extDB: Connected to Database";
  35. } else {
  36. life_sql_id = uiNamespace getVariable "life_sql_id";
  37. __CONST__(life_sql_id,life_sql_id);
  38. _extDB = true;
  39. diag_log "extDB: Still Connected to Database";
  40. };
  41.  
  42. //Broadbase PV to Clients, to warn about extDB Error.
  43. // exitWith to stop trying to run rest of Server Code
  44. if (!_extDB) exitWith {
  45. life_server_extDB_notLoaded = true;
  46. publicVariable "life_server_extDB_notLoaded";
  47. diag_log "extDB: Error checked extDB/logs for more info";
  48. };
  49.  
  50. //Run procedures for SQL cleanup on mission start.
  51. ["CALL resetLifeVehicles",1] spawn DB_fnc_asyncCall;
  52. ["CALL deleteDeadVehicles",1] spawn DB_fnc_asyncCall;
  53. ["CALL deleteOldGangs",1] spawn DB_fnc_asyncCall;
  54. ["CALL deleteOldMessages",1] spawn DB_fnc_asyncCall;
  55. ["CALL deleteOldHouses",1] spawn DB_fnc_asyncCall;
  56.  
  57. life_adminlevel = 0;
  58. life_medicLevel = 0;
  59. life_coplevel = 0;
  60.  
  61. //Null out harmful things for the server.
  62. __CONST__(JxMxE_PublishVehicle,"No");
  63.  
  64. //[] execVM "\life_server\fn_initHC.sqf";
  65.  
  66. life_radio_west = radioChannelCreate [[0, 0.95, 1, 0.8], "Side Channel", "%UNIT_NAME", []];
  67. life_radio_indep = radioChannelCreate [[0, 0.95, 1, 0.8], "Side Channel", "%UNIT_NAME", []];
  68. life_radio_civ = radioChannelCreate [[0, 0.95, 1, 0.8], "Side Channel", "%UNIT_NAME", []];
  69.  
  70. serv_sv_use = [];
  71.  
  72. fed_bank setVariable["safe",(count playableUnits),true];
  73.  
  74. //General cleanup for clients disconnecting.
  75. addMissionEventHandler ["HandleDisconnect",{_this call TON_fnc_clientDisconnect; false;}]; //Do not second guess this, this can be stacked this way.
  76.  
  77. [] spawn TON_fnc_cleanup;
  78. life_gang_list = [];
  79. publicVariable "life_gang_list";
  80. life_wanted_list = [];
  81. client_session_list = [];
  82.  
  83. [] spawn
  84. {
  85. private["_logic","_queue"];
  86. while {true} do
  87. {
  88. sleep (30 * 60);
  89. _logic = missionnamespace getvariable ["bis_functions_mainscope",objnull];
  90. _queue = _logic getvariable "BIS_fnc_MP_queue";
  91. _logic setVariable["BIS_fnc_MP_queue",[],TRUE];
  92. };
  93. };
  94.  
  95. [] spawn TON_fnc_federalUpdate;
  96.  
  97. [] spawn
  98. {
  99. while {true} do
  100. {
  101. sleep (30 * 60);
  102. {
  103. _x setVariable["sellers",[],true];
  104. } foreach [Dealer_1,Dealer_2,Dealer_3];
  105. };
  106. };
  107.  
  108. //Strip NPC's of weapons
  109. {
  110. if(!isPlayer _x) then {
  111. _npc = _x;
  112. {
  113. if(_x != "") then {
  114. _npc removeWeapon _x;
  115. };
  116. } foreach [primaryWeapon _npc,secondaryWeapon _npc,handgunWeapon _npc];
  117. };
  118. } foreach allUnits;
  119.  
  120. [] spawn TON_fnc_initHouses;
  121.  
  122. //Lockup the dome
  123. private["_dome","_rsb"];
  124. _dome = nearestObject [[16019.5,16952.9,0],"Land_Dome_Big_F"];
  125. _rsb = nearestObject [[16019.5,16952.9,0],"Land_Research_house_V1_F"];
  126.  
  127. for "_i" from 1 to 3 do {_dome setVariable[format["bis_disabled_Door_%1",_i],1,true]; _dome animate [format["Door_%1_rot",_i],0];};
  128. _rsb setVariable["bis_disabled_Door_1",1,true];
  129. _rsb allowDamage false;
  130. _dome allowDamage false;
  131. life_server_isReady = true;
  132. publicVariable "life_server_isReady";
Add Comment
Please, Sign In to add comment