[FIX] Tent Saving Issues for 1.8 - Reality Hive

rosska85

Valued Member!
First I'd like to say thanks to Tactical_Force for fixing this issue for 1.7.6.1 onwards. This is a modified version of his work to fix the same problems in 1.8 since the 1.8 code is different.

********​

If you've noticed that after server restarts tents aren't updating their inventories to the database, and can't be removed when packed away or destroyed, then this is the fix you need.

Always remember to create backups before editing, in case anything goes wrong.
For 1.8 only (or Overwatch 0.2.5)
First you're going to need to open up dayz_server\system\server_monitor.sqf
Now find
Code:
            if (_damage < 1) then { // create object
                // for tents: non colliding position
                _entity = createVehicle [_class, _point, [], 0,
                    if (_class=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}
                ];
                _entity setVariable ["ObjectID", _ObjectID, true];
                _entity setVariable ["CharacterID", _CharacterID, true];
                _entity setVariable ["lastUpdate",time];
                _entity setDamage _damage;
 
                if (_class == "TentStorage" || _class == "CamoNet_DZ") then {
                    _entity addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
                };

Change it to
Code:
            if (_damage < 1) then { // create object
                diag_log("Spawned: " + str(_ObjectID) + " " + _class);
 
                // for tents: non colliding position
                _entity = createVehicle [_class, _point, [], 0,
                    if (_class=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}
                ];
                _entity setVariable ["lastUpdate",time];
                // Don't set objects for deployables to ensure proper inventory updates
                if (_CharacterID == "0") then {
                    _entity setVariable ["ObjectID", str(_ObjectID), true];
                } else {
                    _entity setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true];
                };
                _entity setVariable ["CharacterID", _CharacterID, true];
 
                if (_class == "TentStorage" || _class == "CamoNet_DZ") then {
                    _entity addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
                };
 
                _entity setDamage _damage;
Save and close.

For 1.8 and 1.8.0.3
Second, open up dayz_server\compile\server_updateObject.sqf
Now find
Code:
_object_killed = {
    _object setDamage 1;
    call _object_damage;
};

Change it to
Code:
_object_killed = {
    [_ObjectID,_UID] call server_deleteObj;
};
Save and close.

That's all you need, you can now pack up your .pbo again and tents should function correctly.

For 1.8.0.3 only
In dayz_server\system\server_monitor.sqf
Code:
if (_damage < 1) then {
                //diag_log format["OBJ: %1 - %2,%3,%4,%5,%6,%7,%8", _idKey,_type,_ownerID,_worldspace,_inventory,_hitPoints,_fuel,_damage];
     
                dayz_nonCollide = ["DomeTentStorage","TentStorage","CamoNet_DZ"];
     
                //Create it
                _object = createVehicle [_type, _pos, [], 0, if (_type in dayz_nonCollide) then {"NONE"} else {"CAN_COLLIDE"}];
                _object setVariable ["lastUpdate",time];
                _object setVariable ["ObjectID", _idKey, true];
                _object setVariable ["CharacterID", _ownerID, true];
     
                _object setdir _dir;
                _object setDamage _damage;

Change it to
Code:
                if (_damage < 1) then {
                //diag_log format["OBJ: %1 - %2,%3,%4,%5,%6,%7,%8", _idKey,_type,_ownerID,_worldspace,_inventory,_hitPoints,_fuel,_damage];
       
                dayz_nonCollide = ["DomeTentStorage","TentStorage","CamoNet_DZ"];
       
                //Create it
                _object = createVehicle [_type, _pos, [], 0, if (_type in dayz_nonCollide) then {"NONE"} else {"CAN_COLLIDE"}];
                _object setVariable ["lastUpdate",time];
                // Don't set objects for deployables to ensure proper inventory updates
                if (_ownerID == "0") then {
                    _object setVariable ["ObjectID", str(_idKey), true];
                } else {
                    _object setVariable ["ObjectUID", _worldspace call dayz_objectUID2, true];
                };
                _object setVariable ["CharacterID", _ownerID, true];
       
                _object setdir _dir;
                _object setDamage _damage;

If you run into any problems, please post here.
 
I think it will be rather:

Code:
if (_damage < 1) then { // create object
                // for tents: non colliding position
                _entity = createVehicle [_class, _point, [], 0,
                    if (_class=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}
                ];
                if (_CharacterID == "0") then {
                    _entity setVariable ["ObjectID", str(_ObjectID), true];
                } else {
                    _entity setVariable ["ObjectUID", str(_ObjectID),true];
                };
                _entity setVariable ["CharacterID", _CharacterID, true];
                _entity setVariable ["lastUpdate",time];
             
                if (_class == "TentStorage" || _class == "CamoNet_DZ") then {
                    _entity addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
                };
             
                _entity setDamage _damage;

Everything is in original. Only added checks like in 1.7.6.1
Because you can see that in server_updateObject.sqf

Code:
if (!((isNil "_object") OR {(isNull _object)})) then {
    _objectID = _object getVariable ["ObjectID","0"];
    _uid = _object getVariable ["ObjectUID","0"];
};
 
if ((typeName _objectID != "string") || (typeName _uid != "string")) then
{
#ifdef OBJECT_DEBUG
    diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
#endif
    //force fail
    _objectID = "0";
    _uid = "0";
};

We check for string but not for integer value.
 
Yes, the second variable probably should be passed as a string actually. I will edit the variable, but it has been tested very well and works the way it is. :)
 
Hey, I have fixed up your code for 1.8.0.3 as they changed some variables and the way deployables are spawned, and was causing it to face due north.

server_monitor.sqf
Code:
 if (_damage < 1) then { // create object
                diag_log("Spawned: " + str(_idKey) + " " + _type);
       
                // for tents: non colliding position
                _object = createVehicle [_type, _pos, [], 0,
                    if (_type=="TentStorage") then {"NONE"} else {"CAN_COLLIDE"}
                ];
                _object setVariable ["lastUpdate",time];
                // Don't set objects for deployables to ensure proper inventory updates
                if (_ownerID == "0") then {
                    _object setVariable ["ObjectID", str(_idKey), true];
                } else {
                    _object setVariable ["ObjectUID", str(_idKey), true];
                };
                _object setVariable ["CharacterID", _ownerID, true];
 
                if (_type == "TentStorage" || _type == "CamoNet_DZ") then {
                    _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
                };
                _object setdir _dir;
                _object setDamage _damage;
 
Yeah thanks man, I hadn't bothered updating the thread because they've reverted the code changes that caused me to create this thread. The original fix now works for it again if you just use the lines that actually needed changed from the original. Still, handy for others to see the full change for 1.8.0.1 onwards I guess so I'll include what I have in the original post. :)
 
Back
Top