Taviana 2.0 Server needs help!

Discussion in 'Taviana' started by MikeCandys, Oct 27, 2014.

  1. MikeCandys

    MikeCandys Member

    Joined:
    Mar 14, 2013
    Messages:
    87
    Likes Received:
    0
    THANK YOU !

    Hello guys i started to host a Taviana 2.0 Server.

    Ive added already some scripts but i have 1 missing which is really important for me and the server to become famous.

    So the problem is:
    I am looking for someone who can help me implementing that Crashsites to the Tavi 2.0 Map.
    I use vilayer.com atm and i cant see any logs in my rpt about CRASHSPAWN, etc.

    Here is the server_spawnCrashSite.sqf which can be found in compile folder in your dayz_server.pbo:



    Code:
    private["_position","_num","_config","_itemType","_itemChance","_weights","_index","_iArray","_crashModel","_lootTable","_guaranteedLoot","_randomizedLoot","_frequency","_variance","_spawnChance","_spawnMarker","_spawnRadius","_spawnFire","_permanentFire","_crashName"];
    
    //_crashModel    = _this select 0;
    //_lootTable    = _this select 1;
    _guaranteedLoot = _this select 0;
    _randomizedLoot = _this select 1;
    _frequency    = _this select 2;
    _variance    = _this select 3;
    _spawnChance    = _this select 4;
    _spawnMarker    = _this select 5;
    _spawnRadius    = _this select 6;
    _spawnFire    = _this select 7;
    _fadeFire    = _this select 8;
    
    
    diag_log("CRASHSPAWNER: Starting spawn logic for Crash Spawner");
    
    while {true} do {
        private["_timeAdjust","_timeToSpawn","_spawnRoll","_crash","_hasAdjustment","_newHeight","_adjustedPos"];
        // Allows the variance to act as +/- from the spawn frequency timer
        _timeAdjust = round(random(_variance * 2) - _variance);
        _timeToSpawn = time + _frequency + _timeAdjust;
    
        //Adding some Random systems
        _crashModel = ["UH1Wreck_DZ"] call BIS_fnc_selectRandom;
    
        //Crash loot just uncomment the one you wish to use by default with 50cals is enabled.
        //Table including 50 cals
        _lootTable = ["HeliCrash"] call BIS_fnc_selectRandom;
        //Table without 50 cals
        //_lootTable = ["Military","HeliCrash_No50s","MilitarySpecial"] call BIS_fnc_selectRandom;
    
        _crashName    = getText (configFile >> "CfgVehicles" >> _crashModel >> "displayName");
    
        diag_log(format["CRASHSPAWNER: %1%2 chance to spawn '%3' with loot table '%4' at %5", round(_spawnChance * 100), '%', _crashName, _lootTable, _timeToSpawn]);
    
        // Apprehensive about using one giant long sleep here given server time variances over the life of the server daemon
        while {time < _timeToSpawn} do {
            sleep 5;
        };
    
        _spawnRoll = random 1;
    
        // Percentage roll
        if (_spawnRoll <= _spawnChance) then {
    
            _position = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos;
    
            diag_log(format["CRASHSPAWNER: Spawning '%1' with loot table '%2' NOW! (%3) at: %4", _crashName, _lootTable, time, str(_position)]);
    
            _crash = createVehicle [_crashModel,_position, [], 0, "CAN_COLLIDE"];
            // Randomize the direction the wreck is facing
            _crash setDir round(random 360);
    
            // Using "custom" wrecks (using the destruction model of a vehicle vs. a prepared wreck model) will result
            // in the model spawning halfway in the ground.  To combat this, an OPTIONAL configuration can be tied to
            // the CfgVehicles class you've created for the custom wreck to define how high above the ground it should
            // spawn.  This is optional.
            _config = configFile >> "CfgVehicles" >> _crashModel >> "heightAdjustment";
            _hasAdjustment =  isNumber(_config);
            _newHeight = 0;
            if (_hasAdjustment) then {
                _newHeight = getNumber(_config);
                //diag_log(format["DIAG: ADJUSTMENT FOUND FOR %1, IT IS: %2", _crashName, _newHeight]);
            };
    
            // Must setPos after a setDir otherwise the wreck won't level itself with the terrain
            _adjustedPos = [(_position select 0), (_position select 1), _newHeight];
            //diag_log(format["DIAG: Designated Position: %1", str(_adjustedPos)]);
            _crash setPos _adjustedPos;
    
            // I don't think this is needed (you can't get "in" a crash), but it was in the original DayZ Crash logic
            dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_crash];
    
            _crash setVariable ["ObjectID",1,true];
    
            if (_spawnFire) then {
                //["dayzFire",[_crash,2,time,false,_fadeFire]] call broadcastRpcCallAll;
                dayzFire = [_crash,2,time,false,_fadeFire];
                publicVariable "dayzFire";
                _crash setvariable ["fadeFire",_fadeFire,true];
            };
    
            _num        = round(random _randomizedLoot) + _guaranteedLoot;
       
            _config =         configFile >> "CfgBuildingLoot" >> _lootTable;
            _itemTypes =    [] + getArray (_config >> "itemType");
            _index =        dayz_CBLBase  find "HeliCrash";
            _weights =        dayz_CBLChances select _index;
            _cntWeights = count _weights;
    
    
            for "_x" from 1 to _num do {
                //create loot
                _index = floor(random _cntWeights);
                _index = _weights select _index;
                _itemType = _itemTypes select _index;
                [_itemType select 0, _itemType select 1, _position, 5] call spawn_loot;
    
                diag_log(format["CRASHSPAWNER: Loot spawn at '%1' with loot table '%2'", _crashName, _lootTable]);
    
                // ReammoBox is preferred parent class here, as WeaponHolder wouldn't match MedBox0 and other such items.
                _nearby = _position nearObjects ["ReammoBox", sizeOf(_crashModel)];
                {
                    _x setVariable ["permaLoot",true];
                } forEach _nearBy;
            };
        };
    };
    
     
    Last edited: Oct 27, 2014
  2. MikeCandys

    MikeCandys Member

    Joined:
    Mar 14, 2013
    Messages:
    87
    Likes Received:
    0
    Here is the server_monitor.sqf(dayz_server\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;
        };
    };
    
        //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 ");
                };
                //diag_log ("HIVE: Streamed " + str(_val) + " objects");
            };
       
            _countr = 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") 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" }; // Convert Crossbow to 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" }; // Convert BoltSteel to 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;
                    };
                    if (_object isKindOf "AN2_DZ") then {
                    _object addWeapon "M240_veh";
                    _object addMagazine "100Rnd_762x51_M240";
                    _object addMagazine "100Rnd_762x51_M240";
                    _object addMagazine "100Rnd_762x51_M240";
                    };
                    if (_object isKindOf "AH6X_DZ") then {
                    _object addWeapon "M249";
                    _object addMagazine "200Rnd_556x45_M249";
                    _object addMagazine "200Rnd_556x45_M249";
                    };
    
                    //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;
                setDate _date;
                dayzSetDate = _date;
                publicVariable "dayzSetDate";
            };
    
            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 = [5, 5, (0 * 20), (10 * 35), 0.99, 'center', 4000, true, false] spawn server_spawnCrashSite;
    
     
  3. MikeCandys

    MikeCandys Member

    Joined:
    Mar 14, 2013
    Messages:
    87
    Likes Received:
    0
    And here is the server_functions.sqf(dayz_server\init\server_functions.sqf):

    Code:
    [] spawn {[] execVM "\z\addons\dayz_server\init\AH.sqf";};
    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", "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;
    };
    
    call compile preProcessFileLineNumbers "\z\addons\dayz_server\buildings\main.sqf";
     

Share This Page