Advertisement
Guest User

server_functions.sqf

a guest
Oct 16th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 15.06 KB | None | 0 0
  1. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  2. waituntil {!isnil "bis_fnc_init"};
  3.  
  4. BIS_MPF_remoteExecutionServer = {
  5.     if ((_this select 1) select 2 == "JIPrequest") then {
  6.         [nil,(_this select 1) select 0,"loc",rJIPEXEC,[any,any,"per","execVM","ca\Modules\Functions\init.sqf"]] call RE;
  7.     };
  8. };
  9.  
  10. BIS_Effects_Burn =          {};
  11. server_playerLogin =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerLogin.sqf";
  12. server_playerSetup =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSetup.sqf";
  13. server_onPlayerDisconnect = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_onPlayerDisconnect.sqf";
  14. server_updateObject =       compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
  15. server_playerDied =         compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
  16. server_publishObj =         compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf"; //Creates the object in DB
  17. server_deleteObj =          compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf";     //Removes the object from the DB
  18. server_playerSync =         compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";
  19. zombie_findOwner =          compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\zombie_findOwner.sqf";
  20. server_updateNearbyObjects =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
  21. server_spawnCrashSite  =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnCrashSite.sqf";
  22. server_sendToClient =       compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_sendToClient.sqf";
  23. server_Wildgenerate =       compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\zombie_Wildgenerate.sqf";
  24. server_plantSpawner =       compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_plantSpawner.sqf";
  25.  
  26. spawnComposition = compile preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf"; //"\z\addons\dayz_code\compile\object_mapper.sqf";
  27. fn_bases = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fn_bases.sqf";
  28.  
  29. vehicle_handleServerKilled = {
  30.     private["_unit","_killer"];
  31.     _unit = _this select 0;
  32.     _killer = _this select 1;
  33.        
  34.     [_unit, "killed"] call server_updateObject;
  35.    
  36.     _unit removeAllMPEventHandlers "MPKilled";
  37.     _unit removeAllEventHandlers "Killed";
  38.     _unit removeAllEventHandlers "HandleDamage";
  39.     _unit removeAllEventHandlers "GetIn";
  40.     _unit removeAllEventHandlers "GetOut";
  41. };
  42.  
  43. check_publishobject = {
  44.     private ["_allowed","_allowedObjects","_object","_playername"];
  45.  
  46.     _object = _this select 0;
  47.     _playername = _this select 1;
  48.     _allowedObjects = ["TentStorage", "Hedgehog_DZ", "Sandbag1_DZ", "BearTrap_DZ", "Wire_cat1", "StashSmall", "StashMedium", "DomeTentStorage", "CamoNet_DZ", "Trap_Cans", "TrapTripwireFlare", "TrapBearTrapSmoke", "TrapTripwireGrenade", "TrapTripwireSmoke", "TrapBearTrapFlare"];
  49.     _allowed = false;
  50.  
  51. #ifdef OBJECT_DEBUG
  52.     diag_log format ["DEBUG: Checking if Object: %1 is allowed published by %2", _object, _playername];
  53. #endif
  54.  
  55. if ((typeOf _object) in _allowedObjects || (typeOf _object) in allbuildables_class) then {
  56. #ifdef OBJECT_DEBUG
  57.         diag_log format ["DEBUG: Object: %1 published by %2 is Safe",_object, _playername];
  58. #endif
  59.         _allowed = true;
  60.     };
  61.  
  62.     _allowed;
  63. };
  64.  
  65. //event Handlers
  66. eh_localCleanup = {
  67.    
  68. private ["_object","_type","_unit"];
  69. _object = _this select 0;
  70.     _object addEventHandler ["local", {
  71.         if(_this select 1) then {
  72.             _unit = _this select 0;
  73.             _type = typeOf _unit;
  74.              _myGroupUnit = group _unit;
  75.             _unit removeAllMPEventHandlers "mpkilled";
  76.             _unit removeAllMPEventHandlers "mphit";
  77.             _unit removeAllMPEventHandlers "mprespawn";
  78.             _unit removeAllEventHandlers "FiredNear";
  79.             _unit removeAllEventHandlers "HandleDamage";
  80.             _unit removeAllEventHandlers "Killed";
  81.             _unit removeAllEventHandlers "Fired";
  82.             _unit removeAllEventHandlers "GetOut";
  83.             _unit removeAllEventHandlers "GetIn";
  84.             _unit removeAllEventHandlers "Local";
  85.             clearVehicleInit _unit;
  86.             deleteVehicle _unit;
  87.             deleteGroup _myGroupUnit;
  88.             _unit = nil;
  89.             diag_log ("CLEANUP: DELETED A " + str(_type) );
  90.         };
  91.     }];
  92. };
  93.  
  94. server_hiveWrite = {
  95.     private["_data"];
  96.     //diag_log ("ATTEMPT WRITE: " + _this);
  97.     _data = "HiveExt" callExtension _this;
  98.     //diag_log ("WRITE: " +str(_data));
  99. };
  100.  
  101. server_hiveReadWrite = {
  102.     private["_key","_resultArray","_data"];
  103.     _key = _this;
  104.     //diag_log ("ATTEMPT READ/WRITE: " + _key);
  105.     _data = "HiveExt" callExtension _key;
  106.     //diag_log ("READ/WRITE: " +str(_data));
  107.     _resultArray = call compile format ["%1",_data];
  108.     _resultArray;
  109. };
  110.  
  111. onPlayerDisconnected        "[_uid,_name] call server_onPlayerDisconnect;";
  112.  
  113. server_getDiff =    {
  114.     private["_variable","_object","_vNew","_vOld","_result"];
  115.     _variable = _this select 0;
  116.     _object =   _this select 1;
  117.     _vNew =     _object getVariable[_variable,0];
  118.     _vOld =     _object getVariable[(_variable + "_CHK"),_vNew];
  119.     _result =   0;
  120.     if (_vNew < _vOld) then {
  121.         //JIP issues
  122.         _vNew = _vNew + _vOld;
  123.         _object getVariable[(_variable + "_CHK"),_vNew];
  124.     } else {
  125.         _result = _vNew - _vOld;
  126.         _object setVariable[(_variable + "_CHK"),_vNew];
  127.     };
  128.     _result;
  129. };
  130.  
  131. server_getDiff2 =   {
  132.     private["_variable","_object","_vNew","_vOld","_result"];
  133.     _variable = _this select 0;
  134.     _object =   _this select 1;
  135.     _vNew =     _object getVariable[_variable,0];
  136.     _vOld =     _object getVariable[(_variable + "_CHK"),_vNew];
  137.     _result = _vNew - _vOld;
  138.     _object setVariable[(_variable + "_CHK"),_vNew];
  139.     _result;
  140. };
  141.  
  142. dayz_objectUID2 = {
  143.     private["_position","_dir","_key"];
  144.     _dir = _this select 0;
  145.     _key = "";
  146.     _position = _this select 1;
  147.     {
  148.         _x = _x * 10;
  149.         if ( _x < 0 ) then { _x = _x * -10 };
  150.         _key = _key + str(round(_x));
  151.     } forEach _position;
  152.     _key = _key + str(round(_dir));
  153.     _key;
  154. };
  155.  
  156. dayz_recordLogin = {
  157.     private["_key"];
  158.     _key = format["CHILD:103:%1:%2:%3:",_this select 0,_this select 1,_this select 2];
  159.     _key call server_hiveWrite;
  160. };
  161.  
  162. call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\fa_hiveMaintenance.sqf";
  163.  
  164. // ### COPY START
  165. // BASE BUILDING 1.2 Build Array
  166. build_baseBuilding_arrays = {
  167.  
  168. // ################################### BUILD LIST ARRAY SERVER SIDE ######################################## START
  169. /*
  170. Build list by Daimyo for SERVER side
  171. Add and remove recipes, Objects(classnames), requirments to build, and town restrictions + extras
  172. This method is used because we are referencing magazines from player inventory as buildables.
  173. Main array (_buildlist) consist of 34 arrays within. These arrays contains parameters for player_build.sqf
  174. From left to right, each array contains 3 elements, 1st: Recipe Array, 2nd: "Classname", 3rd: Requirements array.
  175. Check comments below for more info on parameters
  176. */
  177. private["_isDestructable","_classname","_isSimulated","_disableSims","_objectSims","_objectSim","_requirements","_isStructure","_structure","_wallType","_removable","_buildlist","_build_townsrestrict"];
  178. // Count is 34
  179. // Info on Parameters (Copy and Paste to add more recipes and their requirments!):
  180. //[TankTrap, SandBags, Wires, Logs, Scrap Metal, Grenades], "Classname", [_attachCoords, _startPos, _modDir, _toolBox, _eTool, _medWait, _longWait, _inBuilding, _roadAllowed, _inTown, _removable, _isStructure, _isSimulated, _isDestructable];
  181. _buildlist = [
  182. [[0, 1, 0, 0, 1, 1, 0], "Grave",                        [[0,2.5,.1],[0,2,0],    0,  true, true, true, false, false, true, true, false, false, true, false]],//Booby Traps --1
  183. [[2, 0, 0, 3, 1, 0, 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
  184. [[1, 0, 1, 0, 1, 0, 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
  185. [[3, 3, 2, 2, 0, 0, 0], "WarfareBDepot",                [[0,18,2],  [0,15,0],   90, true, true, false, true, false, false, false, false, true, true, false]],//WarfareBDepot --4
  186. [[4, 1, 2, 2, 0, 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
  187. [[2, 1, 2, 1, 0, 0, 0], "WarfareBCamp",             [[0,12,1],  [0,10,0],   0,  true, true, false, true, false, false, false, false, true, true, false]],//WarfareBCamp --6
  188. [[2, 1, 1, 1, 0, 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
  189. [[2, 2, 0, 2, 0, 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
  190. [[2, 1, 2, 2, 0, 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
  191. [[4, 1, 1, 3, 0, 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
  192. [[2, 1, 1, 0, 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
  193. [[2, 1, 0, 1, 0, 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
  194. [[0, 1, 1, 0, 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
  195. [[0, 1, 0, 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
  196. [[6, 0, 0, 0, 2, 0, 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
  197. [[5, 0, 0, 0, 1, 0, 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
  198. [[3, 0, 0, 0, 1, 0, 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
  199. [[1, 1, 0, 2, 1, 0, 0], "Land_pumpa",                   [[0,3,.4],  [0,3,0],    0,  true, true, true, false, false, false, false, true, false, true, false]],//Land_pumpa --18
  200. [[1, 0, 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
  201. [[4, 0, 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
  202. [[1, 0, 0, 0, 1, 0, 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
  203. [[1, 0, 0, 2, 0, 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
  204. [[2, 0, 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
  205. [[2, 0, 1, 0, 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
  206. [[0, 0, 7, 0, 1, 0, 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
  207. [[0, 0, 6, 0, 1, 0, 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
  208. [[0, 0, 5, 0, 1, 0, 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
  209. [[0, 0, 4, 0, 1, 0, 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
  210. [[0, 0, 3, 0, 1, 0, 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
  211. [[0, 0, 2, 0, 1, 0, 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
  212. [[0, 0, 1, 0, 1, 0, 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
  213. [[0, 0, 2, 2, 0, 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
  214. [[0, 0, 2, 0, 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
  215. [[0, 0, 3, 1, 0, 1, 0], "SignM_UN_Base_EP1",            [[0,5,.8],  [0,4,0],    0,  true, false, false, false, false, false, false, true, false, true, true]],//UN Base sign FOR NO ZOMBIES
  216. [[1, 0, 0, 0, 2, 0, 0], "Land_Wall_Gate_Ind2Rail_L",    [[0,5,.8],  [0,4,0],    0,  true, false, false, false, false, false, false, true, false, true, true]],//UN Base sign FOR NO ZOMBIES
  217. [[0, 0, 0, 0, 2, 0, 2], "Land_Ind_Tank_Small",          [[0,5,.8],  [0,4,0],    0,  true, false, false, false, false, false, false, true, false, true, true]],//UN Base sign FOR NO ZOMBIES
  218. [[0, 0, 1, 0, 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 *** Remember that the last element in array does not get comma ***
  219. ];
  220. // Build allremovables array for remove action
  221. for "_i" from 0 to ((count _buildlist) - 1) do
  222. {
  223.     _removable = (_buildlist select _i) select _i - _i + 1;
  224.     if (_removable != "Grave") then { // Booby traps have disarm bomb
  225.     allremovables set [count allremovables, _removable];
  226.     };
  227. };
  228. // Build classnames array for use later
  229. for "_i" from 0 to ((count _buildlist) - 1) do
  230. {
  231.     _classname = (_buildlist select _i) select _i - _i + 1;
  232.     allbuildables_class set [count allbuildables_class, _classname];
  233. };
  234.  
  235.  
  236. /*
  237. *** Remember that the last element in ANY array does not get comma ***
  238. Notice lines 47 and 62
  239. */
  240. // Towns to restrict from building in. (Type exact name as shown on map, NOT Case-Sensitive but spaces important)
  241. // ["Classname", range restriction];
  242. // NOT REQUIRED SERVER SIDE, JUST ADDED IN IF YOU NEED TO USE IT
  243. _build_townsrestrict = [
  244. ["Lyepestok", 1000],
  245. ["Sabina", 900],
  246. ["Branibor", 600],
  247. ["Bilfrad na moru", 400],
  248. ["Mitrovice", 350],
  249. ["Seven", 300],
  250. ["Blato", 300]
  251. ];
  252. // Here we are filling the global arrays with this local list
  253. allbuildables = _buildlist;
  254. allbuild_notowns = _build_townsrestrict;
  255.  
  256. // ################################### BUILD LIST ARRAY SERVER SIDE ######################################## END
  257.  
  258. };
  259. //##### COPY END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement