Jump to content

[Release] Anti Combat Log 1.0.6.1


icomrade

Recommended Posts

Updated version of this script: 

In server_playerSync.sqf

Find this block of code: https://github.com/EpochModTeam/DayZ-Epoch/blob/Release_1.0.6.2/SQF/dayz_server/compile/server_playerSync.sqf#L142-L149

Replace with: 

if (_this select 4) then { //combat logged
	_medical set [1, true]; //set unconcious to true
	_medical set [10, 150]; //combat timeout
	//_character setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
	//_character setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds
	//_character setVariable ["USEC_injured",true]; // Set status to bleeding
	//_character setVariable ["USEC_BloodQty",3000]; // Set blood to 3000

	//Begin anti combat log
	_weapons            = _playerGear select 0;
	_weapons_backpack     = _playerBackp select 1;
	_current_magazine    = currentMagazine _playerObj;
	_magazines_backpack = _playerBackp select 2;
	_magazinesRemove = _magazines;

	if ((typeName (_magazinesRemove select 0)) == "ARRAY") then {
		if ((count _magazinesRemove > 1) && {((typeName (_magazinesRemove select 1)) == "STRING") && {((_magazinesRemove select 1) != "")}}) then {
			_weapons set [(count _weapons), (_magazinesRemove select 1)];
		};
		_magazinesRemove = _magazines select 0;
	};

	_loot_box = "USBasicAmmunitionBox" createVehicle [0,0,0];

	clearMagazineCargoGlobal _loot_box;
	clearWeaponCargoGlobal _loot_box;

	{
		_loot_box addWeaponCargoGlobal [_x,1];
	} forEach _weapons;

	_magazinesRemove set [(count _magazinesRemove),_current_magazine];

	{
		_loot_box addMagazineCargoGlobal [_x,1];
	} forEach _magazinesRemove;

	if (typeOf _backpack != "") then {
		if ((typename _weapons_backpack) == "ARRAY") then {
			{
				_loot_box addWeaponCargoGlobal [_x,((_weapons_backpack select 1) select _forEachIndex)];
			} forEach (_weapons_backpack select 0);
		};

		if ((typename _magazines_backpack) == "ARRAY") then {
			{
				_loot_box addMagazineCargoGlobal [_x,((_magazines_backpack select 1) select _forEachIndex)];
			} forEach (_magazines_backpack select 0);
		};
		_loot_box addBackpackCargoGlobal[(typeOf _backpack),1];
	};

	_playerBackp = ["",[[],[]],[[],[]]];
	_playerGear = [[],[]];
	_currentAnim = "";
	_currentWpn = "";
	//End anti combat log
};

 

Above this line: https://github.com/EpochModTeam/DayZ-Epoch/blob/Release_1.0.6.2/SQF/dayz_server/compile/server_playerSync.sqf#L180

place this code: 

if (!isNil "_loot_box") then { //anti combat-log
	_loot_box setPos _charPos;
};

YOU MUST ADD "_loot_box" TO YOUR PRIVATE ARRAY AT THE TOP OF THE FILE!

Link to comment
Share on other sites

Works great, had it on my server a while now, hoever took me a while to get it working. Came to the conclusion it was infistar messing with it.

Did some testing and got it working by doing the following.

 Open AH.sqf and find

_fnc_punish_combatlog = {
                  _isInCombat = player getVariable['startcombattimer',0];
                    if(str _isInCombat != '0')then{ player setDamage 1; };
                };

Comment out that whole section

//_fnc_punish_combatlog = {
                //    _isInCombat = player getVariable['startcombattimer',0];
                    //if(str _isInCombat != '0')then{ player setDamage 1; };
                //};

 

Save and it should work a treat.

Link to comment
Share on other sites

1 hour ago, SmokeyBR said:

i remember when i used this back then, the box would end up in the air case player was flying, if you didnt worked that in, any chance you look into it ?

Updated original post to fix this (untested, but minor changes so meh).

Edit: Almost forgot, you'll need to add "_loot_box" to the file's private array

Link to comment
Share on other sites

testing went all good everything working.

heres some more headache for you hehe, when testing while flying i was above water once you get out of knockout you start swiming above it and loose the box, also maybe add coins support transform coins into briefcases, hehe but thats just me throwing out there.

im pretty satisfied with the it is right now, thank you.

Link to comment
Share on other sites

12 hours ago, SmokeyBR said:

testing went all good everything working.

heres some more headache for you hehe, when testing while flying i was above water once you get out of knockout you start swiming above it and loose the box, also maybe add coins support transform coins into briefcases, hehe but thats just me throwing out there.

im pretty satisfied with the it is right now, thank you.

Actually there's a pretty obvious error I left in. The bellow should fix your issues with water

 

try changing 

_loot_box setPosATL _charPos; //anti combat-log

to

if (!isNil "_loot_box") then { //anti combat-log
	_loot_box setPos _charPos;
};

 

Link to comment
Share on other sites

10 hours ago, icomrade said:

Actually there's a pretty obvious error I left in. The bellow should fix your issues with water

 

try changing 


_loot_box setPosATL _charPos; //anti combat-log

to


if (!isNil "_loot_box") then { //anti combat-log
	[_loot_box, _charPos, !(surfaceIsWater _charPos)] call FNC_GetSetPos;
};

 

Would that be the same as setPosASL?   If so I had problems with it going in side of hills.

Link to comment
Share on other sites

Just now, Hooty said:

Would that be the same as setPosASL?   If so I had problems with it going in side of hills.

You'd need to use SetPos for angle compensation, I didn't think it would be an issue (and the command is much much slower than SetPosATL/SetPosASL).

_loot_box setPos _charPos;

 

Link to comment
Share on other sites

2 minutes ago, icomrade said:

You'd need to use SetPos for angle compensation, I didn't think it would be an issue (and the command is much much slower than SetPosATL/SetPosASL).


_loot_box setPos _charPos;

 

Ok thank you putting it in now.

Link to comment
Share on other sites

  • 4 weeks later...

Easy Install but when I test it (combat log) there is no box when I rejoin.

What did I miss?

EDIT: Players now report loss of all gear and coins with relog after this was installed.

Spoiler

private ["_distanceFoot","_playerPos","_lastPos","_playerGear","_medical","_currentModel","_currentAnim",
"_currentWpn","_muzzles","_array","_coins","_key","_globalCoins","_bankCoins","_playerBackp","_exitReason",
"_backpack","_kills","_killsB","_killsH","_headShots","_humanity","_lastTime","_timeGross","_timeSince",
"_timeLeft","_config","_onLadder","_isTerminal","_modelChk","_temp","_currentState","_character",
"_magazines","_characterID","_charPos","_isInVehicle","_name","_inDebug","_newPos","_count","_maxDist","_relocate","_playerUID","_loot_box"];
//[player,array]

_character = _this select 0;
_magazines = _this select 1;
_characterID = _character getVariable ["characterID","0"];
_playerUID = getPlayerUID _character;
_charPos = getPosATL _character;
_isInVehicle = vehicle _character != _character;
_timeSince = 0;
_humanity = 0;
_name = if (alive _character) then {name _character} else {"Dead Player"};
_inDebug = (respawn_west_original distance _charPos) < 1500;

_exitReason = switch true do {
    case (isNil "_characterID"): {("ERROR: Cannot Sync Character " + _name + " has nil characterID")}; //Unit is null
    case (_inDebug): {format["INFO: Cannot Sync Character %1 near respawn_west %2. This is normal when relogging or changing clothes.",_name,_charPos]};
    case (_characterID == "0"): {("ERROR: Cannot Sync Character " + _name + " has no characterID")};
    case (_character isKindOf "Animal"): {("ERROR: Cannot Sync Character " + _name + " is an Animal class")};
    default {"none"};
};

if (_exitReason != "none") exitWith {
    diag_log _exitReason;
};

//Check for player initiated updates
_playerPos =    [];
_playerGear =    [];
_playerBackp =    [];
_medical =        [];
_distanceFoot =    0;

//all getVariable immediately
_globalCoins = _character getVariable ["GlobalMoney", -1];
_bankCoins = _character getVariable ["MoneySpecial", -1];
_coins = _character getVariable [Z_MoneyVariable, -1]; //should getting coins fail set the variable to an invalid value to prevent overwritting the in the DB
_lastPos = _character getVariable ["lastPos",_charPos];
_usec_Dead = _character getVariable ["USEC_isDead",false];
_lastTime =     _character getVariable ["lastTime",diag_ticktime];
_modelChk =     _character getVariable ["model_CHK",""];
_temp = round (_character getVariable ["temperature",100]);
_lastMagazines = _character getVariable ["ServerMagArray",[[],""]];
/*
    Check previous stats against what client had when they logged in
    this helps prevent JIP issues, where a new player wouldn't have received
    the old players updates. Only valid for stats where clients could have
    be recording results from their local objects (such as agent zombies)
*/
_kills =         ["zombieKills",_character] call server_getDiff;
_killsB =         ["banditKills",_character] call server_getDiff;
_killsH =         ["humanKills",_character] call server_getDiff;
_headShots =     ["headShots",_character] call server_getDiff;
_humanity =     ["humanity",_character] call server_getDiff2;

_charPosLen = count _charPos;

if (!isNil "_magazines") then {
    if (typeName _magazines == "ARRAY") then {
        _playerGear = [weapons _character,_magazines select 0,_magazines select 1];
        _character setVariable["ServerMagArray",_magazines, false];
    };
} else {
    //check Magazines everytime they aren't sent by player_forceSave
    _magTemp = (_lastMagazines select 0);
    if (count _magTemp > 0) then {
        _magazines = [(magazines _character),20] call array_reduceSize;
        {
            _class = _x;
            if (typeName _x == "ARRAY") then {
                _class = _x select 0;
            };
            if (_class in _magazines) then {
                _MatchedCount = {_compare = if (typeName _x == "ARRAY") then {_x select 0;} else {_x}; _compare == _class} count _magTemp;
                _CountedActual = {_x == _class} count _magazines;
                if (_MatchedCount > _CountedActual) then {
                    _magTemp set [_forEachIndex, "0"];
                };
            } else {
                _magTemp set [_forEachIndex, "0"];
            };
        } forEach (_lastMagazines select 0);
        _magazines = _magTemp - ["0"];
        _magazines = [_magazines, (_lastMagazines select 1)];
        _character setVariable["ServerMagArray",_magazines, false];
        _playerGear = [weapons _character,_magazines select 0,_magazines select 1];
    };
};

//Check if update is requested
if !((_charPos select 0 == 0) && (_charPos select 1 == 0)) then {
    //Position is not zero
    //diag_log ("getting position..."); sleep 0.05;
    _playerPos = [round (direction _character),_charPos];
    if (count _lastPos > 2 && {_charPosLen > 2}) then {
        if (!_isInVehicle) then {_distanceFoot = round (_charPos distance _lastPos);};
        _character setVariable["lastPos",_charPos];
    };
    if (_charPosLen < 3) then {_playerPos = [];};
    //diag_log ("position = " + str(_playerPos)); sleep 0.05;
};
_character setVariable ["posForceUpdate",false,true];

//Check player backpack each time sync runs
_backpack = unitBackpack _character;
_playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];

if (!_usec_Dead) then {
    //diag_log ("medical check..."); sleep 0.05;
    _medical = _character call player_sumMedical;
    //diag_log ("medical result..." + str(_medical)); sleep 0.05;
};
_character setVariable ["medForceUpdate",false,true];

_character addScore _kills;        
_timeGross =     (diag_ticktime - _lastTime);
_timeSince =     floor (_timeGross / 60);
_timeLeft =        (_timeGross - (_timeSince * 60));
/*
    Get character state details
*/
_currentWpn =     currentMuzzle _character;
_currentAnim =    animationState _character;
_config =         configFile >> "CfgMovesMaleSdr" >> "States" >> _currentAnim;
_onLadder =        (getNumber (_config >> "onLadder")) == 1;
_isTerminal =     (getNumber (_config >> "terminal")) == 1;
//_wpnDisabled =    (getNumber (_config >> "disableWeapons")) == 1;
_currentModel = typeOf _character;
if (_currentModel == _modelChk) then {
    _currentModel = "";
} else {
    _currentModel = str _currentModel;
    _character setVariable ["model_CHK",typeOf _character];
};
if (_this select 4) then { //combat logged
    _medical set [1, true]; //set unconcious to true
    _medical set [10, 150]; //combat timeout
    //_character setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
    //_character setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds
    //_character setVariable ["USEC_injured",true]; // Set status to bleeding
    //_character setVariable ["USEC_BloodQty",3000]; // Set blood to 3000

    //Begin anti combat log
    _weapons            = _playerGear select 0;
    _weapons_backpack     = _playerBackp select 1;
    _current_magazine    = currentMagazine _playerObj;
    _magazines_backpack = _playerBackp select 2;
    _magazinesRemove = _magazines;

    if ((typeName (_magazinesRemove select 0)) == "ARRAY") then {
        if ((count _magazinesRemove > 1) && {((typeName (_magazinesRemove select 1)) == "STRING") && {((_magazinesRemove select 1) != "")}}) then {
            _weapons set [(count _weapons), (_magazinesRemove select 1)];
        };
        _magazinesRemove = _magazines select 0;
    };

    _loot_box = "USBasicAmmunitionBox" createVehicle [0,0,0];

    clearMagazineCargoGlobal _loot_box;
    clearWeaponCargoGlobal _loot_box;

    {
        _loot_box addWeaponCargoGlobal [_x,1];
    } forEach _weapons;

    _magazinesRemove set [(count _magazinesRemove),_current_magazine];

    {
        _loot_box addMagazineCargoGlobal [_x,1];
    } forEach _magazinesRemove;

    if (typeOf _backpack != "") then {
        if ((typename _weapons_backpack) == "ARRAY") then {
            {
                _loot_box addWeaponCargoGlobal [_x,((_weapons_backpack select 1) select _forEachIndex)];
            } forEach (_weapons_backpack select 0);
        };

        if ((typename _magazines_backpack) == "ARRAY") then {
            {
                _loot_box addMagazineCargoGlobal [_x,((_magazines_backpack select 1) select _forEachIndex)];
            } forEach (_magazines_backpack select 0);
        };
        _loot_box addBackpackCargoGlobal[(typeOf _backpack),1];
    };

    _playerBackp = ["",[[],[]],[[],[]]];
    _playerGear = [[],[]];
    _currentAnim = "";
    _currentWpn = "";
    //End anti combat log
};    
    if (_isInVehicle) then {
        //if the player object is inside a vehicle lets eject the player
        _relocate = ((vehicle _character isKindOf "Air") && (_charPos select 2 > 1.5));
        _character action ["eject", vehicle _character];
        
        // Prevent relog in parachute, heli or plane above base exploit to get inside
        if (_relocate) then {
            _count = 0;
            _maxDist = 800;
            _newPos = [_charPos, 80, _maxDist, 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
            
            while {_newPos distance _charPos == 0} do {
                _count = _count + 1;
                if (_count > 4) exitWith {_newPos = _charPos;}; // Max 4km away fail safe (needs to finish fast so server_playerSync runs below)
                _newPos = [_charPos, 80, (_maxDist + 800), 10, 1, 0, 0, [], [_charPos,_charPos]] call BIS_fnc_findSafePos;
            };
            _newPos set [2,0]; //findSafePos only returns two elements
            _charPos = _newPos;
            diag_log format["%1(%2) logged out in air vehicle. Relocated to safePos.",_name,_playerUID];
        };
    };
};
if (_onLadder or _isInVehicle or _isTerminal) then {
    _currentAnim = "";
    //If position to be updated, make sure it is at ground level!
    if ((count _playerPos > 0) && !_isTerminal) then {
        _charPos set [2,0];
        _playerPos set [1,_charPos];                    
    };
};
if (!isNil "_loot_box") then { //anti combat-log
    _loot_box setPos _charPos;
};
if (_isInVehicle) then {
    _currentWpn = "";
} else {
    if (typeName _currentWpn == "STRING") then {
        _muzzles = getArray (configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
        if (count _muzzles > 1) then {_currentWpn = currentMuzzle _character;};    
    } else {
        //diag_log ("DW_DEBUG: _currentWpn: " + str(_currentWpn));
        _currentWpn = "";
    };
};
_currentState = [[_currentWpn,_currentAnim,_temp],[]];

// If player is in a vehicle, keep its position updated
if (vehicle _character != _character) then {
    [vehicle _character, "position"] call server_updateObject;
};

//Reset timer
if (_timeSince > 0) then {
    _character setVariable ["lastTime",(diag_ticktime - _timeLeft)];
};

/*
    Everything is ready, now publish to HIVE
    Low priority code below this point where _character object is no longer needed and may be Null.
*/
if (count _playerPos > 0) then {
    _array = [];
    {
        if (_x > dayz_minpos && _x < dayz_maxpos) then {_array set [count _array,_x];};
    } forEach (_playerPos select 1);
    _playerPos set [1,_array];
};

//Wait for HIVE to be free and send request
_key = if (Z_SingleCurrency) then {
    format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity,_coins]
} else {
    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,_kills,_headShots,_distanceFoot,_timeSince,_currentState,_killsH,_killsB,_currentModel,_humanity]
};

//diag_log str formatText["INFO - %2(UID:%3) PlayerSync, %1",_key,_name,_playerUID];

_key call server_hiveWrite;

if (Z_SingleCurrency) then { //update global coins
    _key = format["CHILD:205:%1:%2:%3:%4:",_playerUID,dayZ_instance,_globalCoins,_bankCoins];
    _key call server_hiveWrite;
};

// Force gear updates for nearby vehicles/tents
{[_x,"gear"] call server_updateObject;} count nearestObjects [_charPos,DayZ_GearedObjects,10];

 

Link to comment
Share on other sites

  • 1 month later...
  • 8 months later...
57 minutes ago, nova said:

guess not :(

Since this file already gets the player's Z_MoneyVariable variable and syncs it to the database at the end, you just need to find this line:

clearWeaponCargoGlobal _loot_box;

And add this below it:

_loot_box setVariable [Z_MoneyVariable,_coins,true];
	_coins = 0;

Then add "USBasicAmmunitionBox" to the DZE_MoneyStorageClasses array in varables.sqf

 

Maybe there is another step, but I think that should work.

Link to comment
Share on other sites

  • 1 month later...

Question about part of this topic:

Is there any way to disable the unconcious state or to let it really low (like 3-5 secs)? I have a couple of ex militars in my group and keep telling me that "a bullet hurt and burn like hell... but you dont faint for a shot in a leg or in the arm" jajajaja

Thank you

Link to comment
Share on other sites

6 hours ago, LadyVal said:

Question about part of this topic:

Is there any way to disable the unconcious state or to let it really low (like 3-5 secs)? I have a couple of ex militars in my group and keep telling me that "a bullet hurt and burn like hell... but you dont faint for a shot in a leg or in the arm" jajajaja

Thank you

Comment out these 2 lines: https://github.com/EpochModTeam/DayZ-Epoch/blob/Release_1.0.6.2/SQF/dayz_server/compile/server_playerSync.sqf#L143-L144

Link to comment
Share on other sites

 

Thanks a lot, Salival!!

----------------------------------------------------------------------------------

I commented those 2 lines like you suggested but it is not working.  Guys not only have the hourglass, it last even much more longer.
The idea is... if the shot kills you, it kills you.. if not,, no unconcious time

Spoiler
if (count _this > 4) then { //calling from player_onDisconnect
  if (_this select 4) then { //combat logged
  _medical set [1, true]; //set unconcious to true
  _medical set [10, 150]; //combat timeout
  //_character setVariable ["NORRN_unconscious",true,true]; // Set status to unconscious
  //_character setVariable ["unconsciousTime",150,true]; // Set knock out timer to 2 minutes 30 seconds
  //_character setVariable ["USEC_injured",true]; // Set status to bleeding
  //_character setVariable ["USEC_BloodQty",3000]; // Set blood to 3000
  };
Link to comment
Share on other sites

  • 9 months later...

this script works as is with no problems... if you do have a problem is on your server.

go though the installation again make sure everything was done properly, also make sure you do this:

On 3/24/2017 at 2:42 PM, icomrade said:

YOU MUST ADD "_loot_box" TO YOUR PRIVATE ARRAY AT THE TOP OF THE FILE!

if you are 200% sure you followed all the steps than something else is messing with it, i would guess infistar if you use it. A good next step for finding the problem is looking for errors on client RPT and server RPT.

Link to comment
Share on other sites

Yes it was indeed Infistar in AH.sqf I just commented it out. 

//_fnc_punish_combatlog = {

//isInCombat = player getVariable['startcombattimer',0];

 //if(str _isInCombat != '0')then{ player setDamage 1; };

 //};

And in the AHconfig.sqf and turned off 

_UCL =  false;    // Use Anti Combat Log    /* true or false */

Works now! :)

Thanks for your help @SmokeyBR

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...