[Tutorial] Anti-Glitch script. Block unconscious players from being dragged into bases [Epoch]

Sandbird

Valued Member!
There is this really annoying bug on Epoch, 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
smile.png

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


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:
Code:
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:
Code:
_action1 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];
to this
Code:
_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
PHP:
/*
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
PHP:
/*
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.
 
Back
Top