Bienvenue sur ce tutoriel qui permettra a vos joueurs d'acheter et utiliser des bandages pour se soigner. Vous pourrez utiliser des bandages en allant dans votre inventaire virtuel, en sélectionnant un bandage et en appuyant sur utiliser, ou encore en utilisant le raccourci SHIFT + 0.
Difficulté : Facile
Tout d'abord, rendez-vous dans : mission.Map\config\Config_vItems.hppDifficulté : Facile
Après cette ligne :
[CODE title="Config_vItems.hpp"] class storagebig {
variable = "storageBig";
displayName = "STR_Item_StorageBL";
weight = 10;
buyPrice = 150000;
sellPrice = 125000;
illegal = false;
edible = -1;
drinkable = -1;
icon = "icons\ico_storageBig.paa";
};[/CODE]
Ajoutez ceci :
[CODE title="Config_vItems.hpp"]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";
};[/CODE]
Après l'avoir ajouté à la configuration, vous devez l'ajouter à une boutique.
Puis, rendez-vous dans : mission.Map\stringtable.xml et ajouter dans la partie "Life_Items"
[CODE title="stringtable.xml"]<Key ID="STR_Item_Bandage">
<Original>Bandage</Original>
</Key>[/CODE]
Ensuite, rendez-vous dans : mission.Map\core\items et créer un fichier appelé "fn_bandage.sqf" et ajoutez y :
[CODE title="fn_bandage.sqf"]#include "..\..\script_macros.hpp"
/*
File: fn_bandage.sqf
Author: ToxicRageTv, translation by Louchou for The-Programmer
Credits: Original creator of the progress bar
*/
if (!alive player) exitWith {"Les bandages ne peuvent plus rien pour vous..."};
if (life_inv_bandage < 1) exitWith {hint "Vous n'avez pas de bandages !"};
if (life_action_inUse) exitWith {hint "Vous faites déjà quelque chose !"};
if !(isNull objectParent player) exitWith {hint "Vous ne pouvez pas mettre un bandage dans un véhicule."};
life_interrupted = false;
_configSide = switch (side player) do {
case civilian: {"Civil"};
case west: {"Police"};
case independent: {"Medic"};
default {"Civil"};
};
_bandageMode = getNumber(missionConfigFile >> "Config_Bandage" >> _configSide >> "bandageSetHealth");
_maxHealth = getNumber(missionConfigFile >> "Config_Bandage" >> _configSide >> "bandageMaxHealth");
if (damage player <= _maxHealth) exitWith {hint "Un bandage ne peut pas vous soigner davantage."};
_bandageTime = getNumber(missionConfigFile >> "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 ["Application d'un 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 ["Application d'un 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["Action annulée.","PLAIN"]; life_action_inUse = false;};
if !(isNull objectParent player) exitWith {titleText["Vous ne pouvez pas mettre un bandage dans un véhicule.","PLAIN"];};
if (_bandageMode == 1) then {
// Set health
player setDamage _maxHealth;
} else {
// Add to health
_curHealth = damage player;
_newHealth = _curHealth - getNumber(missionConfigFile >> "Config_Bandage" >> _configSide >> "bandageHealing");
if (_newHealth < _maxHealth) then {
player setDamage _maxHealth;
} else {
player setDamage _newHealth;
};
};
[false,"bandage",1] call life_fnc_handleInv;
titleText["Bandage appliqué.","PLAIN"];[/CODE]
Désormais, rendez-vous dans : mission.Map\Functions.hpp pour initialiser notre fonction à la fin de la classe "Items" (ligne 260) et ajoutez y :
[CODE title="Functions.hpp"]class bandage {};
[/CODE]
Puis, rendez-vous dans : mission.Map\config et créer un fichier appelé "Config_Bandage.hpp" et ajoutez y :
[CODE title="Config_Bandage.hpp"]#define true 1
#define false 0
class 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 Civil {
bandageTime = 5;
bandageSetHealth = false;
bandageMaxHealth = 0.2;
bandageHealing = 0.2;
};
class Police {
bandageTime = 5;
bandageSetHealth = false;
bandageMaxHealth = 0.2;
bandageHealing = 0.2;
};
class Medic {
bandageTime = 5;
bandageSetHealth = false;
bandageMaxHealth = 0.2;
bandageHealing = 0.2;
};
};
[/CODE]
Enfin, rendez-vous dans : mission.Map\config\Config_Master.hpp et ajouter à la fin :
[CODE title="Config_Master.hpp"]#include "Config_Bandage.hpp"[/CODE]
Désormais, nous allons rendre utilisable notre bandage

Pour rendre notre bandage utilisable dans le menu Y, puis en utilisant le raccourci SHIFT + 0 :
Premièrement, rendez-vous dans : mission.Map\core\functions\fn_useItem.sqf et ajouter à la fin ligne 100 :
[CODE title="fn_useItem.sqf"]case "bandage": {
[] spawn life_fnc_bandage;
closeDialog 0;
};[/CODE]
Puis, rendez-vous dans : mission.Map\core\functions\fn_keyHandler.sqf :
En dessous de :
[CODE title="fn_keyHandler.sqf"]switch (_code) do {
// -- Disable commander/tactical view
if (LIFE_SETTINGS(getNumber,"disableCommanderView") isEqualTo 1) then {
private _CommandMode = actionKeys "tacticalView";
if (_code in _CommandMode) then {
hint localize "STR_NOTF_CommanderView";
_handled = true;
};
};[/CODE]
Ajoutez :
[CODE title="fn_keyHandler.sqf"]// SHIFT + 0
case 11: {
if (_shift) then {
[] spawn life_fnc_bandage;
};
};[/CODE]
Pour finir, il suffira de télécharger la pièce jointe pour obtenir l'icone .paa de l'item, dans le fichier : mission.Map\icons
Désormais, vous avez ajouté le système de bandage !
Source originale