erBradipo Posted May 6, 2021 Share Posted May 6, 2021 Hi guys i have some problem with that i don't know i can pass these parameters to the same file the first call from fn_actionKeyHandler [1,0,0] call life_fnc_FTD_DriveLicenseTeoric; the file: #include "..\..\..\script_macros.hpp" #define Btn1 37450 #define Btn2 37451 #define Btn3 37452 #define Btn4 37453 #define Btn5 37454 #define Btn6 37455 #define Btn7 37456 #define Btn8 37457 #define Title 37401 private ["_Ndomanda","_result","_count","_Btn1","_Btn2","_Btn3","_Btn4","_Btn5","_Btn6","_Btn7","_Btn8"]; params ["_Ndomanda","_result","_count"]; disableSerialization; if (isNull _container) exitWith {}; //Bad target if (!dialog) then { createDialog "pInteraction_Menu"; }; _Btn1 = CONTROL(37400,Btn1); _Btn2 = CONTROL(37400,Btn2); _Btn3 = CONTROL(37400,Btn3); _Btn4 = CONTROL(37400,Btn4); _Btn5 = CONTROL(37400,Btn5); _Btn6 = CONTROL(37400,Btn6); _Btn7 = CONTROL(37400,Btn7); _Btn8 = CONTROL(37400,Btn8); {_x ctrlShow false;} forEach [_Btn1,_Btn2,_Btn3,_Btn4,_Btn5,_Btn6,_Btn7,_Btn8]; _count = _count + _result; switch (_Ndomanda) do { case 1 : { _Ndomanda = _Ndomanda + 1; hint "Puoi passare con il rosso?"; _Btn1 ctrlSetText "Si"; _Btn1 buttonSetAction "[_Ndomanda, 1, _count] call life_fnc_FTD_DriveLicenseTeoric;"; _Btn1 ctrlShow true; _Btn2 ctrlSetText "No"; _Btn2 buttonSetAction "[_Ndomanda, 1, _count] call life_fnc_FTD_DriveLicenseTeoric;"; _Btn2 ctrlShow true; }; case 2 : { _Ndomanda = _Ndomanda + 2; hint "A cosa serve l'alternatore"; _Btn1 ctrlSetText "Ricarica la batteria"; _Btn1 buttonSetAction "[_Ndomanda, 1, _count] call life_fnc_FTD_DriveLicenseTeoric;"; _Btn1 ctrlShow true; _Btn2 ctrlSetText "Ricarica la dinamo"; _Btn2 buttonSetAction "[_Ndomanda, 1, _count] call life_fnc_FTD_DriveLicenseTeoric;"; _Btn2 ctrlShow true; }; case 3 : { if (_count >= 2) then { ["FTDSucceeded",["Hai Preso La Patente B!"]] call BIS_fnc_showNotification; license_civ_driver = true; [] call SOCK_fnc_syncData; _Btn1 ctrlSetText "ESCI"; _Btn1 buttonSetAction "closeDialog 0;"; _Btn1 ctrlShow true; } else { ["FTDFailed",["Non hai Preso la Patente, Riprova!"]] call BIS_fnc_showNotification; _Btn1 ctrlSetText "ESCI"; _Btn1 buttonSetAction "closeDialog 0;"; _Btn1 ctrlShow true; }; }; }; Quote Link to comment Share on other sites More sharing options...
KllTA Posted May 20 Share Posted May 20 (edited) To call the same script with different parameters, you can create a function that takes the parameters as input and then call that function with different values. Here's an example of how you can modify the code to achieve this: // Define the function that encapsulates the script logic fnc_interactionMenu = { private["_Ndomanda", "_result", "_count", "_Btn1", "_Btn2", "_Btn3", "_Btn4", "_Btn5", "_Btn6", "_Btn7", "_Btn8"]; params["_Ndomanda", "_result", "_count"]; disableSerialization; if (isNull _container) exitWith {}; // Bad target if (!dialog) then { createDialog "pInteraction_Menu"; }; _Btn1 = CONTROL(37400, Btn1); _Btn2 = CONTROL(37400, Btn2); _Btn3 = CONTROL(37400, Btn3); _Btn4 = CONTROL(37400, Btn4); _Btn5 = CONTROL(37400, Btn5); _Btn6 = CONTROL(37400, Btn6); _Btn7 = CONTROL(37400, Btn7); _Btn8 = CONTROL(37400, Btn8); {_x ctrlShow false;} forEach [_Btn1, _Btn2, _Btn3, _Btn4, _Btn5, _Btn6, _Btn7, _Btn8]; _count = _count + _result; switch (_Ndomanda) do { case 1: { _Ndomanda = _Ndomanda + 1; hint "Puoi passare con il rosso?"; _Btn1 ctrlSetText "Si"; _Btn1 buttonSetAction formatText "[_Ndomanda, 1, %1] call fnc_interactionMenu;", _count; _Btn1 ctrlShow true; _Btn2 ctrlSetText "No"; _Btn2 buttonSetAction formatText "[_Ndomanda, 1, %1] call fnc_interactionMenu;", _count; _Btn2 ctrlShow true; }; case 2: { _Ndomanda = _Ndomanda + 2; hint "A cosa serve l'alternatore"; _Btn1 ctrlSetText "Ricarica la batteria"; _Btn1 buttonSetAction formatText "[_Ndomanda, 1, %1] call fnc_interactionMenu;", _count; _Btn1 ctrlShow true; _Btn2 ctrlSetText "Ricarica la dinamo"; _Btn2 buttonSetAction formatText "[_Ndomanda, 1, %1] call fnc_interactionMenu;", _count; _Btn2 ctrlShow true; }; case 3: { if (_count >= 2) then { ["FTDSucceeded", ["Hai Preso La Patente B!"]] call BIS_fnc_showNotification; license_civ_driver = true; [] call SOCK_fnc_syncData; _Btn1 ctrlSetText "ESCI"; _Btn1 buttonSetAction "closeDialog 0;"; _Btn1 ctrlShow true; } else { ["FTDFailed", ["Non hai Preso la Patente, Riprova!"]] call BIS_fnc_showNotification; _Btn1 ctrlSetText "ESCI"; _Btn1 buttonSetAction "closeDialog 0;"; _Btn1 ctrlShow true; }; }; }; }; // Call the function with different parameters // Example usage: [_initialNdomanda, _initialResult, _initialCount] = [1, 0, 0]; [_initialNdomanda, _initialResult, _initialCount] call fnc_interactionMenu; Please note that the code I provided assumes that the required macros and functions (CONTROL, createDialog, BIS_fnc_showNotification, SOCK_fnc_syncData, etc.) are defined elsewhere in the script_macros.hpp file or other script files and are accessible at runtime. Make sure to include those definitions in your actual script or adjust the code accordingly. Edited May 20 by KllTA Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.