Français Menu de Licences / Permis

Zomblard

User
Salut petit tuto pour mettre en place un menu de licence sous formes de dialog (voir images) :

Difficulté : Hyper simple


license.png

Ce script n'est pas de moi mais j'ai corriger un petit problème qui faisait qu'il ne fonctionner pas
Le script n'enlève pas les licences qu'on as déjà acheter
C'est partie :

1 - Rendez vous dans config\Config_Licenses.hpp et ajouter au dessus de class Licenses - si vous avez d'autre licences ajoutez les ici
Code:
class LicensesShops {
    class DMV {
        name = "STR_Shops_DMV";
        side = "civ";
        conditions = "";
        items[] = { "driver", "trucking", "boat", "dive", "pilot", "gun", "home"};
        };
    };

2 - Ouvrez votre stringtable.xml et ajouter au dessus de <Package name="Shop_Names">
Code:
<Package name="Licenses_Menu">
        <Key ID="STR_Licenses_Title">
            <Original>Licences et Permis</Original>
        </Key>
        <Key ID="STR_My_Licenses">
            <Original>Disponnible</Original>
        </Key>
        <Key ID="STR_Show_Licenses">
            <Original>Mes licenses</Original>
        </Key>
</Package>

3 - Ouvrez votre dialog\MasterHandler.hpp ajouter tout en bas
Code:
#include "license_shop.hpp"

4 - Ouvre votre Functions.hpp et ajouter dans class Shops
Code:
        class licshop_update {};
        class licenses {};

5 - Créer le fichier license_shop.hpp dans le dossier dialog et mettez ceci à l'intérieur
Code:
class license_shop {
    idd = 5546;
    name= "license_shop";
    movingEnable = 0;
    enableSimulation = 1;
    //onLoad = "uiNamespace setVariable [""LicenseShop"", _this select 0];";
    objects[] = { };

    class controls {

        class RscTitleBackground : Life_RscText {
            colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};
            idc = -1;
            text = "$STR_Licenses_Title";
            x = 0.1;
            y = 0.2;
            w = 0.775;
            h = 0.04;
        };

        class Mainbackground : Life_RscText {
            colorBackground[] = {0,0,0,0.7};
            idc = -1;
            x = 0.1;
            y = 0.244;
            w = 0.775;
            h = 0.52;
        };

        class listbox: Life_RscListBox {
            idc = 55126;
            text = "";
            sizeEx = 0.035;
            x = 0.1125;
            y = 0.3;
            w = 0.3125;
            h = 0.4;
        };

        class ShowLicenseslistbox: Life_RscStructuredText {
            idc = 55131;
            text = "";
            sizeEx = 0.035;
            x = 0.55;
            y = 0.3;
            w = 0.3125;
            h = 0.4;
        };

        class MyLicenses : Life_RscText {
            idc = 55130;
            text = "$STR_My_Licenses";
            x = 0.1875;
            y = 0.24;
            w = 0.1375;
            h = 0.04;
        };

        class ShowLicenses : Life_RscText {
            idc = 55129;
            text = "$STR_Show_Licenses";
            x = 0.65;
            y = 0.24;
            w = 0.1375;
            h = 0.04;
        };

        class buybutton: Life_RscButtonMenu {
            idc = 55127;
            text = "$STR_Global_Buy";
            x = 0.4125;
            y = 0.72;
            w = 0.15;
            h = 0.04;
            colorText[] = {1,1,1,1};
            colorBackground[] = {0,0,0,0.8};
            action = "if( (lbData[55126,lbCurSel (55126)] != """") ) then { [false, false, false, lbData[55126,lbCurSel (55126)]] call life_fnc_buyLicense; closeDialog 0; };";
        };
    };
};

6 - Créer le fichier fn_licshop_update.sqf dans le dossier core\shops et mettez ceci à l'intérieur
Code:
#include "..\..\script_macros.hpp"
/*
    File: fn_licshop_update.sqf
    Author: Zippy

    Description:
    License shop Updater
    */
    disableSerialization;
//Setup control vars.
private _buylic_list = CONTROL(5546,55126);
private _curlic_list = CONTROL(5546,55131);

//Purge list
lbClear _buylic_list;
lbClear _curlic_list;

//Buy Licenses
if (!isClass(missionConfigFile >> "LicensesShops" >> life_shop_type)) exitWith {closeDialog 0; hint localize "STR_NOTF_ConfigDoesNotExist";}; //Make sure the entry exists..
  ctrlSetText[2403,localize (M_CONFIG(getText,"LicensesShops",life_shop_type,"name"))];
  private _shopLicenses = M_CONFIG(getArray,"LicensesShops",life_shop_type,"items");

  private _side = switch (playerSide) do {
  case west:{"cop"};
  case civilian:{"civ"};
  case independent:{"med"};
  case east:{"adac"};
};

{
  if !(missionNameSpace getVariable [format ['license_%1_%2',_side,_x],false]) then {
    _displayName = M_CONFIG(getText,"Licenses",_x,"displayName");
    private _price = M_CONFIG(getNumber,"Licenses",_x,"price");

    if !(_price isEqualTo -1) then {
      _buylic_list lbAdd format["%1  ($%2)",(localize _displayName),[_price] call life_fnc_numberText];
      _buylic_list lbSetData [(lbSize _buylic_list)-1,_x];
      _buylic_list lbSetValue [(lbSize _buylic_list)-1,_price];
      _icon = M_CONFIG(getText,"Licenses",_x,"icon");
      if (!(_icon isEqualTo "")) then {
        _buylic_list lbSetPicture [(lbSize _buylic_list)-1,_icon];
      };
    };
  };

} forEach _shopLicenses;

private _struct = "";

{
  private _name = getText(_x >> "displayName");

  if (LICENSE_VALUE(configName _x,_side)) then {
    _struct = _struct + format["%1<br/>",localize _name];
  };
} forEach (format["getText(_x >> 'side') isEqualTo '%1'",_side] configClasses (missionConfigFile >> "Licenses"));

if (_struct isEqualTo "") then {
  _struct = "No Licenses";
};

_curlic_list ctrlSetStructuredText parseText format ["<t>%1</t>",_struct];

7 - Créer le fichier fn_licenses.sqf dans le dossier core\shops et mettez ceci à l'intérieur
Code:
#include "..\..\script_macros.hpp"
/*
    File: fn_licenses.sqf
    Author: Zippy

    Description:
    Open the licenses menu
*/

params [
    ["_shopNPC", objNull, [objNull]],
    "",
    "",
    ["_shopType", "", [""]]
];

if (isNull _shopNPC || {_shopType isEqualTo ""}) exitWith {};

private _shopSide = M_CONFIG(getText,"LicensesShops",_shopType,"side");

life_shop_type = _shopType;
life_shop_npc = _shopNPC;

private _exit = false;

if !(_shopSide isEqualTo "") then {
    private _flag = switch (playerSide) do {case west: {"cop"}; case independent: {"med"}; default {"civ"};};
    if !(_flag isEqualTo _shopSide) then {_exit = true;};
};

if (_exit) exitWith {};

private _conditions = M_CONFIG(getText,"LicensesShops",_shopType,"conditions");

if !([_conditions] call life_fnc_levelCheck) exitWith {hint localize "STR_Shop_Veh_NotAllowed";};

createDialog "license_shop";

[] call life_fnc_licshop_update;


/*
_display = findDisplay 5546;
if(isNull _display) exitWith {};
_listbox = _display displayCtrl 55126;
_mylic = _display displayCtrl 55131;
_struct = "";
*/

8 - Rendez-vous dans votre mission.sqm supprimez les choses qui ressemble à ça dans votre license shop actuel :
Code:
this addAction[format ["%1 ($%2)",localize (getText(missionConfigFile >> "Licenses" >> "driver" >> "displayName")), [(getNumber(missionConfigFile >> "Licenses" >> "driver" >> "price"))] call life_fnc_numberText],life_fnc_buyLicense,"driver",0,false,false,"",' !license_civ_driver && playerSide isEqualTo civilian ',5];

9 - Toujours dans votre mission.sqm ajoutez ceci pour exécuter le script de menu des licences
Code:
this addAction[localize"STR_MAR_DMV",life_fnc_licenses,"DMV",0,false,false,"",'((player distance cursorObject) < 5)'];

Et voilà c'est fini.
 
Dernière édition par un modérateur:
  • Like
Les réactions: IceEagle132
So players can't open the menu from a mile away should do:


this addAction[localize"STR_MAR_DMV",life_fnc_licenses,"DMV",5];
 
  • Like
Les réactions: Zomblard
Does not appear that your list on the left updates. Here is the fix:
License Shop Updater:
#include "..\..\script_macros.hpp"
/*
    File: fn_licshop_update.sqf
    Author: Zippy

    Description:
    License shop Updater
*/
disableSerialization;
//Setup control vars.
private _buylic_list = CONTROL(5546,55126);
private _curlic_list = CONTROL(5546,55131);

//Purge list
lbClear _buylic_list;
lbClear _curlic_list;

//Buy Licenses
if (!isClass(missionConfigFile >> "LicensesShops" >> life_shop_type)) exitWith {closeDialog 0; hint localize "STR_NOTF_ConfigDoesNotExist";}; //Make sure the entry exists..
ctrlSetText[2403,localize (M_CONFIG(getText,"LicensesShops",life_shop_type,"name"))];
private _shopLicenses = M_CONFIG(getArray,"LicensesShops",life_shop_type,"items");

private _side = switch (playerSide) do {
    case west:{"cop"};
    case civilian:{"civ"};
    case independent:{"med"};
    case east:{"adac"};
};

{
    if(!(call compile format ['license_%1_%2',_side,_x])) then {
      _displayName = M_CONFIG(getText,"Licenses",_x,"displayName");
      private _price = M_CONFIG(getNumber,"Licenses",_x,"price");

      if (!(_price isEqualTo -1)) then {
          _buylic_list lbAdd format["%1  ($%2)",(localize _displayName),[_price] call life_fnc_numberText];
          _buylic_list lbSetData [(lbSize _buylic_list)-1,_x];
          _buylic_list lbSetValue [(lbSize _buylic_list)-1,_price];
          _icon = M_CONFIG(getText,"Licenses",_x,"icon");
          if (!(_icon isEqualTo "")) then {
              _buylic_list lbSetPicture [(lbSize _buylic_list)-1,_icon];
          };
      };
    };

} forEach _shopLicenses;

//Show licenses
private _struct = "";

{
    private _name = getText(_x >> "displayName");

    if (LICENSE_VALUE(configName _x,_side)) then {
        _struct = _struct + format["%1<br/>",localize _name];
    };
} forEach (format["getText(_x >> 'side') isEqualTo '%1'",_side] configClasses (missionConfigFile >> "Licenses"));

if (_struct isEqualTo "") then {
    _struct = "No Licenses";
};
        _curlic_list ctrlSetStructuredText parseText format ["<t>%1</t>",_struct];
 

Daniels Morris

User
Developer
Sa pourrais être cool de faire un check des licenses, je m'explique si tu a la license camion dans la listBox a gauche sa t'affichera License camion (Acquise) d'une certaine couleur
 

Zomblard

User
Oui c’était le but du fix :)
Dans un premier temps de les supprimer des disponnibles
 
Sa pourrais être cool de faire un check des licenses, je m'explique si tu a la license camion dans la listBox a gauche sa t'affichera License camion (Acquise) d'une certaine couleur
So the update makes it so now if you own a license it won't show on the left list only on the right.
 
Here I will share what I did for my test server, I also made it so the display will update without closing.
 

Fichiers joints

  • Licences-Permits.zip
    4.7 KB · Affichages: 20

Zomblard

User
Bonjour ; on peux en faire plusieur menu ?

J'ai pas tester mais ça devrais marcher
Voici comment faire :
Va dans : config\Config_Licenses.hpp
Dans class LicensesShops rajoute en dessous de :
Code:
class DMV {
        name = "STR_Shops_DMV";
        side = "civ";
        conditions = "";
        items[] = { "driver", "trucking", "boat", "dive", "pilot", "gun", "home"};
        };
Ceci :
Code:
class NOM_DE_TON_SHOP {
        name = "STR_Shops_NOM_DANS_STRINGTABLE";
        side = "civ";
        conditions = "";
        items[] = { "LES", "LICENCES", "QUE", "TU", "VEUT"};
        };
N'oublie pas de rajouter dans ta stringtable !
Ensuite tu va dans ta mission.sqm
Et sur une pancarte ou un PNJ tu rajoute :
Code:
this addAction[localize"STR_MAR_NOM_DANS_STRINGTABLE",life_fnc_licenses,"NOM_DE_TON_SHOP",0,false,false,"",'((player distance cursorObject) < 5)'];

Oublie pas de remplacer :
NOM_DE_TON_SHOP
NOM_DANS_STRINGTABLE

Sa devrais allez comme ça.
 
  • Like
Les réactions: Maxence