Project : More Tents

Here is my server.pbo\init\server_functions.sqf

Code:
waituntil {!isnil "bis_fnc_init"};

BIS_MPF_remoteExecutionServer = {
    if ((_this select 1) select 2 == "JIPrequest") then {
        [nil,(_this select 1) select 0,"loc",rJIPEXEC,[any,any,"per","execVM","ca\Modules\Functions\init.sqf"]] call RE;
    };
};

BIS_Effects_Burn =            {};
server_playerLogin =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerLogin.sqf";
server_playerSetup =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSetup.sqf";
server_onPlayerDisconnect = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_onPlayerDisconnect.sqf";
server_updateObject =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
server_playerDied =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
server_publishObj =         compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf";    //Creates the object in DB
server_deleteObj =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf";     //Removes the object from the DB
server_playerSync =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";
zombie_findOwner =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\zombie_findOwner.sqf";
server_updateNearbyObjects =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
server_spawnCrashSite  =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnCrashSite.sqf";

vehicle_handleInteract = {
    private["_object"];
    _object = _this select 0;
    needUpdate_objects = needUpdate_objects - [_object];
    [_object, "all"] call server_updateObject;
};

vehicle_handleServerKilled = {
    private["_unit","_killer"];
    _unit = _this select 0;
    _killer = _this select 1;
        
    [_unit, "killed"] call server_updateObject;
    
    _unit removeAllMPEventHandlers "MPKilled";
    _unit removeAllEventHandlers "Killed";
    _unit removeAllEventHandlers "HandleDamage";
    _unit removeAllEventHandlers "GetIn";
    _unit removeAllEventHandlers "GetOut";
};

check_publishobject = {
    private["_allowed","_allowedObjects","_object"];

    _object = _this select 0;
    _playername = _this select 1;
    _allowedObjects = ["TentStorage", "DomeTentStorage", "Hedgehog_DZ", "Sandbag1_DZ", "TrapBear", "Wire_cat1"];
    _allowed = false;
        
    diag_log format ["DEBUG: Checking if Object: %1 is allowed published by %2", _object, _playername];
        
    if ((typeOf _object) in _allowedObjects) then {
        diag_log format ["DEBUG: Object: %1 published by %2 is Safe",_object, _playername];
        _allowed = true;
    };

    _allowed
};

//event Handlers
eh_localCleanup = {
    private ["_object"];
    _object = _this select 0;
    _object addEventHandler ["local", {
        if(_this select 1) then {
            private["_type","_unit"];
            _unit = _this select 0;
            _type = typeOf _unit;
             _myGroupUnit = group _unit;
             _unit removeAllMPEventHandlers "mpkilled";
             _unit removeAllMPEventHandlers "mphit";
             _unit removeAllMPEventHandlers "mprespawn";
             _unit removeAllEventHandlers "FiredNear";
            _unit removeAllEventHandlers "HandleDamage";
            _unit removeAllEventHandlers "Killed";
            _unit removeAllEventHandlers "Fired";
            _unit removeAllEventHandlers "GetOut";
            _unit removeAllEventHandlers "GetIn";
            _unit removeAllEventHandlers "Local";
            clearVehicleInit _unit;
            deleteVehicle _unit;
            deleteGroup _myGroupUnit;
            _unit = nil;
            diag_log ("CLEANUP: DELETED A " + str(_type) );
        };
    }];
};

server_hiveWrite = {
    private["_data"];
    //diag_log ("ATTEMPT WRITE: " + _this);
    _data = "HiveExt" callExtension _this;
    diag_log ("WRITE: " +str(_data));
};

server_hiveReadWrite = {
    private["_key","_resultArray","_data"];
    _key = _this;
    //diag_log ("ATTEMPT READ/WRITE: " + _key);
    _data = "HiveExt" callExtension _key;
    diag_log ("READ/WRITE: " +str(_data));
    _resultArray = call compile format ["%1",_data];
    _resultArray
};

server_characterSync = {
    private ["_characterID","_playerPos","_playerGear","_playerBackp","_medical","_currentState","_currentModel","_key"];
    _characterID =     _this select 0;    
    _playerPos =    _this select 1;
    _playerGear =    _this select 2;
    _playerBackp =    _this select 3;
    _medical =         _this select 4;
    _currentState =    _this select 5;
    _currentModel = _this select 6;
    
    _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];
    //diag_log ("HIVE: WRITE: "+ str(_key) + " / " + _characterID);
    _key call server_hiveWrite;
};

//onPlayerConnected         "[_uid,_name] spawn server_onPlayerConnect;";
onPlayerDisconnected         "[_uid,_name] call server_onPlayerDisconnect;";

server_getDiff =    {
    private["_variable","_object","_vNew","_vOld","_result"];
    _variable = _this select 0;
    _object =     _this select 1;
    _vNew =     _object getVariable[_variable,0];
    _vOld =     _object getVariable[(_variable + "_CHK"),_vNew];
    _result =     0;
    if (_vNew < _vOld) then {
        //JIP issues
        _vNew = _vNew + _vOld;
        _object getVariable[(_variable + "_CHK"),_vNew];
    } else {
        _result = _vNew - _vOld;
        _object setVariable[(_variable + "_CHK"),_vNew];
    };
    _result
};

server_getDiff2 =    {
    private["_variable","_object","_vNew","_vOld","_result"];
    _variable = _this select 0;
    _object =     _this select 1;
    _vNew =     _object getVariable[_variable,0];
    _vOld =     _object getVariable[(_variable + "_CHK"),_vNew];
    _result = _vNew - _vOld;
    _object setVariable[(_variable + "_CHK"),_vNew];
    _result
};

dayz_objectUID = {
    private["_position","_dir","_key","_object"];
    _object = _this;
    _position = getPosATL _object;
    _dir = direction _object;
    _key = [_dir,_position] call dayz_objectUID2;
    _key
};

dayz_objectUID2 = {
    private["_position","_dir","_key"];
    _dir = _this select 0;
    _key = "";
    _position = _this select 1;
    {
        _x = _x * 10;
        if ( _x < 0 ) then { _x = _x * -10 };
        _key = _key + str(round(_x));
    } forEach _position;
    _key = _key + str(round(_dir));
    _key
};

dayz_recordLogin = {
    private["_key"];
    _key = format["CHILD:103:%1:%2:%3:",_this select 0,_this select 1,_this select 2];
    _key call server_hiveWrite;
};
 
Here's the edit function :
Jz5hcOm.png
 
Lastly, my server.pbo\system\server_monitor.sqf
Code:
[]execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)

dayz_versionNo =         getText(configFile >> "CfgMods" >> "DayZ" >> "version");
dayz_hiveVersionNo =     getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
_script = getText(missionConfigFile >> "onPauseScript");

if ((count playableUnits == 0) and !isDedicated) then {
    isSinglePlayer = true;
};

waitUntil{initialized}; //means all the functions are now defined

diag_log "HIVE: Starting";


if (_script != "") then
{
    diag_log "MISSION: File Updated";
} else {
    while {true} do
    {
        diag_log "MISSION: File Needs Updating";
        sleep 1;
    };
};

//serverVehicleCounter = [];

_allowedObjects = ["TentStorage", "DomeTentStorage","Hedgehog_DZ", "Sandbag1_DZ","TrapBear"];

//Stream in objects
    /* STREAM OBJECTS */
        //Send the key
        _key = format["CHILD:302:%1:",dayZ_instance];
        _result = _key call server_hiveReadWrite;

        diag_log "HIVE: Request sent";
        
        //Process result
        _status = _result select 0;
        
        _myArray = [];
        if (_status == "ObjectStreamStart") then {
            _val = _result select 1;
            //Stream Objects
            diag_log ("HIVE: Commence Object Streaming...");
            for "_i" from 1 to _val do {
                _result = _key call server_hiveReadWrite;

                _status = _result select 0;
                _myArray set [count _myArray,_result];
                //diag_log ("HIVE: Loop ");
            };
        };
    
        _countr = 0;    
        //_totalvehicles = 0;
        {
                
            //Parse Array
            _countr = _countr + 1;
        
            _idKey =     _x select 1;
            _type =        _x select 2;
            _ownerID =     _x select 3;
            _worldspace = _x select 4;
            _intentory=    _x select 5;
            _hitPoints=    _x select 6;
            _fuel =        _x select 7;
            _damage =     _x select 8;

            _dir = 0;
            _pos = [0,0,0];
            _wsDone = false;
            if (count _worldspace >= 2) then
            {
                _dir = _worldspace select 0;
                if (count (_worldspace select 1) == 3) then {
                    _pos = _worldspace select 1;
                    _wsDone = true;
                }
            };            
            if (!_wsDone) then {
                if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
                _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
                if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
                diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
            };
            
            if (_damage < 1) then {
                diag_log format["OBJ: %1 - %2", _idKey,_type];
                
                //Create it
                _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
                _object setVariable ["lastUpdate",time];
                _object setVariable ["ObjectID", _idKey, true];
                _object setVariable ["CharacterID", _ownerID, true];
                
                clearWeaponCargoGlobal  _object;
                clearMagazineCargoGlobal  _object;
                
                if (_object isKindOf "TentStorage" || _object isKindOf "DomeTentStorage") then {
                    _pos set [2,0];
                    _object setpos _pos;
                    _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
                };
                
                _object setdir _dir;
                _object setDamage _damage;
                
                
                if (count _intentory > 0) then {
                    //Add weapons
                    _objWpnTypes = (_intentory select 0) select 0;
                    _objWpnQty = (_intentory select 0) select 1;
                    _countr = 0;                    
                    {
                        if (_x == "Crossbow") then { _x = "Crossbow_DZ" };
                        _isOK =     isClass(configFile >> "CfgWeapons" >> _x);
                        if (_isOK) then {
                            _block =     getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
                            if (!_block) then {
                                _object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
                            };
                        };
                        _countr = _countr + 1;
                    } forEach _objWpnTypes; 
                    
                    //Add Magazines
                    _objWpnTypes = (_intentory select 1) select 0;
                    _objWpnQty = (_intentory select 1) select 1;
                    _countr = 0;
                    {
                        if (_x == "BoltSteel") then { _x = "WoodenArrow" };
                        _isOK =     isClass(configFile >> "CfgMagazines" >> _x);
                        if (_isOK) then {
                            _block =     getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
                            if (!_block) then {
                                _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
                            };
                        };
                        _countr = _countr + 1;
                    } forEach _objWpnTypes;

                    //Add Backpacks
                    _objWpnTypes = (_intentory select 2) select 0;
                    _objWpnQty = (_intentory select 2) select 1;
                    _countr = 0;
                    {
                        _isOK =     isClass(configFile >> "CfgVehicles" >> _x);
                        if (_isOK) then {
                            _block =     getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
                            if (!_block) then {
                                _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
                            };
                        };
                        _countr = _countr + 1;
                    } forEach _objWpnTypes;
                };    
                
               if (_object isKindOf "AllVehicles") then {
                    {
                        _selection = _x select 0;
                        _dam = _x select 1;
                        if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
                        [_object,_selection,_dam] call object_setFixServer;
                    } forEach _hitpoints;
                    _object setvelocity [0,0,1];
                    _object setFuel _fuel;
                    _object call fnc_vehicleEventHandler;
                    //_totalvehicles = _totalvehicles + 1;
                    //serverVehicleCounter set [count serverVehicleCounter,_type];
                };

                //Monitor the object
                //_object enableSimulation false;
                dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
            };
        } forEach _myArray;
        
    // # END OF STREAMING #

//Set the Time
    //Send request
    _key = "CHILD:307:";
    _result = _key call server_hiveReadWrite;
    _outcome = _result select 0;
    if(_outcome == "PASS") then {
        _date = _result select 1; 
        if(isDedicated) then {
            ["dayzSetDate",_date] call broadcastRpcCallAll;
        };

        diag_log ("HIVE: Local Time set to " + str(_date));
    };
    
    createCenter civilian;
    if (isDedicated) then {
        endLoadingScreen;
    };    
    
if (isDedicated) then {
    _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
};

allowConnection = true;

// [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire]
nul = [3, 4, (50 * 60), (15 * 60), 0.75, 'center', 4000, true, false] spawn server_spawnCrashSite;
 
I assume that everything up til the below works. ( so rpt shows all fine.)

Did you trace where the saving fails ?

diag_log format ["DEBUG: Object: %1 published by %2 is Safe
 
Sarge - what log file shows the trace? I'm having a hell of a time figuring out where too look when I do uncomment the diag_log lines.
 
Sarge - what log file shows the trace? I'm having a hell of a time figuring out where too look when I do uncomment the diag_log lines.
The arma2oaserver.RPT in the dayz_1.chernarus (or whatever you use for your server)'s folder.
It is very helpful for debugging.

I've been having a problem where weapons like the MK16 and MK17 variants along with the SCAR varients and rocket launchers will not save to a player's loadout.
I'll be doing some testing on removing this when I get my test server up and running.
 
HOLY SHIT it works. I got it working. Problem is, I'm not 100% on what I ended up changing to get it to work correctly :)

Now, back to figuring out why my player models keep resetting to Survivor2_DZ when logging into the server.
 
HOLY SHIT it works. I got it working. Problem is, I'm not 100% on what I ended up changing to get it to work correctly :)

Now, back to figuring out why my player models keep resetting to Survivor2_DZ when logging into the server.
You should check if they're actually being written to the database as opposed to just being changed in game.
 
Wouldn't have posted it if I hadn't already checked the DB to make sure the object is there. But thanks for the reminder Sir :)
 
Here (to any that wanna check it out).

http://www.derpdayz.jossy.info/@dayz_DERP3.rar

http://www.derpdayz.jossy.info/dayz_server.pbo

Now - it does actually work. Everything in my mod actually mostly works (with a couple vehicle exceptions). But most importantly, the 2nd tent works.

If anyone wants to actually check it out on our test server, you can. You have to launch dayz with the @dayz_DERP3 as your dayz dirctory, not as a -mod, but as the actual directory. (IE - you don't want to also run @dayz - as that will dilute the spawn chances and bring up wierd combinations of loot.)

After you launch the game, you can search by using the filter DERP or GUIDEZ - and attach to the server that is on port 2305 = the word modified is in the server identity as well.

(I'd get exact links or descriptions, but i'm at work and not in a place where i can access all that stuff).


I would have put all this stuff up on getit hub, but that site confuses the crap out of me - sorry.
 
No it can't. Not easily anyway. If it could be done easily, i'd have written it that way.

The main problem is that the new tent object needs all of it's own coding seperate from the origional tent coding, requiring additional SQL files in the dayz_code.pbo and dayz_server.pbo (as well as creating the object in the dayz_equip.pbo). If all the changes were only to the server.pbo, it could be handled by the stock/standard dayz mod. But it necessitates changes directly to the code itself, making a custom version of dayz required.
 
Is there no way to override sections of dayz_code using mission.pbo somehow? I am quite new to this but I managed to put dogs, lift scripts, Sarge's AI, volumetric fog, custom weather, custom zombie behaviour, custom loot and zed spawning, and other minor stuff directly in mission.pbo so everyone with DayZ can play this mission once they join my server.
 
I refer back to my post, just above yours. I have NO idea if you can over-ride player functions. Building a new object is a player function which references a server write function. I think you could write code into the mission.pbo just fine, but having that code for user functions take precidence over what is already in the dayz_code.pbo? I dunno. Doubt it.
 
I refer back to my post, just above yours. I have NO idea if you can over-ride player functions. Building a new object is a player function which references a server write function. I think you could write code into the mission.pbo just fine, but having that code for user functions take precidence over what is already in the dayz_code.pbo? I dunno. Doubt it.
I believe that is possible, since I have fixed some of the loot spawning parameters via mission file.
I scrounged through dayz_code.pbo and found a .sqf that spawned loot, and edited it so it spawns loot while someone's in a vehicle, or if they log in when the server had a restart.

Here are some (possibly) related topics:
http://opendayz.net/threads/deleting-rockets-added-garbage-debris.9530/http://opendayz.net/threads/100-custom-loot-tables-tutorial.8474/
 
Back
Top