Jump to content
KillerAussie

[TUTORIAL] Better SAFEZONES

Recommended Posts

I have been looking around and have noticed that a lot of people are using the method of defining the safezone using macros with the marker and distance in an array. I am happy to say that I have a much easier and better way to do this. It will involve editing 4 different files.

You need to add markers onto your map with variable names set to them. You should use "Ellipse" or "Rectangle" markers.

Files to be edited:

  1. "Altis_Life.Altis\core\configuration.sqf"
  2. "Altis_Life.Altis\core\fn_setupEVH.sqf"
  3. "Altis_Life.Altis\core\functions\fn_handleDamage.sqf"
  4. "Altis_Life.Altis\core\functions\fn_onFired.sqf"

Step 1:

Firstly we have to create the global variable where our safe zones will be stored. To do this all you have to do is go to the "configuration.sqf" file. It should look like the following code:

Spoiler
#include "..\script_macros.hpp"
/*
    File: configuration.sqf
    Author:

    Description:
    Master Life Configuration File
    This file is to setup variables for the client, there are still other configuration files in the system

*****************************
****** Backend Variables *****
*****************************
*/
life_query_time = time;
life_action_delay = time;
life_trunk_vehicle = objNull;
life_session_completed = false;
life_garage_store = false;
life_session_tries = 0;
life_net_dropped = false;
life_siren_active = false;
life_clothing_filter = 0;
life_clothing_uniform = -1;
life_redgull_effect = time;
life_is_processing = false;
life_bail_paid = false;
life_impound_inuse = false;
life_action_inUse = false;
life_spikestrip = objNull;
life_knockout = false;
life_interrupted = false;
life_respawned = false;
life_removeWanted = false;
life_action_gathering = false;
tawvd_addon_disable = true;
life_god = false;
life_frozen = false;
life_save_gear = [];
life_container_activeObj = objNull;
life_disable_getIn = false;
life_disable_getOut = false;
life_admin_debug = false;
life_preview_3D_vehicle_cam = objNull;
life_preview_3D_vehicle_object = objNull;
life_preview_light = objNull;
life_pos_exist = false;
life_pos_attach = [];
life_civ_position = [];
life_markers = false;
life_markers_active = false;
life_canpay_bail = true;
life_storagePlacing = scriptNull;

//Settings
life_settings_enableNewsBroadcast = profileNamespace getVariable ["life_enableNewsBroadcast",true];
life_settings_enableSidechannel = profileNamespace getVariable ["life_enableSidechannel",true];
life_settings_tagson = profileNamespace getVariable ["life_settings_tagson",true];
life_settings_revealObjects = profileNamespace getVariable ["life_settings_revealObjects",true];
life_settings_viewDistanceFoot = profileNamespace getVariable ["life_viewDistanceFoot",1250];
life_settings_viewDistanceCar = profileNamespace getVariable ["life_viewDistanceCar",1250];
life_settings_viewDistanceAir = profileNamespace getVariable ["life_viewDistanceAir",1250];

//Uniform price (0),Hat Price (1),Glasses Price (2),Vest Price (3),Backpack Price (4)
life_clothing_purchase = [-1,-1,-1,-1,-1];
/*
*****************************
****** Weight Variables *****
*****************************
*/
life_maxWeight = LIFE_SETTINGS(getNumber,"total_maxWeight");
life_carryWeight = 0; //Represents the players current inventory weight (MUST START AT 0).

/*
*****************************
****** Life Variables *******
*****************************
*/
life_net_dropped = false;
life_use_atm = true;
life_is_arrested = false;
life_is_alive = false;
life_delivery_in_progress = false;
life_thirst = 100;
life_hunger = 100;
CASH = 0;

life_istazed = false;
life_isknocked = false;
life_vehicles = [];

/*
    Master Array of items?
*/
//Setup variable inv vars.
{
    missionNamespace setVariable [ITEM_VARNAME(configName _x),0];
} forEach ("true" configClasses (missionConfigFile >> "VirtualItems"));

/* Setup the BLAH! */
{
    _varName = getText(_x >> "variable");
    _sideFlag = getText(_x >> "side");

    missionNamespace setVariable [LICENSE_VARNAME(_varName,_sideFlag),false];
} forEach ("true" configClasses (missionConfigFile >> "Licenses"));

 

At the very bottom of this file paste the following code:

life_safezones = ["marker1","marker2","marker3"]; // Replace "marker#" with your safezone marker names(variable names in editor). Can have infinite number of zones, make sure you serperate each zone with a comma(,) and enclose with quotation marks("") like I have shown with the examples.

Once you have added that code and edited it you can save and exit that file.

Step 2:

This step is something that I recommend you do but it is not necessary. This allows bullets from vehicles and firearms to be deleted(Currently only bullets from firearms can be deleted). All you have to do is go into your "fn_setupEVH.sqf" and change the following code:

player addEventHandler ["Fired", {_this call life_fnc_onFired}];

Change it to:

player addEventHandler ["FiredMan", {_this call life_fnc_onFired}];

Nice! We are half way done. Lets move on shall we.

Step 3:

What you have to do now is find your "fn_handleDamage.sqf" file. Once you have found it, it should look something like this:

Spoiler
#include "..\..\script_macros.hpp"
/*
    File: fn_handleDamage.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    Handles damage, specifically for handling the 'tazer' pistol and nothing else.
*/
params [
    ["_unit",objNull,[objNull]],
    ["_part","",[""]],
    ["_damage",0,[0]],
    ["_source",objNull,[objNull]],
    ["_projectile","",[""]],
    ["_index",0,[0]]
];

private _originalDamage = if (_part == "") then {damage _unit}else{_unit getHit _part};
//Handle the tazer first (Top-Priority).
if (!isNull _source) then {
    if (_source != _unit) then {
        if (currentWeapon _source in ["hgun_P07_snds_F","arifle_SDAR_F"] && _projectile in ["B_9x21_Ball","B_556x45_dual"]) then {
            if (side _source isEqualTo west && playerSide isEqualTo civilian) then {
                _damage = _originalDamage;
                if (alive player && !life_istazed && !life_isknocked && !(_unit getVariable ["restrained",false])) then {
                    private ["_distance"];
                    _distance = 35;
                    if (_projectile == "B_556x45_dual") then {_distance = 100;};
                    if (_unit distance _source < _distance) then {
                        if !(isNull objectParent player) then {
                            if (typeOf (vehicle player) == "B_Quadbike_01_F") then {
                                player action ["Eject",vehicle player];
                                [_unit,_source] spawn life_fnc_tazed;
                            };
                        } else {
                            [_unit,_source] spawn life_fnc_tazed;
                        };
                    };
                };
            };

            //Temp fix for super tasers on cops.
            if (side _source isEqualTo west && (playerSide isEqualTo west || playerSide isEqualTo independent)) then {
                _damage = _originalDamage;
            };
        };
    };
};

[] spawn life_fnc_hudUpdate;
_damage;

 

This file has been edited with my Tazer Healing Exploit [FIX], You can find how to do that here: https://www.altisliferpg.com/topic/4787-tazer-healing-exploit-fix/

Once you have found that file, just above this line of code:

[] spawn life_fnc_hudUpdate;

Paste one of the following codes:

Spoiler

If you have my Tazer Healing Exploit[FIX] then use this code:

{
	if (player inArea _x) then {
		_damage = _originalDamage;
	};
}forEach life_safezones;

If you don't have the Tazer Healing Exploit[FIX] then use this code:

{
	if (player inArea _x) then {
		_damage = 0;
	};
}forEach life_safezones;

 

Once you have done that, you have finished with that file. Save and exit.

Step 4(Final):

For our final step we are going to add the bullet delete/ anti-fire for the safezones. To do this, find your "fn_onFired.sqf". It should look something like this:

Spoiler
#include "..\..\script_macros.hpp"
/*
    File: fn_onFired.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    Handles various different ammo types being fired.
*/
private ["_ammoType","_projectile"];
_ammoType = _this select 4;
_projectile = _this select 6;

if (_ammoType isEqualTo "GrenadeHand_stone") then {
    _projectile spawn {
        private "_position";
        while {!isNull _this} do {
            _position = ASLtoATL (visiblePositionASL _this);
            sleep 0.1;
        };
        [_position] remoteExec ["life_fnc_flashbang",RCLIENT];
    };
};

 

At the very bottom of this file, add the following code:

{
	if (player inArea _x) then {
		deleteVehicle _projectile;
		["Stop firing in the safezone!","Stop Firing!"] spawn BIS_fnc_guiMessage;
	};
}forEach life_safezones;

And that is all that you need to do. Make sure you save everything.

If you have any issues please don't be afraid to ask for help.

Have fun!

Edited by KillerAussie
Added semi-colon for safety

Share this post


Link to post
Share on other sites

Aw yeah, nice.

Correct me if I'm wrong, but I'm pretty sure that this is wrong.

1 hour ago, KillerAussie said:

life_safezones = ["marker1","marker2","marker3"]

Where's the colon? 

Edited by Delexical
  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Delexical said:

Aw yeah, nice.

Correct me if I'm wrong, but I'm pretty sure that this is wrong.

Where's the colon? 

Doesn't really need one because its at the bottom of the script but if anything else is put after this you should definetley have a semi-colon. I'll add one in just to be safe, thanks brother :)

 

*Edit*

Post updated with "safety" semi-colon.

Edited by KillerAussie

Share this post


Link to post
Share on other sites

Semicolons are only needed at E.O.L which is (the end of the line) to essentially close the line of like a full stop in a sentence.

In C# and C++ where sqf originates from you don't need to put semicolons for things like ifs and else it won't alter the code but it won't add anything to it either.

  • Like 1

Share this post


Link to post
Share on other sites
12 minutes ago, XaFlaForo said:

Semicolons are only needed at E.O.L which is (the end of the line) to essentially close the line of like a full stop in a sentence.

eeeh!

Share this post


Link to post
Share on other sites

Hey Killer Aussie, created a profile here very specially to thank you for sharing this! Loved the style of your guide and the safezones are working great for me! I've just tested over a Lan connection with only myself in the server though so I'll have to keep my fingers crossed till the server is actually up for real.

 

Having said that, I do however see a potential exploit in which people could fire into the safezones from outside. I've just run a test and it seems that while bullets fired from inside the safezone are indeed deleted, it doesnt do the same for projectiles fired from outside the safezone inwards. Any suggestions or possibilities of ways to fix that?

 

Cheers!

Share this post


Link to post
Share on other sites
On 11/25/2018 at 8:26 AM, Puma Power.PT said:

im talking about (You enter now in safe zone , you are leaving safe zone

You can just make a trigger in the editor and add it yourself. 

Ripped from Radiation Area by Fuel as I can't access the editor right now.

Trigger: Activation

  • Type: None
  • Activation: Anybody
  • Activation Type: Present
  • Repeatable: Yes
  • Server Only: No

Trigger: Expression

Condition: 

this && (local player) && (vehicle player in thisList)

On Activation:

hint parseText format ["<t color='#0eb0ff'>You have entered a safezone!</t>"];

On Deactivation:

hint parseText format ["<t color='#0eb0ff'>You are leaving a safezone!</t>"];

Obviously, you can do the same for KOS Areas / Gang Hideouts.

 

Share this post


Link to post
Share on other sites

Is it possible to add dialogue to the screen instead of the message? If Yes, please tell me.

{
	if (player inArea _x) then {
		deleteVehicle _projectile;
		["Stop firing in the safezone!","Stop Firing!"] spawn BIS_fnc_guiMessage;
	};
}forEach life_safezones;

In General, a great job! Thanks

 

Edited by tamirlan_sky

Share this post


Link to post
Share on other sites
13 hours ago, tamirlan_sky said:

Is it possible to add dialogue to the screen instead of the message? If Yes, please tell me.

Just replace ["Stop firing in the safezone!","Stop Firing!"] spawn BIS_fnc_guiMessage; with one of these:

systemChat "Stop firing in the safezone!"; // Message in the chat.
hint "Stop firing in the safezone!"; // Mesasge in a hint box on screen.
titleText["Stop firing in the safezone!","PLAIN"]; // Message in the center of the screen.

 

  • Like 2

Share this post


Link to post
Share on other sites
8 hours ago, tamirlan_sky said:

Thanks for the information! I mean another. I want this to come out in the middle of the screen... I created a dialogue and I want it to go out when the shot is fired.

If you've already made the dialog, just use createDialog or createDisplay to show it.

Edited by imthatguyhere
  • Like 1

Share this post


Link to post
Share on other sites
59 minutes ago, tamirlan_sky said:

createDialog not work(

What did you try to do with createDialog? If you made your dialog properly, it absolutely will work.

Edited by imthatguyhere
  • Like 1

Share this post


Link to post
Share on other sites

createDisplay not try

class nestrelai  { //["0.338097 * safezoneW + safezoneX","0.203 * safezoneH + safezoneY","0.314524 * safezoneW","0.594 * safezoneH"]
idd = 2535;
name= "";
movingEnable = false;
enableSimulation = true;
onLoad = "";
onUnLoad = "";
    class controlsBackground {

        class background: Life_RscPicture
		{
			idc = 1200;
			text = "Rodos_mod\tamlet\pages\background_nestrelai.paa";
			x = 0.338097 * safezoneW + safezoneX;
			y = 0.203 * safezoneH + safezoneY;
			w = 0.314524 * safezoneW;
			h = 0.594 * safezoneH;
		};
    };

    class controls {
		
	    class ButtonClose: Life_RscButtonMenu {
            idc = -1;
            text = "";
            onButtonClick = "closeDialog 0;";
            x = 0.485562 * safezoneW + safezoneX;
            y = 0.742 * safezoneH + safezoneY;
            w = 0.0206253 * safezoneW;
            h = 0.0264 * safezoneH;
			colorBackground[] = {0,0,0,0};
			colorBackgroundFocused[] = {0,0,0,0};
			colorBackground2[] = {0,0,0,0};
			color[] = {1,1,1,1};
			colorFocused[] = {0,0,0,0};
			color2[] = {0,0,0,0};
			colorText[] = {1,1,1,1};
        };
		
	};
};

 

 

Here is so plugged his "MasterHandler.hpp"

 

/*
    Master UI Resource File
*/
#include "common.hpp"
#include "shop_items.hpp"
#include "player_inv.hpp"
#include "gang.hpp"
#include "key_chain.hpp"
#include "impound.hpp"
#include "bank.hpp"
#include "veh_shop.hpp"
#include "shops.hpp"
#include "hud_stats.hpp"
#include "admin_menu.hpp"
#include "cell_phone.hpp"
#include "wanted_list.hpp"
#include "ticket.hpp"
#include "clothing.hpp"
#include "trunk.hpp"
#include "spawnSelection.hpp"
#include "chop_shop.hpp"
#include "pInteraction.hpp"
#include "deathScreen.hpp"
#include "vehicleShop.hpp"
#include "vehicleShop3D.hpp"
#include "settings.hpp"
#include "federalReserve.hpp"
#include "compensate.hpp"
#include "FuelStat.hpp"
#include "newsStation.hpp"
#include "common_EditorWrapper.hpp"
#include "market.hpp"
#include "AH_buy.hpp"
#include "AH_vsell.hpp"
#include "Toxic_Bus_Menu.hpp"
#include "nestrelai.hpp"

The last in the list 

 

{
    if (player inArea _x) then {
        deleteVehicle _projectile;
       createDialog ""nestrelai"";
    };
}forEach life_safezones;

Is that right?

Share this post


Link to post
Share on other sites
5 minutes ago, tamirlan_sky said:

Coordinates are correct... you can be sure

Pastebin a client RPT from when you tried it.

Edited by imthatguyhere
  • Like 1

Share this post


Link to post
Share on other sites

not look... I thought that (createDialog ""nestrelai"";) doesn't work there. apparently was wrong... Now busy with hard work... I'll try to figure it out later... Thank you very much for your help... 

Share this post


Link to post
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

×