Jump to content
Repentz

[Tutorial] Seatbelts

Recommended Posts

SEATBELTS

handledamage: by Snipes mad

dialog, eventHandlers, addaction, etc: by Repentz

 

 

This script allows you to put on/take off your seatbelt when inside a vehicle, I have also fixed the problem of the seatbelt not disabling when exiting your vehicle

Currently, the seatbelt reduces crash damage by 50%, I would put in an ejection function, but arma 3 desync leads to the script thinking you have crashed and ejecting you.

 

Let's begin

 

Go into core/Configuration.sqf, place this in the variables:

life_seatbelt = false;

Next, let's go into core/setupActions.sqf, place this at the very bottom to enable for all sides:

life_actions pushBack (player addAction["<t color = '#D660D6'>Put on Seatbelt</t>",life_fnc_seatbelt,"",7,false,false,"",' !life_seatbelt && vehicle player != player ']);
life_actions pushBack (player addAction["<t color = '#D660D6'>Remove Seatbelt</t>",life_fnc_seatbelt,"",7,false,false,"",' life_seatbelt && vehicle player != player ']);

Go into core/functions/handleDamage.sqf, place this near the bottom before hudUpdate

if ((vehicle _unit) isKindOf "Car" && (isNull _source || _source isEqualTo _unit)) then
{
	_damage = if (life_seatbelt) then { _damage / 2 } else { _damage};
};

Create a file in core/functions called fn_seatBelt.sqf:

/*
//--By Repentz for altisLifeRPG
*/

#include "..\..\script_macros.hpp"
/*
	fn_seatBelt.sqf
*/
//playSound "seatbelt"; //--Enable this to play a sound when you put your seatbelt on
if(!life_seatbelt) then {
	life_seatbelt = true;
} else {
	life_seatbelt = false;
};

//[] call life_fnc_hudUpdate; //--Enable this if you are putting a hud option to display when your seatbelt is on.

Go into functions.hpp in main directory, find functions section, add this:

class seatbelt {};

Go into initPlayerLocal in your main directory, add this after "if (LIFE_SETTINGS(getNumber,"spyGlass_toggle") isEqualTo 1) then {[] execVM "SpyGlass\fn_initSpy.sqf";};"

if (hasInterface) then {
    player addEventHandler ["GetOutMan", {
        life_seatbelt = false;
        //[] call life_fnc_hudUpdate; //--Enable if you are putting a hud option to display when your seatbelt is on
    }];
};

if (hasInterface) then {
    player addEventHandler ["GetInMan", {
        life_seatbelt = false;
        //[] call life_fnc_hudUpdate; //--Enable if you are putting a hud option to display when your seatbelt is on
    }];
};

Optional: If you want to have a icon display when you're inside your vehicle, and your seatbelt is on or off, put this in your hud_stats.hpp:

#define IDC_LIFE_BAR_SeatBelt 4203

then

LIFE_BAR_SeatBelt

then

class LIFE_BAR_SeatBelt: Life_RscPicture
{
    idc = IDC_LIFE_BAR_SeatBelt;
    text = "";
    x = 0.952292 * safezoneW + safezoneX;
    y = 0.664333 * safezoneH + safezoneY;
    w = 0.0331042 * safezoneW;
    h = 0.0589743 * safezoneH;
};

This is still for optional icon display, go into hudUpdate:

#define IDC_LIFE_BAR_SeatBelt 4203

then

if(!isNil "life_seatbelt") then {
    if ( vehicle player != player ) then {
        if(life_seatbelt) then {
            LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "rg_client\HUD\seatbeltOn.paa";
        } else {
            LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "rg_client\HUD\seatbeltOff.paa";
        };
    } else {
        LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "";
    };
};

You will have to find your own icons, sounds, and position the icon wherever you wish if you want these features, also remember for the seatbelt sound to call it in description.ext as a new sound.

 

Done.

Edited by Repentz
  • Like 6
  • Sad 1

Share this post


Link to post
Share on other sites

Hello ! (sorry for my english) I have succesfully installed your script, it's work. I have the sound but i don't have the picture... I don't understand the part of the picture... i don't have error in my RPT... Can you help me please? Thanks a lot ! (I have the 4.4 R3 )

Edited by ArashTaFace

Share this post


Link to post
Share on other sites

Create your own picture and I change a part in the coding to put the pictures in the icon folder.

in your file hudupdate.sqf do this to direct to the icons folder

if(!isNil "life_seatbelt") then {
    if ( vehicle player != player ) then {
        if(life_seatbelt) then {
            LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "icons\seatbeltOn.paa";
        } else {
            LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "icons\seatbeltOff.paa";
        };
    } else {
        LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "";
    };
};

  • Like 1

Share this post


Link to post
Share on other sites
47 minutes ago, Iceman said:

Create your own picture and I change a part in the coding to put the pictures in the icon folder.

in your file hudupdate.sqf do this to direct to the icons folder

if(!isNil "life_seatbelt") then {
    if ( vehicle player != player ) then {
        if(life_seatbelt) then {
            LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "icons\seatbeltOn.paa";
        } else {
            LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "icons\seatbeltOff.paa";
        };
    } else {
        LIFEctrl(IDC_LIFE_BAR_SeatBelt) ctrlSetText "";
    };
};

thats was what id did , i will try it again

Share this post


Link to post
Share on other sites

i think the main thing is where exactly does this go

class LIFE_BAR_SeatBelt: Life_RscPicture
{
    idc = IDC_LIFE_BAR_SeatBelt;
    text = "";
    x = 0.952292 * safezoneW + safezoneX;
    y = 0.664333 * safezoneH + safezoneY;
    w = 0.0331042 * safezoneW;
    h = 0.0589743 * safezoneH;
};

i tried in a few different spots in hudUpdate. it does show up but is almost invisible

Share this post


Link to post
Share on other sites
7 minutes ago, reaperz73 said:

i think the main thing is where exactly does this go

class LIFE_BAR_SeatBelt: Life_RscPicture
{
    idc = IDC_LIFE_BAR_SeatBelt;
    text = "";
    x = 0.952292 * safezoneW + safezoneX;
    y = 0.664333 * safezoneH + safezoneY;
    w = 0.0331042 * safezoneW;
    h = 0.0589743 * safezoneH;
};

i tried in a few different spots in hudUpdate. it does show up but is almost invisible

that goes in the hud_stats.hpp under this

class Life_RscText_HUDWater: Life_RscText_HUDCommon {
        idc = 1202;
        text = "$STR_HUD_Water";
        x = 0.534723 * safezoneW + safezoneX;
    };
   

  • Like 2

Share this post


Link to post
Share on other sites

You should consider that your audience may be total nub, consider going into more indepth explanations. where exactly they should be placing lines /show examples of what it should look like, just saying then and then and then etc.. does not explain exactly where things go for example the # easily overlookable if they are a complete nub. would be good to explain stuff like such. Also, if they only need top 1/2 of what is up there to get it to work and everything else is (Optional) maybe make more discernable from the (Optional) 1/2. Myself, was able to put this in with no errors... except  there was no option in scroll wheel to put seatbelt on or off.

  • Like 1

Share this post


Link to post
Share on other sites
49 minutes ago, Mastermind said:

You should consider that your audience may be total nub, consider going into more indepth explanations. where exactly they should be placing lines /show examples of what it should look like, just saying then and then and then etc.. does not explain exactly where things go for example the # easily overlookable if they are a complete nub. would be good to explain stuff like such. Also, if they only need top 1/2 of what is up there to get it to work and everything else is (Optional) maybe make more discernable from the (Optional) 1/2. Myself, was able to put this in with no errors... except  there was no option in scroll wheel to put seatbelt on or off.

I agree to a point. but how are people to learn this instead of just copy and paste.

  • Like 1

Share this post


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

@Repentz

The creator of this script is Snipes mad for Aiekillu Altis life server.

 

Please give the credit.

What part of this script did he create? I did all of the dialog, eventhandler, etc. Possibly the handleDamage?

Credit given anyways

Edited by Repentz
  • Like 1

Share this post


Link to post
Share on other sites

I put this in for 2nd time and it works just like it says. Though I did not do the part where it says how to add icon and stuff, I can do that later. Point is its, in there and works. I am going to turn that dmg reduction down abit more to where a crash is just survivable at like 25%-15% life left. Thanks for posting this, anychance you can tell us how to add the ejection part it, for those of us who would still like to have that implemented plz?

Share this post


Link to post
Share on other sites
On 2016-10-07 at 4:07 PM, Mastermind said:

I put this in for 2nd time and it works just like it says. Though I did not do the part where it says how to add icon and stuff, I can do that later. Point is its, in there and works. I am going to turn that dmg reduction down abit more to where a crash is just survivable at like 25%-15% life left. Thanks for posting this, anychance you can tell us how to add the ejection part it, for those of us who would still like to have that implemented plz?

Ejection part of it sometimes triggers during desync so have fun having people flying out of helis for and cars at random times.

Share this post


Link to post
Share on other sites
On 23/10/2016 at 3:04 PM, Cristik said:

Is it possible to move the seatbelt option below the get out/eject options?

Yes it is,

 

in your fn_setupActions.sqf

life_actions pushBack (player addAction["<t color = '#D660D6'>S'attacher</t>",life_fnc_seatbelt,"",7,false,false,"",' !life_seatbelt && vehicle player != player ']);
life_actions pushBack (player addAction["<t color = '#D660D6'>Se détacher</t>",life_fnc_seatbelt,"",7,false,false,"",' life_seatbelt && vehicle player != player ']);

 

change the number "7" by what you want

 

 

btw thanks for this script

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...