Français HUD avec icônes et jauges progressives pour la version Altis Life 5.X

  • Auteur de la discussion Auteur de la discussion Aryles
  • Date de début Date de début

Aryles

User
23/8/22
209
5
9
800
22
France
discord.gg
Bonjour !
Nous réaliserons un script permettant de réaliser un HUD avec icônes et jauges progressives.
1 - Petite Introduction:

Etant donné que le seul scripts de HUD avec icônes et jauges progressives est sur la 4.X je me suis permis de la modifier pour la 5.X.

Je tiens à donner les crédits à l'auteur original: Repentz

2 - Installation:

L'installation ce fais en plusieurs partie :

1) À la racine de votre mission dialog/hud_stats.hpp, remplacez par le code ci-dessous :
Code:
//---------------------------------
//By Repentz
//---------------------------------

#define INFINITE 1e+1000
#define IDC_LIFE_BAR_FOOD 2200
#define IDC_LIFE_BAR_FOOD_RING 3200
#define IDC_LIFE_BAR_WATER 2201
#define IDC_LIFE_BAR_WATER_RING 3201
#define IDC_LIFE_BAR_HEALTH 2202
#define IDC_LIFE_BAR_HEALTH_RING 3202
//#define IDC_LIFE_BAR_POOP 4202
#define IDC_LIFE_BAR_Speaker 3007
#define IDC_LIFE_BAR_SeatBelt 4203


class playerHUD {
    idd = -1;
    duration = INFINITE;
    movingEnable = 0;
    fadein = 0;
    fadeout = 0;
    name = "playerHUD";
    onLoad = "uiNamespace setVariable ['playerHUD',_this select 0]";
    objects[] = {};
        controls[] = {
        LIFE_BAR_FOOD_RING,
        LIFE_BAR_WATER_RING,
        LIFE_BAR_HEALTH_RING,
        LIFE_BAR_Speaker,
        LIFE_BAR_SeatBelt
    };

        class LIFE_BAR_SeatBelt: Life_RscPicture
        {
            idc = IDC_LIFE_BAR_SeatBelt;
            text = "";
            x = 0.952292 * safezoneW + safezoneX;
            y = 0.574333 * safezoneH + safezoneY;
            w = 0.0331042 * safezoneW;
            h = 0.0589743 * safezoneH;
        };
        class LIFE_BAR_Speaker: Life_RscPicture
        {
            idc = IDC_LIFE_BAR_Speaker;
            text = "";
            x = 0.952292 * safezoneW + safezoneX;
            y = 0.640333 * safezoneH + safezoneY;
            w = 0.0331042 * safezoneW;
            h = 0.0589743 * safezoneH;
        };
        class LIFE_BAR_HEALTH_RING: Life_RscPicture
        {
            idc = IDC_LIFE_BAR_HEALTH_RING;
            text = "";
            x = 0.952292 * safezoneW + safezoneX;
            y = 0.706333 * safezoneH + safezoneY;
            w = 0.0331042 * safezoneW;
            h = 0.0589743 * safezoneH;
        };
        class LIFE_BAR_FOOD_RING: Life_RscPicture
        {
            idc = IDC_LIFE_BAR_FOOD_RING;
            text = "";
            x = 0.952292 * safezoneW + safezoneX;
            y = 0.772333 * safezoneH + safezoneY;
            w = 0.0331042 * safezoneW;
            h = 0.0589743 * safezoneH;
        };
        class LIFE_BAR_WATER_RING: Life_RscPicture
        {
            idc = IDC_LIFE_BAR_WATER_RING;
            text = "";
            x = 0.952292 * safezoneW + safezoneX;
            y = 0.838333 * safezoneH + safezoneY;
            w = 0.0331042 * safezoneW;
            h = 0.0589743 * safezoneH;
        };
};

2 ) À la racine de votre mission core\functions\fn_HudUpdate.sqf remplacez tous le fichier par le code ci-dessous:
Code:
#include "..\..\script_macros.hpp"

//---------------------------------
//By Repentz
//---------------------------------


#define INFINITE 1e+1000
#define IDC_LIFE_BAR_FOOD 2200
#define IDC_LIFE_BAR_FOOD_RING 3200
#define IDC_LIFE_BAR_WATER 2201
#define IDC_LIFE_BAR_WATER_RING 3201
#define IDC_LIFE_BAR_HEALTH 2202
#define IDC_LIFE_BAR_HEALTH_RING 3202
#define IDC_LIFE_BAR_Speaker 3007
#define IDC_LIFE_BAR_SeatBelt 4203

disableSerialization;
if(isNull LIFEdisplay) then {[] call life_fnc_hudSetup;};

//[LIFE_ID_PlayerTags,"onEachFrame"] call BIS_fnc_removeStackedEventHandler;
LIFE_ID_PlayerTags = ["LIFE_PlayerTags","onEachFrame","life_fnc_playerTags"] call BIS_fnc_addStackedEventHandler;

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

if(!isNil "life_fadeSound") then
{
    if(life_fadeSound) then
    {
        LIFEctrl(IDC_LIFE_BAR_Speaker) ctrlSetText "textures\HUD\earplugsY.paa";
    } else {
        LIFEctrl(IDC_LIFE_BAR_Speaker) ctrlSetText "textures\HUD\earplugsN.paa";
    };
};

if(!isNil "life_thirst") then
{
    if (life_thirst <= 100) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water0.paa";
    };

    if (life_thirst <= 90) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water1.paa";
    };

    if (life_thirst <= 80) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water2.paa";
    };

    if (life_thirst <= 70) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water3.paa";
    };

    if (life_thirst <= 60) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water4.paa";
    };

    if (life_thirst <= 50) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water5.paa";
    };

    if (life_thirst <= 40) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water6.paa";
    };

    if (life_thirst <= 30) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water7.paa";
    };

    if (life_thirst <= 20) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water8.paa";
    };

    if (life_thirst <= 10) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water9.paa";
    };

    if (life_thirst <= 0) then
    {
        LIFEctrl(IDC_LIFE_BAR_WATER_RING) ctrlSetText "textures\HUD\water10.paa";
    };
};

if (damage player >= 0) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health0.paa";
};

if (damage player >= 0.01) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health1.paa";
};

if (damage player >= 0.02) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health2.paa";
};

if (damage player >= 0.03) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health3.paa";
};

if (damage player >= 0.07) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health4.paa";
};

if (damage player >= 0.13) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health5.paa";
};

if (damage player >= 0.2) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health6.paa";
};

if (damage player >= 0.3) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health7.paa";
};

if (damage player >= 0.4) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health8.paa";
};

if (damage player >= 0.7) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health9.paa";
};

if (damage player >= 1) then
{
    LIFEctrl(IDC_LIFE_BAR_HEALTH_RING) ctrlSetText "textures\HUD\health10.paa";
};

if(!isNil "life_hunger") then
{
    if (life_hunger <= 100) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food0.paa";
    };

    if (life_hunger <= 90) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food1.paa";
    };

    if (life_hunger <= 80) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food2.paa";
    };

    if (life_hunger <= 70) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food3.paa";
    };

    if (life_hunger <= 60) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food4.paa";
    };

    if (life_hunger <= 50) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food5.paa";
    };

    if (life_hunger <= 40) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food6.paa";
    };

    if (life_hunger <= 30) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food7.paa";
    };

    if (life_hunger <= 20) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food8.paa";
    };

    if (life_hunger <= 10) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food9.paa";
    };

    if (life_hunger <= 0) then
    {
        LIFEctrl(IDC_LIFE_BAR_FOOD_RING) ctrlSetText "textures\HUD\food1.paa";
    };
};


3 ) À la racine de votre mission core\functions\fn_HudSetup.sqf, remplacez par le code ci-dessous :
Code:
#include "..\..\script_macros.hpp"

disableSerialization;

2 cutRsc ["playerHUD","PLAIN"];
[] call life_fnc_hudUpdate;

[] spawn
{
    private["_dam"];
    while {true} do
    {
        _dam = damage player;
        waitUntil {(damage player) != _dam};
        [] call life_fnc_hudUpdate;
    };
};

4) N'oubliez pas d'installer les textures: Votre Mission\textures puis créer un dossier HUD

Voilà votre HUD est maintenant installé, pensez à vérifier qu'il ne vous manque pas des accolades (pour éviter les erreurs inutiles)

C'est fini, il s'agit d'une mise à jour de ce sujet, il ne reste plus qu'à profiter !
 

Fichiers joints

Dernière édition par un modérateur:
  • Like
Les réactions: Maxime_56000 et XplaT Kusto