English Solved Problem with fn_actionkeyhandler and ACE3

29/8/21
2
0
100
When adding the ability to use the ACE3 interaction menu, the following error occurs
[CODE title="PRT log"]Error in expression <ring && [_curTarget] distance player < 3}) : {
if (AvalonClientCashMoneyD > 0) t>
Error position: <}) : {
if (AvalonClientCashMoneyD > 0) t>
Error Missing )
File mpmissions\__cur_mp.Sehreno\code\functions\AvalonClient_system_actionKeyHandler.sqf..., line 12
Error in expression <ring && [_curTarget] distance player < 3}) : {
if (AvalonClientCashMoneyD > 0) t>
Error position: <}) : {
if (AvalonClientCashMoneyD > 0) t>
Error Missing )
File mpmissions\__cur_mp.Sehreno\code\functions\AvalonClient_system_actionKeyHandler.sqf..., line 12[/CODE]



The file whose error is referenced by RPT
[CODE title="AvalonClient_system_actionKeyHandler"]
/*
Filename: AvalonClient_system_actionKeyHandler.sqf
*/
#include "..\..\script_macros.hpp"
private _curTarget = param [0,objNull,[objNull]];
if (life_action_inUse) exitWith {};
if (life_interrupted) exitWith {life_interrupted = false};
if (dialog) exitWith {};
if !(NOTINVEH(player)) exitWith {};
if (isNull _curTarget) exitWith {};
if (EQUAL(_curTarget,player)) exitWith {};

switch (true) do {
case (["atm_",([_curTarget] call AvalonClient_system_getModelName)] call AvalonClient_system_xString && [_curTarget] distance player < 3}) : {
if (DCASH > 0) then {
[] call AvalonClient_atm_legalization;
} else {
[] call AvalonClient_atm_openMenu;
};
};
case (_curTarget isKindOf "House_F") : {
[_curTarget] call AvalonClient_system_initHouseMenu;
};
case (_curTarget isKindOf "CAManBase" && {player distance _curTarget < 5} && {isPlayer _curTarget} && {LSINCAP(_curTarget)}): {
if ( isClass(configFile >> "CfgPatches" >> "ace_interact_menu") ) then {
_agonyaction = ["TWRP_AgonyMenu", "Agony Interaction", "", {[_curTarget] spawn AvalonClient_system_agonyInteractionMenu;},{true},4] call ace_interact_menu_fnc_CreateAction;
[_curTarget , 0, ["ACE_MainActions"],_agonyaction] call ace_interact_menu_fnc_addActionToObject;
} else {
[_curTarget] spawn AvalonClient_system_agonyInteractionMenu;
};
case (_curTarget isKindOf "CAManBase" && {player distance _curTarget < 5} && {isPlayer _curTarget} && {alive _curTarget}): {
if (GVAR_RESTRAINED(_curTarget)) then {
switch(true) do {
case (life_copDuty): {
if ( isClass(configFile >> "CfgPatches" >> "ace_interact_menu") ) then {
_copaction = ["TWRP_CopMenu", "Cop Interaction", "", [_curTarget] spawn AvalonClient_system_copInteractionMenu;},{true},4] call ace_interact_menu_fnc_CreateAction;
[_curTarget , 0, ["ACE_MainActions"],_copaction] call ace_interact_menu_fnc_addActionToObject;
} else {
[_curTarget] spawn AvalonClient_system_copInteractionMenu
};
};
case (life_medDuty): {
if ( isClass(configFile >> "CfgPatches" >> "ace_interact_menu") ) then {
_medaction = ["TWRP_MedMenu", "Med Interaction", "", [_curTarget] spawn AvalonClient_system_medInteractionMenu;},{true},4] call ace_interact_menu_fnc_CreateAction;
[_curTarget , 0, ["ACE_MainActions"],_medaction] call ace_interact_menu_fnc_addActionToObject;
} else {
[_curTarget] spawn AvalonClient_system_medInteractionMenu
};
};
default {
if ( isClass(configFile >> "CfgPatches" >> "ace_interact_menu") ) then {
_civaction = ["TWRP_CivMenu", "Civ Interaction", "", [_curTarget] spawn AvalonClient_system_civInteractionMenu;},{true},4] call ace_interact_menu_fnc_CreateAction;
[_curTarget , 0, ["ACE_MainActions"],_civaction] call ace_interact_menu_fnc_addActionToObject;
} else {
[_curTarget] spawn AvalonClient_system_civInteractionMenu
};
};
};
} else {
if ( isClass(configFile >> "CfgPatches" >> "ace_interact_menu") ) then {
_freeaction = ["TWRP_CivMenu", "Free Interaction", "", [_curTarget] spawn AvalonClient_system_freeInteractionMenu;},{true},4] call ace_interact_menu_fnc_CreateAction;
[_curTarget , 0, ["ACE_MainActions"],_freeaction] call ace_interact_menu_fnc_addActionToObject;
} else {
[_curTarget] spawn AvalonClient_system_freeInteractionMenu;
};
};
};
case (!alive _curTarget && [_curTarget] isKindOf "Animal"} && {(typeOf _curTarget) in ["Salema_F","Ornate_random_F","Mackerel_F","Tuna_F","Mullet_F","CatShark_F","Hen_random_F","Cock_random_F","Goat_random_F","Sheep_random_F","Turtle_F"]}): {
[_curTarget] spawn AvalonClient_system_gutAnimal;
};
case ([_curTarget] call AvalonClient_system_isVehicleKind && {player distance _curTarget < ((boundingBox _curTarget select 1) select 0) + 2}): {
if (EQUAL((typeOf _curTarget),"av_HospitalBed")) then {
//управление больничной койкой (hospital bed management)
if ( isClass(configFile >> "CfgPatches" >> "ace_interact_menu") ) then {
_hbaction = ["TWRP_CivMenu", "Hospital Bed Interaction", "", [_curTarget] spawn AvalonClient_system_hbInteractionMenu;},{true},4] call ace_interact_menu_fnc_CreateAction;
[_curTarget , 0, ["ACE_MainActions"],_hbaction] call ace_interact_menu_fnc_addActionToObject;
} else {
[_curTarget] spawn AvalonClient_system_hbInteractionMenu;
};
} else {
if ( isClass(configFile >> "CfgPatches" >> "ace_interact_menu") ) then {
_vehaction = ["TWRP_CivMenu", "Vehicle Interaction", "", [_curTarget] spawn AvalonClient_system_vInteractionMenu;},{true},4] call ace_interact_menu_fnc_CreateAction;
[_curTarget , 0, ["ACE_MainActions"],_vehaction] call ace_interact_menu_fnc_addActionToObject;
} else {
[_curTarget] spawn AvalonClient_system_vInteractionMenu;
};
};
};
case (EQUAL((typeOf _curTarget),"Land_av_Gate_gang") && {player distance _curTarget < ((boundingBox _curTarget select 1) select 0) + 2}): {
[_curTarget] spawn AvalonClient_system_gateInteractionMenu;
};
default {};
};
[/CODE]

And script_macros.hpp
[CODE title="script_macros.hpp"]/* System Wide Stuff */
#define SUB(var1,var2) var1 = var1 - var2
#define ADD(var1,var2) var1 = var1 + var2
#define SEL(ARRAY,INDEX) (ARRAY select INDEX)
#define DCASH AvalonClientCashMoneyD
#define CASH AvalonClientCashMoney
#define BANK AvalonClientAtmMoney
#define GANG_FUNDS grpPlayer GVAR ["gang_bank",0]
#define GANG_NAME grpPlayer GVAR ["gang_name",""]

//RemoteExec Macros
#define RSERV 2 //Only server
#define RCLIENT -2 //Except server
#define RANY 0 //Global

//Namespace Macros
#define SVAR_MNS missionNamespace setVariable
#define GVAR_MNS missionNamespace getVariable
#define SVAR_UINS uiNamespace setVariable
#define SVAR_PNS parsingNamespace setVariable
#define GVAR_UINS uiNamespace getVariable
#define SVAR_PRNS profileNamespace setVariable
#define GVAR_PRNS profileNamespace getVariable

//Scripting Macros
#define CONST(var1,var2) var1 = compileFinal (if (typeName var2 == "STRING") then {var2} else {str(var2)})
#define CONSTVAR(var) var = compileFinal (if (typeName var == "STRING") then {var} else {str(var)})
#define FETCH_CONST(var) (call var)
#define PVAR_ALL(var) publicVariable var
#define PVAR_SERV(var) publicVariableServer var
#define PVAR_ID(var,id) id publicVariableClient var
#define GVAR getVariable
#define SVAR setVariable
#define RIFLE primaryWeapon player
#define RIFLE_ITEMS primaryWeaponItems player
#define PISTOL handgunWeapon player
#define PISTOL_ITEMS handgunItems player
#define LAUNCHER secondaryWeapon player
#define LAUNCHER_ITEMS secondaryWeaponItems player
#define PHEADGEAR headGear player
#define PBINOCULAR binocular player
#define PUNIFORM uniform player
#define PUNIFORM_ITEMS uniformItems player
#define PVEST vest player
#define PVEST_ITEMS vestItems player
#define PBACKPACK backpack player
#define PBACKPACK_ITEMS backpackItems player
#define PGOOGLES goggles player
#define P_ASSIGNED assignedItems player
#define CURWEAPON currentWeapon player
#define ANIMSTATE animationState player
#define GVAR_RNAME(unit1) unit1 GVAR ["realname",""]
#define GVAR_RTITLE(unit1) unit1 GVAR ["realtitle",""]
#define GVAR_RESTRAINED(unit1) unit1 GVAR ["restrained",false]
#define NOTATTACHED(unit1) (isNull attachedTo unit1)

//Display Macros
#define CONTROL(disp,ctrl) ((findDisplay ##disp) displayCtrl ##ctrl)
#define CONTROL_DATA(ctrl) (lbData[ctrl,lbCurSel ctrl])
#define CONTROL_VALUE(ctrl) (lbValue[ctrl,lbCurSel ctrl])
#define CONTROL_DATAI(ctrl,index) ctrl lbData index
#define CONTROL_TEXTI(ctrl,index) ctrl lbText index
#define CONTROL_VALUEI(ctrl,index) ctrl lbValue index

//System Macros
#define grpPlayer group player
#define steamid getPlayerUID player

//Condition Macros
#define EQUAL(condition1,condition2) condition1 isEqualTo condition2
#define ISANIMSTATE(condition1) (animationState player) isEqualTo condition1
#define ISPSIDE(condition1) playerSide isEqualTo condition1
#define NOTINVEH(condition1) isNull objectParent condition1
#define KINDOF_ARRAY(a,b) [##a,##b] call {_veh = _this select 0;_types = _this select 1;_res = false; {if (_veh isKindOf _x) exitwith { _res = true };} forEach _types;_res}

#define LSALIVE(unit1) unit1 GVAR ["lifeState",""] isEqualTo "HEALTHY"
#define LSNOTALIVE(unit1) unit1 GVAR ["lifeState",""] in ["RESPAWN","INCAPACITATED","DEAD"]

#define LSINCAP(unit1) unit1 GVAR ["lifeState",""] isEqualTo "INCAPACITATED"
#define LSDEAD(unit1) unit1 GVAR ["lifeState",""] isEqualTo "DEAD"
#define LSRESP(unit1) unit1 GVAR ["lifeState",""] isEqualTo "RESPAWN"

//new for config system
#define M_CONFIG(TYPE,CFG,CLASS,ENTRY) TYPE(missionConfigFile >> CFG >> CLASS >> ENTRY)
#define M_CONFIG2(TYPE,CFG,SECTION,CLASS,ENTRY) TYPE(missionConfigFile >> CFG >> SECTION >> CLASS >> ENTRY)
#define BASE_CONFIG(CFG,CLASS) inheritsFrom(configFile >> CFG >> CLASS)
#define FETCH_CONFIG(TYPE,CFG,SECTION,CLASS,ENTRY) TYPE(configFile >> CFG >> SECTION >> CLASS >> ENTRY)
#define FETCH_CONFIG2(TYPE,CFG,CLASS,ENTRY) TYPE(configFile >> CFG >> CLASS >> ENTRY)
#define FETCH_CONFIG3(TYPE,CFG,SECTION,CLASS,ENTRY,SUB) TYPE(configFile >> CFG >> SECTION >> CLASS >> ENTRY >> SUB)
#define FETCH_CONFIG4(TYPE,CFG,SECTION,CLASS,ENTRY,SUB,SUB2) TYPE(configFile >> CFG >> SECTION >> CLASS >> ENTRY >> SUB >> SUB2)

#define ITEM_VARNAME(varName) format ["life_inv_%1",M_CONFIG(getText,"LifeCfgVirtualItems",varName,"variable")]
#define ITEM_VALUE(varName) GVAR_MNS [ITEM_VARNAME(varName),0]
#define ITEM_NAME(varName) localize M_CONFIG(getText,"LifeCfgVirtualItems",varName,"displayName")
#define ITEM_ICON(varName) M_CONFIG(getText,"LifeCfgVirtualItems",varName,"icon")
#define ITEM_WEIGHT(varName) M_CONFIG(getNumber,"LifeCfgVirtualItems",varName,"weight")

#define LIFE_SETTINGS(TYPE,SETTING) TYPE(missionConfigFile >> "LifeCfgSettings" >> SETTING)
#define LIFE_SETTINGSWORLD(TYPE,WRD,SETTING) TYPE(missionConfigFile >> "LifeCfgSettings" >> WRD >> SETTING)
#define LIFE_GTITLE(WRD,TTL) getText(missionConfigFile >> "LifeCfgGarages" >> WRD >> TTL >> "displayName")

#define LIFE_MARKERWORLD(TYPE,WRD,SETTING) TYPE(missionConfigFile >> "LifeCfgMapMarkers" >> WRD >> SETTING)

#define ARC_SETTINGS(TYPE,SETTING) TYPE(missionConfigFile >> "LifeCfgArcheology" >> SETTING)
#define WZ_SETTINGS(TYPE,SETTING) TYPE(missionConfigFile >> "LifeCfgWarZones" >> SETTING)
#define INIT_BUTTON(VAR,CTRL,NAME,ACTION) \
_b##VAR = _display displayCtrl ##CTRL; \
_b##VAR ctrlShow true; \
_b##VAR ctrlSetText NAME; \
_b##VAR buttonSetAction ACTION
#define IS_VIP (call life_donator) > 0[/CODE]
 
Solution
Hello ! You have an error in the following line :
Code:
case (["atm_",([_curTarget] call AvalonClient_system_getModelName)] call AvalonClient_system_xString && [_curTarget] distance player < 3}) : {

Here is the fix :
Code:
case (["atm_",([_curTarget] call AvalonClient_system_getModelName)] call AvalonClient_system_xString && {[_curTarget] distance player < 3}) : {
--- This message was automatically generated by ChatGPT, the content may be incorrect. Please read the message with precautions! ---

The error in the AvalonClient_system_actionKeyHandler script seems to be caused by missing a closing bracket } before the case statement. Ensure each case statement has a corresponding closing bracket. Also, check the overall script's structure for correct nesting and bracket placements. Remember to maintain consistency with brackets and resolve any missing or misplaced ones.

Review the part where the switch statement starts and make sure each case block ends properly. Check the syntax in the script for any typos or missing characters. A clean and organized script structure can help avoid such errors and improve readability for debugging.

--- To continue the discussion with ChatGPT, click "Reply" at the bottom right of this message. Otherwise, wait for someone to reply. ---
 
Hello ! You have an error in the following line :
Code:
case (["atm_",([_curTarget] call AvalonClient_system_getModelName)] call AvalonClient_system_xString && [_curTarget] distance player < 3}) : {

Here is the fix :
Code:
case (["atm_",([_curTarget] call AvalonClient_system_getModelName)] call AvalonClient_system_xString && {[_curTarget] distance player < 3}) : {
 
  • Like
Les réactions: destroymena
Solution
Привет ! У вас ошибка в следующей строке:
[ЗАКОДИРОВАНО]
case (["atm_",([_curTarget] вызов AvalonClient_system_getModelName)] вызов AvalonClient_system_xString && [_curTarget] distance player < 3}): {
[/ЗАКОДИРОВАНО]

Вот исправление:
[ЗАКОДИРОВАНО]
case (["atm_",([_curTarget] вызов AvalonClient_system_getModelName)] вызов AvalonClient_system_xString && {[_curTarget] distance player < 3}): {
[/ЗАКОДИРОВАНО]
Thank you very much. When reading code for a long time, it is very easy to make such a mistake. 😃