Jump to content

[Release] Anti Combat Log


f3cuk

Recommended Posts

Anti Combat Log
 
Grew tired with the combat logging on our server and felt like I had to do something about it. What I came up with was actually pretty easy - and as such - has probably already been done loads of times before but since i couldn't find it -> here goes.

What this does
 
Whenever a player combat logs from the server ALL of his gear will be taken from his body and put in a crate right where he logged off. This way, when it was a malicious log, the other side has the possibility to get the (well deserved) gear. When it was an accident log, there is a good chance the box will still be there when the player logs back in and he can safely take his stuff back.
 
Installation instructions
 
1.) Unpack your dayz_server.pbo

 

2.) Open compiles/server_onPlayerdisconnect.sqf

 

Find

private ["

 

Replace with

private ["_removebackpack","_pos","_backpack","_weapons","_weapons_backpack","_magazines","_current_magazine","_magazines_backpack","_loot_box","

 

Find

_playerPos = [];

Add below

_removebackpack = false;

 
Find

	_playerObj setVariable["NORRN_unconscious",true, true];
	_playerObj setVariable["unconsciousTime",300,true];
	
	diag_log format["COMBAT LOGGED: %1 (%2) at location %3", _playerName,_timeout,(getPosATL _playerObj)];
	//diag_log format["SET UNCONCIOUSNESS: %1", _playerName];
	
	// Message whole server when player combat logs
	_message = format["PLAYER COMBAT LOGGED: %1",_playerName];
	[nil, nil, rTitleText, _message, "PLAIN"] call RE;

Replace with

        _playerObj setVariable["NORRN_unconscious",true,true];
        _playerObj setVariable["unconsciousTime",120,true];

        _pos                 = getPosAtl _playerObj;
        _backpack            = unitBackpack _playerObj;
        _weapons            = weapons _playerObj;
        _weapons_backpack     = getWeaponCargo _backpack;
        _magazines            = magazines _playerObj;
        _current_magazine    = currentMagazine _playerObj;
        _magazines_backpack = getMagazineCargo _backpack;
        _loot_box             = createVehicle ["USBasicAmmunitionBox",_pos,[],0,"CAN_COLLIDE"];

        clearMagazineCargoGlobal _loot_box;
        clearWeaponCargoGlobal _loot_box;

        {
            _loot_box addWeaponCargoGlobal [_x,1];
        } count (_weapons);

        _magazines set [(count _magazines),_current_magazine];

        {
            _loot_box addMagazineCargoGlobal [_x,1];
        } count (_magazines);

        if (typename _weapons_backpack == "ARRAY") then {

            _i = 0;

            {
                _loot_box addWeaponCargoGlobal [_x,((_weapons_backpack select 1) select _i)];
                _i = _i + 1;
            } count (_weapons_backpack select 0);

        };

        if (typename _magazines_backpack == "ARRAY") then {

            _i = 0;

            {
                _loot_box addMagazineCargoGlobal [_x,((_magazines_backpack select 1) select _i)];
                _i = _i + 1;
            } count (_magazines_backpack select 0);

        };

        if(typeOf _backpack != "") then {
            _loot_box addBackpackCargoGlobal[(typeOf _backpack),1];
        };
    
        diag_log format["COMBAT LOGGED: %1 (%2) at location %3 - DEBUG: Weapons: (%4 - %5) / Magazines: (%6 - %7) / Backpack: (%8)",_playerName,_timeout,(getPosATL _playerObj),_weapons,_weapons_backpack,_magazines,_magazines_backpack,_backpack];

        _message = format["PLAYER COMBAT LOGGED: %1",_playerName];

        [nil, nil, rTitleText, _message, "PLAIN"] call RE;

        _removebackpack = true;

        {
            _playerObj removeMagazine _x;
        } count magazines _playerObj;

        {
            _playerObj removeWeapon _x;
        } count _weapons;

Find

[_playerObj,_magazines,true,true,_isplayernearby] call server_playerSync;

Replace with

[_playerObj,_magazines,true,true,_isplayernearby,_removebackpack] call server_playerSync;

 
3.) Open compiles/server_playersync.sqf

Find

private ["

 

Replace with

private ["_removebackpack","

Find
_playerwasNearby = false;

Add below

_removebackpack = false;

Find

if ((count _this) > 4) then {
    _playerwasNearby = _this select 4;
};

Add below

if ((count _this) > 5) then {
    _removebackpack = _this select 5;
};

Find

    if (_isNewGear || _forceGear) then {
        //diag_log ("gear..."); sleep 0.05;
        _playerGear = [weapons _character,_magazines];
        //diag_log ("playerGear: " +str(_playerGear));
        _backpack = unitBackpack _character;
        if(_playerwasNearby) then {
            _empty = [[],[]];
            _playerBackp = [typeOf _backpack,_empty,_empty];
        } else {
            _playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];
        };
    };

Add below

    if(_removeBackpack) then {
        _playerBackp = ["",[[],[]],[[],[]]];
    };

 
3.) That's it, save, close, repack and you're all set!

Link to comment
Share on other sites

shouldn't you add _removebackpack to the private array at the top as well?

 

Ehm yes, good catch. OP edited.

 

If that's truly the case, you provide evidence and the admin can easily restore gear lost.

 

True, I made it so that when the combat log happens it writes a line to your RPT file with all of the information of that player.

Link to comment
Share on other sites

Ehm yes, good catch. OP edited.

 

 

True, I actually made it so that when the combat log happens it actually writes a line to your RPT file with all of the information of that player.

 

I noticed that, great add to easily see the gear that was lost!

Link to comment
Share on other sites

Thank you F3cuk as always, using this now on my server ;)

 

You're very welcome paddy :)

 

works great, thankz for this..

seems it duped my GPS

have one in my inventory and one in the box....

other than that its working great

 

The duped GPS might be you activating your admin tools (which usually gives you a GPS).

 

now howz about something similar for blown up vehicle gear...

except loot scattered on ground ????

 

Hmm that might be doable, actually something i have thought about a number of times already but that was before i got into scripting. No promises but I'll look into it :)

Link to comment
Share on other sites

Hmm that might be doable, actually something i have thought about a number of times already but that was before i got into scripting. No promises but I'll look into it :)

Okay so one major problem with this is that it would become rewarding to destroy vehicles from other players, which is something i definitely do not want to encourage.

Link to comment
Share on other sites

  • 2 weeks later...

Doesnt work for me guys. I have to put ]; after this private["_removebackpack","_pos","_backpack","_weapons","_weapons_backpack","_magazines","_current_magazine","_magazines_backpack","_loot_box","  ????

 

and like this

 

if ((count _this) > 5) then {
    _removebackpack = _this select 5;
};

 

  if (_isNewGear || _forceGear) then {
        //diag_log ("gear..."); sleep 0.05;
        _playerGear = [weapons _character,_magazines];
        //diag_log ("playerGear: " +str(_playerGear));
        _backpack = unitBackpack _character;
        if(_playerwasNearby) then {
            _empty = [[],[]];
            _playerBackp = [typeOf _backpack,_empty,_empty];
        } else {
            _playerBackp = [typeOf _backpack,getWeaponCargo _backpack,getMagazineCargo _backpack];
        };
    };   <<<< have this guy and the up one in right place?

Link to comment
Share on other sites

  • 5 weeks later...

can you add coins (3.0)=] mayb commented out =] thanks again

 

Well, Coins are more of a stat not an item, they dont have a classname. However, it may be possible to add a check wallet action to the crate it's self. The people with a definite answer to this would more than likely be the creators of the coin script. If you have scripting knowledge, you may just find the answer in the coin script it's self. Just look for the player death part and try to incorporate the 2 together.

Link to comment
Share on other sites

Hey there, at first: great tut - thanks a lot. I just got the problem that I combat logged for a test and my dead corpse (a friend shot me once - but just to hit me and it doesnt killed me) and all my loot duplicated. I checked all files and lines and found no mistakes. My server runs at ZAP-Hosting with newest Overpoch  Chernarus version. I hope you can help me to find a solution . 

 
 
11:06:59 File z\addons\dayz_server\compile\server_onPlayerDisconnect.sqf, line 1
11:06:59 Error in expression <Disconnect.sqf"
private [_removebackpack","_pos","_backpack","_weapons","_weapon>
11:06:59   Error position: <","_pos","_backpack","_weapons","_weapon>
11:06:59   Error Missing ]
11:06:59 File z\addons\dayz_s
 
edit: private ["_removebackpack","  i have fixed
Link to comment
Share on other sites

  • 2 weeks later...

Hi thanks for making this – love it :)

 

We been having fun running it on our test server, works like a charm. Only had this small issue….

 

If a player is in combat in a chopper and combat logs then the box is in the sky, not on the ground

We decided to use it for target practice and it blow up  :lol:

Link to comment
Share on other sites

Hi thanks for making this – love it :)

 

We been having fun running it on our test server, works like a charm. Only had this small issue….

 

If a player is in combat in a chopper and combat logs then the box is in the sky, not on the ground

We decided to use it for target practice and it blow up  :lol:

If it is a big enough issue you could just create an if statement where if player is not in vehicle then it will execute the following code.. If a player is in a vehicle then it wouldn't exec this code.. Or play around with fnc_find safe position.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

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...