English [Traffic System] Have access to the menu with a condition (license, ...)

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

Mathis

Admin
Membre du personnel
29/12/19
503
16
48
1 100
Welcome to this tutorial that will allow you to access the Traffic System menu with a condition such as a license instead of allowing a whole side ;)
This can be used to give, for example, access to the menu to repairman or to a job.
This tutorial follows a user's request for help on Discord.

Let's go !


In your @The_Programmer/addons/traffic_system/server/fn_initAllGroups.sqf, search theses lines :
Code:
Développer Réduire Copier
if (_cop_Author isEqualTo 1) then {_cop_author_Arr pushBack (configName _x);};
if (_med_Author isEqualTo 1) then {_med_author_Arr pushBack (configName _x);};
if (_east_Author isEqualTo 1) then {_east_author_Arr pushBack (configName _x);};
And replace theses lines by :
Code:
Développer Réduire Copier
_cop_author_Arr pushBack (configName _x);

Replace your @The_Programmer/addons/traffic_system/client/fn_controlMenu.sqf by :
Code:
Développer Réduire Copier
/*
    Author: Sharywan
    Web site: www.the-programmer.com
    Discord: https://discord.the-programmer.com

    Terms of use:
      - This file is forbidden unless you have permission from the author. If you have this file without permission to use it please do not use it and do not share it.
      - If you have permission to use this file, you can use it on your server however it is strictly forbidden to share it.
      - Out of respect for the author please do not delete this information.
*/
_side = TP_TrafficLight_cop_Author;
if (_side isEqualTo []) exitWith {};

createDialog "tp_dialog_control_trafficLights";

_display = findDisplay 65500;
(_display displayCtrl 2503) ctrlSetText (["STR_CONTROL_CENTER","Sharywan_Settings_TrafficSystem","TrafficSystem_Localization"] call theprogrammer_core_fnc_localize);
(_display displayCtrl 5002) ctrlSetText (["STR_CLOSE_MENU","Sharywan_Settings_TrafficSystem","TrafficSystem_Localization"] call theprogrammer_core_fnc_localize);

{
    _name         =         getText       (missionConfigFile >> "Sharywan_Settings_TrafficSystem" >> "Traffic_Light" >> _x >> "name");

    _condition = getText (missionConfigFile >> "Sharywan_Settings_TrafficSystem" >> "Traffic_Light" >> _x >> "condition_open_menu");
    _condition_result = if (_condition isEqualTo "") then {true} else {call compile _condition};

    if !(isNil "_condition_result") then {
        if (_condition_result isEqualType true) then {
            if (_condition_result isEqualTo true) then {
                _control     =         _display displayCtrl 38510;

                _control lbAdd _name;
                _control lbSetPicture [(lbSize _control)-1,"\a3\ui_f\data\map\vehicleicons\iconobject_circle_ca.paa"];
                _control lbSetData [(lbSize _control)-1,_x];
                _control lbSetValue [(lbSize _control)-1,_forEachIndex];

                ctrlShow [1001,false];
                ctrlShow [1000,false];
            };
        };
    };
}  forEach _side;

if ((lbSize _control) isEqualTo 0) exitWith {
    closeDialog 0;
    hint (["STR_NO_AUTHOR_2","Sharywan_Settings_TrafficSystem","TrafficSystem_Localization"] call theprogrammer_core_fnc_localize);
};

And finally, in the script's config_master (in the mission), find these lines :
Code:
Développer Réduire Copier
cop_authorize_disable = true; // Allows the side west to use the traffic control panel to disable the lights
medics_authorize_disable = true; // Allows the side medic to use the traffic control panel to disable the lights
east_authorize_disable = false; // Only if you have the adac site: allows you to allow the adac side to use the traffic control panel to disable the lights
And replace them by :
Code:
Développer Réduire Copier
condition_open_menu = ""; // Allows the condition to use the traffic control panel to disable the lights

Two examples :

For one license only :
condition_open_menu = "license_civ_VARIABLE";
For a license or cop or medic : condition_open_menu = "(license_civ_VARIABLE || (playerSide in [west, independent]))";
In both cases, replace VARIABLE by the variable of the concerned license.

And now, it's ready!

Sincerely,
Forum Manager - Mathis
 
Activité
Pour l'instant, il n'y a personne ici