MGTDB

Disable vehicles ramming players in safezones

10 posts in this topic

This is for vehicles vs players, currently, since Arma 3 0.54 collision between vehicles cannot be disabled

First, if you don't already, create a folder called custom in your mission file

Grab 3 files from the Exile client files
ExileClient_object_player_event_onEnterSafezone.sqf, ExileClient_object_player_thread_safeZone.sqf and ExileClient_object_player_event_onLeaveSafezone.sqf


Change ExileClient_object_player_event_onEnterSafezone.sqf to the code below and place it in the custom folder

Spoiler

/**
 * ExileClient_object_player_event_onEnterSafezone
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_vehicle", "_attachedObjects", "_position"];
if (ExilePlayerInSafezone) exitWith { false };
if !(alive player) exitWith { false };
ExilePlayerInSafezone = true;
ExileClientVehiclesCollision = [];
{
    ExileClientVehiclesCollision pushBackUnique _x;
    player disableCollisionWith _x;
} forEach nearestObjects [player, ["LandVehicle","Tank","Air","Ship"], 50];
player allowDamage false;
player removeAllEventHandlers "HandleDamage";
_vehicle = vehicle player;
if !(_vehicle isEqualTo player) then 
{
	if (local _vehicle) then 
	{
		_vehicle allowDamage false;
	};
	_attachedObjects = attachedObjects _vehicle;
	if !(_attachedObjects isEqualTo []) then 
	{
		_position = getPosATL _vehicle;
		{
			if ((typeOf _x) in ["DemoCharge_Remote_Mag", "SatchelCharge_Remote_Mag"]) then 
			{
				detach _x;
				_x setPosATL [(_position select 0) + random 2, (_position select 1) + random 2, 0.05];
				_x setDir (random 360);
			};
		}
		forEach _attachedObjects;
	};
	ExileClientSafeZoneVehicle = _vehicle;
	ExileClientSafeZoneVehicleFiredEventHandler = _vehicle addEventHandler ["Fired", {_this call ExileClient_object_player_event_onFiredSafeZoneVehicle}];
};
ExileClientSafeZoneESPEventHandler = addMissionEventHandler ["Draw3D", {20 call ExileClient_gui_safezone_safeESP}];
["Welcome! God mode enabled."] spawn ExileClient_gui_baguette_show;
ExileClientSafeZoneUpdateThreadHandle = [1, ExileClient_object_player_thread_safeZone, [], true] call ExileClient_system_thread_addtask;
true

 

Change ExileClient_object_player_thread_safeZone.sqf to the code below and place it in the custom folder

Spoiler

/**
 * ExileClient_object_player_thread_safeZone
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_vehicle"];
_vehicle = vehicle player;
if (!ExilePlayerInSafezone) exitWith {false};
{
ExileClientVehiclesCollision pushBackUnique _x;
player disableCollisionWith _x;
} forEach nearestObjects [player, ["LandVehicle","Tank","Air","Ship"], 50];
if (_vehicle isEqualTo player) then 
{
	if !(isNull ExileClientSafeZoneVehicle) then
	{
		ExileClientSafeZoneVehicle removeEventHandler ["Fired", ExileClientSafeZoneVehicleFiredEventHandler];	
		ExileClientSafeZoneVehicle = objNull;
		ExileClientSafeZoneVehicleFiredEventHandler = nil;
	};
}
else 
{
	if (local _vehicle) then 
	{
		_vehicle allowDamage false;
	};
	if !(_vehicle isEqualTo ExileClientSafeZoneVehicle) then 
	{
		if !(isNull ExileClientSafeZoneVehicle) then 
		{
			ExileClientSafeZoneVehicle removeEventHandler ["Fired", ExileClientSafeZoneVehicleFiredEventHandler];	
			ExileClientSafeZoneVehicle = objNull;
			ExileClientSafeZoneVehicleFiredEventHandler = nil;
		};
		ExileClientSafeZoneVehicle = _vehicle;
		ExileClientSafeZoneVehicleFiredEventHandler = _vehicle addEventHandler ["Fired", {_this call ExileClient_object_player_event_onFiredSafeZoneVehicle}];
	};
};
true

 

and ExileClient_object_player_event_onLeaveSafezone.sqf to the code below and place it in the custom folder

Spoiler

/**
 * ExileClient_object_player_event_onLeaveSafezone
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 */
 
private["_vehicle"];
if !(ExilePlayerInSafezone) exitWith { false };
ExilePlayerInSafezone = false;
{
	if !(isNull _x) then
	{
		player enableCollisionWith _x;
	};
} forEach ExileClientVehiclesCollision;
ExileClientVehiclesCollision = [];
if !(isNil "ExileClientSafeZoneUpdateThreadHandle") then 
{
	[ExileClientSafeZoneUpdateThreadHandle] call ExileClient_system_thread_removeTask;
	ExileClientSafeZoneUpdateThreadHandle = nil;
};
player allowDamage true;
player addEventHandler ["HandleDamage", {_this call ExileClient_object_player_event_onHandleDamage}];
if !(isNull ExileClientSafeZoneVehicle) then
{
	if (local ExileClientSafeZoneVehicle) then 
	{
		ExileClientSafeZoneVehicle allowDamage true;
	};
	ExileClientSafeZoneVehicle removeEventHandler ["Fired", ExileClientSafeZoneVehicleFiredEventHandler];	
	ExileClientSafeZoneVehicle = objNull;
	ExileClientSafeZoneVehicleFiredEventHandler = nil;
};
_vehicle = vehicle player; 
if !(_vehicle isEqualTo player) then 
{
	if (local _vehicle) then 
	{
		_vehicle allowDamage true;
	};
};
if !(isNil "ExileClientSafeZoneESPEventHandler") then 
{
	removeMissionEventHandler ["Draw3D", ExileClientSafeZoneESPEventHandler];
	ExileClientSafeZoneESPEventHandler = nil;
};
if (alive player) then 
{
	["Goodbye! God mode disabled."] spawn ExileClient_gui_baguette_show;
};
true

 

Then in config.cpp, find class CfgExileCustomCode and add the following to the array

class CfgExileCustomCode
{
	ExileClient_object_player_event_onEnterSafezone = "custom\ExileClient_object_player_event_onEnterSafezone.sqf";
	ExileClient_object_player_thread_safeZone = "custom\ExileClient_object_player_thread_safeZone.sqf";
	ExileClient_object_player_event_onLeaveSafezone = "custom\ExileClient_object_player_event_onLeaveSafezone.sqf";
};

Then pack your mission file and you're good to go!

Edited: Made it even more performant
Edited: Updated with Stokes code

Edited by MGTDB
  • Like 11

Share this post


Link to post
Share on other sites

Seen this in effect. Idea is good. But now I can't stop multiple players running up to my vehicle and draining all my fuel along with looting my mission vehicle. Before I could ram the player with the vehicle giving me a few seconds to actually sell everything I gained. 

  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

As opposed to you repeatedly ramming the players until they are forced out of the trade zone, so you can kill and loot them?

  • Like 2

Share this post


Link to post
Share on other sites
16 hours ago, Wooki said:

As opposed to you repeatedly ramming the players until they are forced out of the trade zone, so you can kill and loot them?

Why do you think I rammed them B|

Share this post


Link to post
Share on other sites
17 hours ago, dima054 said:

Umm so which solution is better? From MGTDB or from StokesMagee?

Updated OP to use Stokes code

  • Like 2

Share this post


Link to post
Share on other sites
Advertisement

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

  • Recently Browsing   0 members

    No registered users viewing this page.