Advertisement
Guest User

server functions

a guest
Jul 21st, 2013
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 16.76 KB | None | 0 0
  1. waituntil {!isnil "bis_fnc_init"};
  2.  
  3. BIS_Effects_Burn =          {};
  4. object_spawnDamVehicle =    compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\object_spawnDamVehicle.sqf";
  5. server_playerLogin =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerLogin.sqf";
  6. server_playerSetup =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSetup.sqf";
  7. server_onPlayerDisconnect = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_onPlayerDisconnect.sqf";
  8. server_updateObject =       compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
  9. server_playerDied =         compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
  10. server_publishObj =         compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf";
  11. local_publishObj =          compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_publishObj.sqf";       //Creates the object in DB
  12. local_deleteObj =           compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_deleteObj.sqf";        //Creates the object in DB
  13. local_createObj =           compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\local_createObj.sqf";        //Creates the object in DB
  14. server_playerSync =         compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";
  15. zombie_findOwner =          compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\zombie_findOwner.sqf";
  16. server_updateNearbyObjects =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
  17.  
  18. // Alt F4 Bot
  19. server_botSetup =       compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_botSetup.sqf";
  20. server_botSync =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_botSync.sqf";
  21. server_botDamage =          compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_botDamage.sqf";
  22. server_botDied =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_botDied.sqf";
  23. //Get instance name (e.g. dayz_1.chernarus)
  24. fnc_instanceName = {
  25.     "dayz_" + str(dayz_instance) + "." + worldName
  26. };
  27.  
  28. if(isNil "botPlayers") then {
  29.     botPlayers = []
  30. };
  31. //Get instance name (e.g. dayz_1.chernarus)
  32. fnc_instanceName = {
  33.     "dayz_" + str(dayz_instance) + "." + worldName
  34. };
  35.  
  36. vehicle_handleInteract = {
  37.     private["_object"];
  38.     _object = _this select 0;
  39.     [_object, "all"] call server_updateObject;
  40. };
  41.  
  42. //event Handlers
  43. eh_localCleanup =           {
  44.     private ["_object"];
  45.     _object = _this select 0;
  46.     _object addEventHandler ["local", {
  47.         if(_this select 1) then {
  48.             private["_type","_unit"];
  49.             _unit = _this select 0;
  50.             _type = typeOf _unit;
  51.             deleteVehicle _unit;
  52.             diag_log ("CLEANUP: DELETED A " + str(_type) );
  53.         };
  54.     }];
  55. };
  56.  
  57. server_characterSync = {
  58.     private ["_characterID","_playerPos","_playerGear","_playerBackp","_medical","_currentState","_currentModel","_key"];
  59.     _characterID =  _this select 0;
  60.     _playerPos =    _this select 1;
  61.     _playerGear =   _this select 2;
  62.     _playerBackp =  _this select 3;
  63.     _medical =      _this select 4;
  64.     _currentState = _this select 5;
  65.     _currentModel = _this select 6;
  66.    
  67.     _key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,0,0,0,0,_currentState,0,0,_currentModel,0];
  68.     //diag_log ("HIVE: WRITE: "+ str(_key) + " / " + _characterID);
  69.     _key call server_hiveWrite;
  70. };
  71.  
  72. //was missing for server
  73. fnc_buildWeightedArray =    compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_buildWeightedArray.sqf";      //Checks which actions for nearby casualty
  74.  
  75. //onPlayerConnected         "[_uid,_name] spawn server_onPlayerConnect;";
  76. onPlayerDisconnected        "[_uid,_name] call server_onPlayerDisconnect;";
  77.  
  78. server_hiveWrite = {
  79.     private["_data"];
  80.     //diag_log ("ATTEMPT WRITE: " + _this);
  81.     _data = "HiveEXT" callExtension _this;
  82.     diag_log ("WRITE: " + _data);
  83. };
  84.  
  85. server_hiveReadWrite = {
  86.     private["_key","_resultArray","_data"];
  87.     _key = _this select 0;
  88.     //diag_log ("ATTEMPT READ/WRITE: " + _key);
  89.     _data = "HiveEXT" callExtension _key;
  90.     diag_log ("READ/WRITE: " + _data);
  91.     _resultArray = call compile format ["%1;",_data];
  92.     _resultArray;
  93. };
  94.  
  95. spawn_heliCrash = {
  96.     private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
  97.    
  98.     waitUntil{!isNil "BIS_fnc_selectRandom"};
  99.     if (isDedicated) then {
  100.     _position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
  101.     diag_log("DEBUG: Spawning a crashed helicopter at " + str(_position));
  102.     _veh = createVehicle ["UH1Wreck_DZ",_position, [], 0, "CAN_COLLIDE"];
  103.     dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
  104.     _veh setVariable ["ObjectID",1,true];
  105.     dayzFire = [_veh,2,time,false,false];
  106.     publicVariable "dayzFire";
  107.     if (isServer) then {
  108.         nul=dayzFire spawn BIS_Effects_Burn;
  109.     };
  110.     _num = round(random 4) + 3;
  111.     _config =       configFile >> "CfgBuildingLoot" >> "HeliCrash";
  112.     _itemType =     [] + getArray (_config >> "itemType");
  113.     //diag_log ("DW_DEBUG: _itemType: " + str(_itemType)); 
  114.     _itemChance =   [] + getArray (_config >> "itemChance");
  115.     //diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance)); 
  116.     //diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));   
  117.    
  118.     waituntil {!isnil "fnc_buildWeightedArray"};
  119.    
  120.     _weights = [];
  121.     _weights =      [_itemType,_itemChance] call fnc_buildWeightedArray;
  122.     //diag_log ("DW_DEBUG: _weights: " + str(_weights));   
  123.     for "_x" from 1 to _num do {
  124.         //create loot
  125.         _index = _weights call BIS_fnc_selectRandom;
  126.         sleep 1;
  127.         if (count _itemType > _index) then {
  128.             //diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
  129.             _iArray = _itemType select _index;
  130.             _iArray set [2,_position];
  131.             _iArray set [3,5];
  132.             _iArray call spawn_loot;
  133.             _nearby = _position nearObjects ["WeaponHolder",20];
  134.             {
  135.                 _x setVariable ["permaLoot",true];
  136.             } forEach _nearBy;
  137.         };
  138.     };
  139.     };
  140. };
  141.  
  142. server_getDiff =    {
  143.     private["_variable","_object","_vNew","_vOld","_result"];
  144.     _variable = _this select 0;
  145.     _object =   _this select 1;
  146.     _vNew =     _object getVariable[_variable,0];
  147.     _vOld =     _object getVariable[(_variable + "_CHK"),_vNew];
  148.     _result =   0;
  149.     if (_vNew < _vOld) then {
  150.         //JIP issues
  151.         _vNew = _vNew + _vOld;
  152.         _object getVariable[(_variable + "_CHK"),_vNew];
  153.     } else {
  154.         _result = _vNew - _vOld;
  155.         _object setVariable[(_variable + "_CHK"),_vNew];
  156.     };
  157.     _result
  158. };
  159.  
  160. server_getDiff2 =   {
  161.     private["_variable","_object","_vNew","_vOld","_result"];
  162.     _variable = _this select 0;
  163.     _object =   _this select 1;
  164.     _vNew =     _object getVariable[_variable,0];
  165.     _vOld =     _object getVariable[(_variable + "_CHK"),_vNew];
  166.     _result = _vNew - _vOld;
  167.     _object setVariable[(_variable + "_CHK"),_vNew];
  168.     _result
  169. };
  170.  
  171. dayz_objectUID = {
  172.     private["_position","_dir","_key","_object"];
  173.     _object = _this;
  174.     _position = getPosATL _object;
  175.     _dir = direction _object;
  176.     _key = [_dir,_position] call dayz_objectUID2;
  177.     _key
  178. };
  179.  
  180. dayz_objectUID2 = {
  181.     private["_position","_dir","_key"];
  182.     _dir = _this select 0;
  183.     _key = "";
  184.     _position = _this select 1;
  185.     {
  186.         _x = _x * 10;
  187.         if ( _x < 0 ) then { _x = _x * -10 };
  188.         _key = _key + str(round(_x));
  189.     } forEach _position;
  190.     _key = _key + str(round(_dir));
  191.     _key
  192. };
  193.  
  194. dayz_recordLogin = {
  195.     private["_key"];
  196.     _key = format["CHILD:103:%1:%2:%3:",_this select 0,_this select 1,_this select 2];
  197.     diag_log ("HIVE: WRITE: "+ str(_key));
  198.     _key call server_hiveWrite;
  199. };
  200. // BASE BUILDING 1.2 Build Array
  201. build_baseBuilding_arrays = {
  202.  
  203. // ################################### BUILD LIST ARRAY SERVER SIDE ######################################## START
  204. /*
  205. Build list by Daimyo for SERVER side
  206. Add and remove recipes, Objects(classnames), requirments to build, and town restrictions + extras
  207. This method is used because we are referencing magazines from player inventory as buildables.
  208. Main array (_buildlist) consist of 34 arrays within. These arrays contains parameters for player_build.sqf
  209. From left to right, each array contains 3 elements, 1st: Recipe Array, 2nd: "Classname", 3rd: Requirements array.
  210. Check comments below for more info on parameters
  211. */
  212. private["_isDestructable","_classname","_isSimulated","_disableSims","_objectSims","_objectSim","_requirements","_isStructure","_structure","_wallType","_removable","_buildlist","_build_townsrestrict"];
  213. // Count is 34
  214. // Info on Parameters (Copy and Paste to add more recipes and their requirments!):
  215. //[TankTrap, SandBags, Wires, Logs, Scrap Metal, Grenades], "Classname", [_attachCoords, _startPos, _modDir, _toolBox, _eTool, _medWait, _longWait, _inBuilding, _roadAllowed, _inTown, _removable, _isStructure, _isSimulated, _isDestructable];
  216. _buildlist = [
  217. [[0, 1, 0, 0, 1, 1], "Grave",                       [[0,2.5,.1],[0,2,0],    0,  true, true, true, false, false, true, true, false, false, true, false]],//Booby Traps --1
  218. [[2, 0, 0, 3, 1, 0], "Concrete_Wall_EP1",           [[0,5,1.75],[0,2,0],    0,  true, false, true, false, false, true, false, false, false, true, false]],//Gate Concrete Wall --2
  219. [[1, 0, 1, 0, 1, 0], "Infostand_2_EP1",             [[0,2.5,.6],[0,2,0],    0,  true, false, true, false, false, false, false, false, false, false, false]],//Gate Panel w/ KeyPad --3
  220. [[3, 3, 2, 2, 0, 0], "WarfareBDepot",               [[0,18,2],  [0,15,0],   90, true, true, false, true, false, false, false, false, true, true, false]],//WarfareBDepot --4
  221. [[4, 1, 2, 2, 0, 0], "Base_WarfareBBarrier10xTall", [[0,10,1],  [0,10,0],   0,  true, true, false, true, false, false, false, false, false, true, false]],//Base_WarfareBBarrier10xTall --5
  222. [[2, 1, 2, 1, 0, 0], "WarfareBCamp",                [[0,12,1],  [0,10,0],   0,  true, true, false, true, false, false, false, false, true, true, false]],//WarfareBCamp --6
  223. [[2, 1, 1, 1, 0, 0], "Base_WarfareBBarrier10x",     [[0,10,.6], [0,10,0],   0,  true, true, false, true, false, false, false, false, false, true, false]],//Base_WarfareBBarrier10x --7
  224. [[2, 2, 0, 2, 0, 0], "Land_fortified_nest_big",     [[0,12,1],  [2,8,0],    180,true, true, false, true, false, false, false, false, true, true, false]],//Land_fortified_nest_big --8
  225. [[2, 1, 2, 2, 0, 0], "Land_Fort_Watchtower",        [[0,10,2.2],[0,8,0],    90, true, true, false, true, false, false, false, false, true, true, false]],//Land_Fort_Watchtower --9
  226. [[4, 1, 1, 3, 0, 0], "Land_fort_rampart_EP1",       [[0,7,.2],  [0,8,0],    0,  true, true, false, true, false, false, false, true, false, true, false]],//Land_fort_rampart_EP1 --10
  227. [[2, 1, 1, 0, 0, 0], "Land_HBarrier_large",         [[0,7,1],   [0,4,0],    0,  true, true, true, false, false, false, false, false, false, true, false]],//Land_HBarrier_large --11
  228. [[2, 1, 0, 1, 0, 0], "Land_fortified_nest_small",   [[0,7,1],   [0,3,0],    90, true, true, true, false, false, false, false, false, true, true, false]],//Land_fortified_nest_small --12
  229. [[0, 1, 1, 0, 0, 0], "Land_BagFenceRound",          [[0,4,.5],  [0,2,0],    180,true, true, false, false, false, false, false, true, false, true, false]],//Land_BagFenceRound --13
  230. [[0, 1, 0, 0, 0, 0], "Land_fort_bagfence_long",     [[0,4,.3],  [0,2,0],    0,  true, true, false, false, false, false, false, true, false, true, false]],//Land_fort_bagfence_long --14
  231. [[6, 0, 0, 0, 2, 0], "Land_Misc_Cargo2E",           [[0,7,2.6], [0,5,0],    90, true, false, false, true, false, false, false, false, false, true, false]],//Land_Misc_Cargo2E --15
  232. [[5, 0, 0, 0, 1, 0], "Misc_Cargo1Bo_military",      [[0,7,1.3], [0,5,0],    90, true, false, false, true, false, false, false, false, false, true, false]],//Misc_Cargo1Bo_military --16
  233. [[3, 0, 0, 0, 1, 0], "Ins_WarfareBContructionSite", [[0,7,1.3], [0,5,0],    90, true, false, false, true, false, false, false, false, false, true, false]],//Ins_WarfareBContructionSite --17
  234. [[1, 1, 0, 2, 1, 0], "Land_pumpa",                  [[0,3,.4],  [0,3,0],    0,  true, true, true, false, false, false, false, true, false, true, false]],//Land_pumpa --18
  235. [[1, 0, 0, 0, 0, 0], "Land_CncBlock",               [[0,3,.4],  [0,2,0],    0,  true, false, false, false, false, true, true, true, false, true, false]],//Land_CncBlock --19
  236. [[4, 0, 0, 0, 0, 0], "Hhedgehog_concrete",          [[0,5,.6],  [0,4,0],    0,  true, true, false, true, false, true, false, false, false, true, false]],//Hhedgehog_concrete --20
  237. [[1, 0, 0, 0, 1, 0], "Misc_cargo_cont_small_EP1",   [[0,5,1.3], [0,4,0],    90, true, false, false, false, false, false, false, true, false, true, false]],//Misc_cargo_cont_small_EP1 --21
  238. [[1, 0, 0, 2, 0, 0], "Land_prebehlavka",            [[0,6,.7],  [0,3,0],    90, true, false, false, false, false, false, false, true, false, true, true]],//Land_prebehlavka(Ramp) --22
  239. [[2, 0, 0, 0, 0, 0], "Fence_corrugated_plate",      [[0,4,.6],  [0,3,0],    0,  true, false, false, false, false, false, false, true, false, true, true]],//Fence_corrugated_plate --23
  240. [[2, 0, 1, 0, 0, 0], "ZavoraAnim",                  [[0,5,4.0], [0,5,0],    0,  true, false, false, false, false, true, false, true, false, true, true]],//ZavoraAnim --24
  241. [[0, 0, 7, 0, 1, 0], "Land_tent_east",              [[0,8,1.7], [0,6,0],    0,  true, false, false, true, false, false, false, false, true, true, true]],//Land_tent_east --25
  242. [[0, 0, 6, 0, 1, 0], "Land_CamoNetB_EAST",          [[0,10,2],  [0,10,0],   0,  true, false, false, true, false, false, false, true, true, true, true]],//Land_CamoNetB_EAST --26
  243. [[0, 0, 5, 0, 1, 0], "Land_CamoNetB_NATO",          [[0,10,2],  [0,10,0],   0,  true, false, false, true, false, false, false, true, true, true, true]],//Land_CamoNetB_NATO --27
  244. [[0, 0, 4, 0, 1, 0], "Land_CamoNetVar_EAST",        [[0,10,1.2],[0,7,0],    0,  true, false, true, false, false, false, false, true, false, true, true]],//Land_CamoNetVar_EAST --28
  245. [[0, 0, 3, 0, 1, 0], "Land_CamoNetVar_NATO",        [[0,10,1.2],[0,7,0],    0,  true, false, true, false, false, false, false, true, false, true, true]],//Land_CamoNetVar_NATO --29
  246. [[0, 0, 2, 0, 1, 0], "Land_CamoNet_EAST",           [[0,8,1.2], [0,7,0],    0,  true, false, true, false, false, false, false, true, false, true, true]],//Land_CamoNet_EAST --30
  247. [[0, 0, 1, 0, 1, 0], "Land_CamoNet_NATO",           [[0,8,1.2], [0,7,0],    0,  true, false, true, false, false, false, false, true, false, true, true]],//Land_CamoNet_NATO --31
  248. [[0, 0, 2, 2, 0, 0], "Fence_Ind_long",              [[0,5,.6],  [-4,1.5,0], 0,  true, false, true, false, false, false, false, true, false, true, true]], //Fence_Ind_long --32
  249. [[0, 0, 2, 0, 0, 0], "Fort_RazorWire",              [[0,5,.8],  [0,4,0],    0,  true, false, false, false, false, false, false, true, false, true, true]],//Fort_RazorWire --33
  250. [[0, 0, 1, 0, 0, 0], "Fence_Ind",                   [[0,4,.7],  [0,2,0],    0,  true, false, false, false, false, false, true, true, false, true, true]], //Fence_Ind   --34
  251. [[3, 0, 2, 1, 1, 0], "Land_Ind_IlluminantTower",    [[0,4,.7],  [0,2,0],    0,  true, true, true, false, false, false, true, true, false, true, true]], //Land_Ind_IlluminantTower  --35
  252. [[1, 0, 2, 2, 0, 0], "CampEast",    [[0,4,.7],  [0,2,0],    0,  true, true, true, false, false, false, true, true, false, true, true]], //CampEast  --36
  253. [[2, 0, 0, 0, 2, 0], "Barrack2",    [[0,4,.7],  [0,2,0],    0,  true, true, true, false, false, false, true, true, false, true, true]], //Barrack2  --37
  254. [[2, 2, 1, 0, 0, 0], "camp_ins1",   [[0,4,.7],  [0,2,0],    0,  true, true, true, false, false, false, true, true, false, true, true]], //camp_ins1     --38
  255. [[2, 3, 0, 0, 2, 0], "citybase01",      [[0,4,.7],  [0,2,0],    0,  true, true, true, false, false, false, true, true, false, true, true]], //citybase01    --39
  256. [[1, 0, 0, 2, 1, 0], "Fort_Barricade_EP1",      [[0,4,.7],  [0,2,0],    0,  true, true, true, false, false, false, true, true, false, true, true]], //Fort_Barricade_EP1    --4-
  257. [[0, 0, 0, 0, 1, 0], "Hedgehog",    [[0,4,.7],  [0,2,0],    0,  true, true, true, false, false, false, true, true, false, true, true]] //Hedgehog   --41
  258. ];
  259. ];
  260. // Build allremovables array for remove action
  261. for "_i" from 0 to ((count _buildlist) - 1) do
  262. {
  263.     _removable = (_buildlist select _i) select _i - _i + 1;
  264.     if (_removable != "Grave") then { // Booby traps have disarm bomb
  265.     allremovables set [count allremovables, _removable];
  266.     };
  267. };
  268. // Build classnames array for use later
  269. for "_i" from 0 to ((count _buildlist) - 1) do
  270. {
  271.     _classname = (_buildlist select _i) select _i - _i + 1;
  272.     allbuildables_class set [count allbuildables_class, _classname];
  273. };
  274.  
  275.  
  276. /*
  277. *** Remember that the last element in ANY array does not get comma ***
  278. Notice lines 47 and 62
  279. */
  280. // Towns to restrict from building in. (Type exact name as shown on map, NOT Case-Sensitive but spaces important)
  281. // ["Classname", range restriction];
  282. // NOT REQUIRED SERVER SIDE, JUST ADDED IN IF YOU NEED TO USE IT
  283. _build_townsrestrict = [
  284. ["Lyepestok", 1000],
  285. ["Sabina", 900],
  286. ["Branibor", 600],
  287. ["Bilfrad na moru", 400],
  288. ["Mitrovice", 350],
  289. ["Seven", 300],
  290. ["Blato", 300]
  291. ];
  292. // Here we are filling the global arrays with this local list
  293. allbuildables = _buildlist;
  294. allbuild_notowns = _build_townsrestrict;
  295.  
  296. // ################################### BUILD LIST ARRAY SERVER SIDE ######################################## END
  297.  
  298. };
  299. execVM "z\addons\dayz_server\init\code.sqf";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement