Jump to content

[How To] Anti-Glitch script. Block unconscious players from being dragged into bases


Sandbird

Recommended Posts

There is this really annoying bug, where a player can be dragged inside walls/bases when he is unconscious...so you get a little surprise when you log in the game and get killed inside your wall proofed base.

Well not anymore :)

Here is the fix for it.

 

What this does

This will NOT allow the player to Drop his dragging by the neck friend inside a player's base. The script will check if there is an epoch wall, house, building (check drop_body.sqf) withing 10m of the player...and if there is it wont do anything when the player selects "Drop Body". Instead it will create a diag_log entry and notify him in a nice way that he is a total noob for trying to glitch :P.

 

Initialize

 

You are probably overwriting compiles.sqf and with it fn_selfActions.sqf. Well you have to do the same for fn_damageActions.sqf.

So open compiles.sqf and replace fnc_usec_damageActions with this:

fnc_usec_damageActions =    compile preprocessFileLineNumbers "dayz_code\compile\fn_damageActions.sqf";

and move the file fn_damageActions.sqf (from the dayz_code.pbo) inside your compile folder.

 

Now, do the following steps:

 

 

Step 1

Open fn_damageActions.sqf and change:

_action1 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];

to this

_action1 = _unit addAction [localize "str_actions_medical_01", "dayz_code\medical\drag.sqf",_unit, 0, true, true];

Step 2

inside your dayz_code folder create a folder called medical. Inside medical make 2 files...drag.sqf, drop_body.sqf

So in the end you have:

MPMissions\DayZ_Epoch_17.Chernarus\dayz_code\medical\drag.sqf

MPMissions\DayZ_Epoch_17.Chernarus\dayz_code\medical\drop_body.sqf

 

Here is the content of those 2 files.

 

drag.sqf

/*

 DRAG BODY SCRIPT

 Allows players to drag unconscious bodies 

 JULY 2010 - norrin
*****************************************************************************************************************************
Start drag.sqf
*/

private ["_unit","_dragee","_unconscious"];
_dragee	= _this select 3;
_unit  	= player;
_unconscious = 	_dragee getVariable ["NORRN_unconscious", false];

if (isNull _dragee) exitWith {}; 
if (!_unconscious) exitWith {}; 

//player assumes dragging posture
_dragee setVariable ["NORRN_unit_dragged", true, true]; 
_unit playActionNow "grabDrag";
sleep 2;

//unconscious unit assumes dragging posture
//public EH 
//["norrnRaDrag",_dragee] call broadcastRpcCallAll;
	norrnRaDrag = [_dragee];
	publicVariable "norrnRaDrag";
_dragee attachto [_unit,[0.1, 1.01, 0]];
sleep 0.02;

//rotate wounded units so that it is facing the correct direction
norrnR180 = _dragee;
publicVariable "norrnR180";
_dragee  setDir 180;
r_drag_sqf 	= true;

//Uneccesary actions removed & drop body added 
call fnc_usec_medic_removeActions;

NORRN_dropAction = player addAction ["Drop body", "dayz_code\medical\drop_body.sqf",_dragee, 0, false, true];
//NORRN_carryAction = player addAction ["Carry body", "\z\addons\dayz_code\medical\carry.sqf",_dragee, 0, false, true];
sleep 1;

drop_body.sqf

/*
 DROP BODY SCRIPT

 Allows players to drop unconscious bodies

 JULY 2010 - norrin
*****************************************************************************************************************************
Start drop_body.sqf
*/

private ["_dragee","_unit","_wallTypes"];
_dragee	= _this select 3; 
allowDropPlayer = true;

_wallTypes = nearestObjects [player, ["ModularItems","BuiltItems","Land_DZE_WoodDoor_Base","CinderWallDoor_DZ_Base","Land_DZE_WoodDoorLocked_Base","CinderWallDoorLocked_DZ_Base","Land_HBarrier1_DZ","Land_HBarrier3_DZ","Land_HBarrier5_DZ","MetalGate_DZ","Wooden_shed_DZ","WoodShack_DZ","StorageShed_DZ","MetalPanel_DZ","Fence_corrugated_DZ","Concrete_Wall_EP1","MAP_zed2_civil","Base_WarfareBBarrier10x","Land_HBarrier_large","Base_WarfareBBarrier10xTall","Land_Fort_Watchtower","Land_Fort_Watchtower_EP1","WarfareBDepot","Land_fortified_nest_big","Land_fort_rampart_EP1","Misc_cargo_cont_small_EP1","Ins_WarfareBConstructionSite","Misc_Cargo1Bo_military","Land_Misc_Cargo2B","Fence_Ind","Fence_Ind_long","Fence_corrugated_plate","Fort_RazorWire","Hhedgehog_concrete","Land_Ind_Garage01","Land_hut_old02","Land_HouseV_1I4","WoodLargeWall_DZ","WoodLargeWallDoor_DZ","WoodLargeWallWin_DZ","WoodSmallWall_DZ","WoodSmallWallWin_DZ","WoodSmallWallDoor_DZ","WoodSmallWallThird_DZ","CinderWallHalf_DZ","CinderWall_DZ","CinderWallDoorway_DZ","CinderWallSmallDoorway_DZ","CinderWallDoorSmall_DZ","CinderWallDoorSmallLocked_DZ","Land_DZE_GarageWoodDoorLocked","Land_DZE_LargeWoodDoorLocked"], 16];


if (count _wallTypes > 0) then {
		_wall = [_wallTypes, player] call BIS_fnc_nearestPosition;
		if ((vehicle player) distance _wall < 10) then {
				cutText [format[">>>Anti-Glitch script<<< (Admin notified) Cant drop a player near an epoch building."], "PLAIN DOWN"];
				titleFadeOut 2;
				diag_log format[">>>Anti-Glitch script<<< Player: %1 tried to drop Player: %2 near an epoch building", player, _dragee];
				allowDropPlayer = false;
				sleep 1;
		};
};

if (allowDropPlayer) then {
	player removeAction NORRN_dropAction;
	player removeAction NORRN_carryAction;
	NORRN_remove_drag = true;  
	r_drag_sqf = false;
	r_carry_sqf = false;
	r_action = false;
	_unit = player;
	
	detach _unit;
	detach _dragee;
	_unit switchMove "";
	_dragee switchMove "";
	NORRN_Dragged_body = objNull;
	_dragee setVariable ["NORRN_unit_dragged", false, true]; 
	
	//lie on back
	_dragee playMoveNow "ainjppnemstpsnonwrfldnon";
	norrnRalie = _dragee;
	publicVariable "norrnRalie";
};

_wallTypes is the array that holds the walls/buildings/house etc that you want to check if they are around before the player gets dropped.

I tried to add the most common used buildings like walls, barriers, garages etc... If you have any custom buildings you want to add...just add them to the array.

 

If i am missing any important building please post it here so i can update the script.

 

Enjoy.

Link to comment
Share on other sites

  • 4 months later...

Has anyone noticed that if you run at a locked door and just as you are bumping into the door, if you go prone it lets you in the base?

 

This is horrible as it works nearly all the time and let's you in and out.

 

Sandbird, could your script above be edited to cover that? 

Link to comment
Share on other sites

Also could you fix the bandage glitch to stop people quickly getting back up?

 

 

It would probably need something added to fn_unconscious.sqf to disable keys for the duration of the unconsciousness, the issue is medical stuff is deep rooted into the game and would require numerous pulls to the mission file (imo)

 

Although it may be possible to create a new file check for NORRN_unconscious on a player, then if the player is it then disables the players keys.

 

uncon.sqf

if (isNil "NORRN_unconscious") then {
            NORRN_unconscious = false;
    };
    while {true} do {
            waitUntil { NORRN_unconscious };
            titleText ["input disabled","PLAIN DOWN"]; titleFadeOut 4;
            disableUserInput true;disableUserInput true;disableUserInput true;
            waitUntil { !NORRN_unconscious };
    disableUserInput false;disableUserInput false;disableUserInput false;  
    };


The above may work if called from the init.sqf after player monitor call

[] execVM "uncon.sqf";

 

Edit: tested, doesn't work

Link to comment
Share on other sites

I think lag is causing this. server<-->client interaction. A faster server might solve this.

 

 

OK, have tried with low pop this morning, soon after restart with server FPS at 21. I am using Vert for hosting.

 

Still seems to work if you run at a locked door and hit prone just as you bump into the door. Can anyone else recreate on their servers? I think you need to be doing it at a door where the lock is facing you (facing outside). Then it works pretty much 80% of the time.

Link to comment
Share on other sites

 

try

while {true} do {
	waitUntil {(player getVariable ["NORRN_unconscious", false])};
	titleText ["input disabled","PLAIN DOWN"]; titleFadeOut 4;
	disableUserInput true;disableUserInput true;disableUserInput true;
	waitUntil {!(player getVariable ["NORRN_unconscious", false])};
	disableUserInput false;disableUserInput false;disableUserInput false;   
};

 

Nice! Works, thank you :D

Link to comment
Share on other sites

 

try

while {true} do {
	waitUntil {(player getVariable ["NORRN_unconscious", false])};
	titleText ["input disabled","PLAIN DOWN"]; titleFadeOut 4;
	disableUserInput true;disableUserInput true;disableUserInput true;
	waitUntil {!(player getVariable ["NORRN_unconscious", false])};
	disableUserInput false;disableUserInput false;disableUserInput false;   
};

 

Thanks but what about being tazed? i'm sure that would be simple enough 

if (isnill "isTazed") then (
        isTazed = false;

while {true} do {
	waitUntil {(player getVariable ["isTazed", false])};
	titleText ["input disabled","PLAIN DOWN"]; titleFadeOut 4;
	disableUserInput true;disableUserInput true;disableUserInput true;
	waitUntil {!(player getVariable ["isTazed", false])};
	disableUserInput false;disableUserInput false;disableUserInput false;   
};

Tell me how wrong i am please :D

Link to comment
Share on other sites

It appears infistars script either 1) only works once or 2) is affected by lag.. I continued on with my own fix and coupled with infistars, it seems to work with the testing I did being knocked out by zombies and being overburdened.

 

 

I hope this helps, I also hope someone can make the fn_unconcious.sqf bulletproof as it would negate all my changes in that thread above.

Link to comment
Share on other sites

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

I love this fix, thank you Sandbird. I was wondering if there is a way to implement this into the handcuff script so players can't release a captive in someone's base? Here is the handcuff script, the working version is on page 16 or something. http://opendayz.net/threads/dayz-1-8-0-3-handcuff-player-help.15324/page-8#post-96967

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