Jump to content

[Tutorial] Bandages


ToxicRageTv
 Share

Recommended Posts

Bandages

ToxicRageTv

Description

This is a simple bandages script that allows players to buy and use bandages to heal themselves. You can either use the bandages by going to your virtual inventory, selecting a bandage and pressing use, or you can use the hotkey of SHIFT + 0 (zero). This includes a config file so that it can be tweaked to you liking. You can change things like bandaging time, the amount of health received from using a bandage and more.

 

1. Open "Altis_Life.Altis\config\Config_vItems.hpp" and ADD

class bandage {
	variable = "bandage";
	displayName = "STR_Item_Bandage";
	weight = 1;
	buyPrice = 750;
	sellPrice = 350;
	illegal = false;
	edible = -1;
	drinkable = -1;
	icon = "icons\ico_bandages.paa";
};

* After adding it to the config you will need to add it to a shop

 

2. Open "Altis_Life.Altis\Functions.hpp" and ADD the following under class Items (around line 260)

class bandage {};

 

3. Open "Altis_Life.Altis\config\Config_Master.hpp" and at the VERY BOTTOM ADD

#include "Toxic_Config_Bandage.hpp"

 

4. Open "Altis_Life.Altis\core\pmenu\fn_useItem.sqf" and ADD

case "bandage": {
	[] spawn life_fnc_bandage;
	closeDialog 0;
};

 

5. Open "Altis_Life.Altis\core\functions\fn_keyHandler.sqf" and ADD

//Shift 0 (zero)
case 11: {
	if (_shift) then {
		[] spawn life_fnc_bandage;        
	};
};

 

6. Open "Altis_Life.Altis\stringtable.xml" and ADD the follow under the package "Life_Items"

<Key ID="STR_Item_Bandage">
	<Original>Bandage</Original>
</Key>

 

7. Go to "Altis_Life.Altis\core\items" and CREATE a FILE called "fn_bandage.sqf"

Spoiler
#include "..\..\script_macros.hpp"
/*

	File: fn_bandage.sqf
	Author: ToxicRageTv
	Credits: Original creator of the progress bar

	This script was created for the Altis Life RPG community.

*/
if (!alive player) exitWith {"Bandages can't help you now..."};
if (life_inv_bandage < 1) exitWith {hint "You don't have any bandages!"};
if (life_action_inUse) exitWith {hint "You're already doing something!"};
if !(isNull objectParent player) exitWith {hint "You must be on foot in order bandage!"};

life_interrupted = false;
_configSide = switch (side player) do {
	case civilian: {"Civilian"};
	case west: {"Cop"};
	case independent: {"Medic"};
	default {"Civilian"};
};

_bandageMode = getNumber(missionConfigFile >> "Toxic_Config_Bandage" >> _configSide >> "bandageSetHealth");
_maxHealth = getNumber(missionConfigFile >> "Toxic_Config_Bandage" >> _configSide >> "bandageMaxHealth");

if (damage player <= _maxHealth) exitWith {hint "A bandage cannot heal you any higher"};

_bandageTime = getNumber(missionConfigFile >> "Toxic_Config_Bandage" >> _configSide >> "bandageTime");
_sleepTime = _bandageTime / 100;

life_action_inUse = true;

//Setup our progress bar.
disableSerialization;
"progressBar" cutRsc ["life_progress","PLAIN"];
_ui = uiNamespace getVariable "life_progress";
_progress = _ui displayCtrl 38201;
_pgText = _ui displayCtrl 38202;
_pgText ctrlSetText format ["Applying bandage (0%1)...","%"];
_progress progressSetPosition 0.01;
_cP = 0.01;

for "_i" from 0 to 1 step 0 do {
	if (animationState player != "AinvPknlMstpSnonWnonDnon_medic_1") then {
		[player,"AinvPknlMstpSnonWnonDnon_medic_1",true] remoteExecCall ["life_fnc_animSync",RCLIENT];
		player switchMove "AinvPknlMstpSnonWnonDnon_medic_1";
		player playMoveNow "AinvPknlMstpSnonWnonDnon_medic_1";
	};

	uiSleep _sleepTime;
	_cP = _cP + 0.01;
	_progress progressSetPosition _cP;
	_pgText ctrlSetText format ["Applying bandage (%1%2)...",round(_cP * 100),"%"];
	if (_cP >= 1) exitWith {};
	if (!alive player) exitWith {};
	if !(isNull objectParent player) exitWith {};
	if (life_interrupted) exitWith {};
};

life_action_inUse = false;
"progressBar" cutText ["","PLAIN"];
player playActionNow "stop";
if (life_interrupted) exitWith {life_interrupted = false; titleText["Canceled applying bandage.","PLAIN"]; life_action_inUse = false;};
if !(isNull objectParent player) exitWith {titleText["Canceled applying bandage, you cannot enter a vehicle.","PLAIN"];};

if (_bandageMode == 1) then {
	//Set health
	player setDamage _maxHealth;
} else {
	//Add to health
	_curHealth = damage player;
	_newHealth = _curHealth - getNumber(missionConfigFile >> "Toxic_Config_Bandage" >> _configSide >> "bandageHealing");
	if (_newHealth < _maxHealth) then {
		player setDamage _maxHealth;
	} else {
		player setDamage _newHealth;
	};
};

[false,"bandage",1] call life_fnc_handleInv;

titleText["Bandage applied.","PLAIN"];

 

 

8. Go to "Altis_Life.Altis\config" and CREATE a FILE called "Toxic_Config_Bandage.hpp"

Spoiler
#define true 1
#define false 0

class Toxic_Config_Bandage {
	/*
		bandageTime: (INTEGER) The time in SECONDS it takes to apply the bandage

		bandageSetHealth: (BOOLEAN) When using the bandage it will set the players health
			to the same everytime. Otherwise, it will add to the players current health.

		bandageMaxHealth: (INTEGER) The max amount of health a player can receive from
			using a bandage. If bandageSetHealth = true then this is how much health they will receive

		bandageHealing: (INTEGER) The amount of health given to the player everytime they
			use a bandage. 0 = 100%, 1 = dead
			* NOTE: This will only be used if bandageSetHealth = false

	*/

	class Civilian {
		bandageTime = 5;
		bandageSetHealth = false;
		bandageMaxHealth = 0.2;
		bandageHealing = 0.2;
	}

	class Cop {
		bandageTime = 5;
		bandageSetHealth = false;
		bandageMaxHealth = 0.2;
		bandageHealing = 0.2;
	}

	class Medic {
		bandageTime = 5;
		bandageSetHealth = false;
		bandageMaxHealth = 0.2;
		bandageHealing = 0.2;
	}
}

 

 

9. Download and move the file "ico_bandages.paa" to "Altis_Life.Altis\icons"

 

And that should be it! Please let me know if there are any problems and when asking for help pastebin your client/server logs.

ico_bandages.paa

Edited by ToxicRageTv
  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Great script!!

how do I get it working through the Y menu on altislife 5.0?

it works using Shift+0 but not the Y menu, I tried changing edible from -1 to 20 but it didnt fix it for me.

and step 4  is

case "bandage": {
	[] spawn life_fnc_bandage;
	closeDialog 0;
};

should it be this?

case (_item isEqualTo "bandage": {
	[] spawn life_fnc_bandage;
	closeDialog 0;
};

 

 

Edited by Chaddles
Link to comment
Share on other sites

Are you using default y-menu or a phone menu? Also if your using the most up to day 5.0 it would be:

 

case "bandage": {
	[] spawn life_fnc_bandage;
	closeDialog 0;
};

As well you don't need to change edible -1 to 20 since this then would increase your food if you use a bandage.

Edited by GraveYard
  • Like 1
Link to comment
Share on other sites

On 9/7/2020 at 12:11 PM, Chaddles said:

Great script!!

how do I get it working through the Y menu on altislife 5.0?

it works using Shift+0 but not the Y menu, I tried changing edible from -1 to 20 but it didnt fix it for me.

and step 4  is

case "bandage": {
	[] spawn life_fnc_bandage;
	closeDialog 0;
};

should it be this?

case (_item isEqualTo "bandage": {
	[] spawn life_fnc_bandage;
	closeDialog 0;
};

 

 

Sorry didn't get a notification about your reply. It would depend on your framework version. If you are using the latest 5.0 then it will be what i posted. Otherwise, use the same format that you see in your file.

Link to comment
Share on other sites

  • 1 year later...
5 minutes ago, BehrTheDon said:

im using the xphone mod and i cant get it to work, i know it was working before i put the xphone script in. any ideas? Thanks!

I've never used that or looked at the source code so I'm not sure how it implements using items. Try checking if it overrides the useItem script and check your rpt logs.

Link to comment
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.

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.