Cruiser1092 3 Posted June 7 Greetings! How can I create a multiplayer-compatible in-game Light Switch that allows me to turn specific lights on and off using the addaction command? For example: in a room with lights (light1,light2) I would like to place a Land transfer switch that allows me to turn light1 and light 2 on and off with an addaction command on it Share this post Link to post Share on other sites
JCataclisma 79 Posted June 8 Man, I have done a very similar thing on those "folded camp lamps" I attached to a helicopter, but it was more than a year ago. I will run a better search, but I am sure I got it from a topis here in forums, most likely from Larrow, and it also got the "synch" in editor involved (right-click -> synch). Here is one of topics which have also helped me then, but they're using triggers, instead. Share this post Link to post Share on other sites
JCataclisma 79 Posted June 8 Ok, found it. But, so far, it doesn't have any additional addAction as you wished - only the original action from the switch. I have several objects "Land_PortableLight_02_single_folded_black_F" attached to a vehicle, as well as a switch box "Land_TransferSwitch_01_F". There is also a game logic. All of these objects ares synched (right-click => synch): lamps, switch box and logic. And this is what's on LOGIC's attributes -> Init: [this, vangnamStyle] call BIS_fnc_attachToRelative; // I needed the switch box attached to the van - unnecessary in case of static (but functional) switch; _objs = synchronizedObjects this; _switch = _objs select{ _x isKindOf "Land_TransferSwitch_01_F" } select 0; _lights = _objs select { (_x isKindOf "Land_PortableLight_02_single_folded_olive_F") || (_x isKindOf "Land_PortableLight_02_single_folded_sand_F") || (_x isKindOf "Land_PortableLight_02_single_folded_black_F") }; TAG_fnc_lightsState = { params[ "_lights", "_lightState" ]; { _x switchLight _lightState; }forEach _lights; }; _switch setVariable[ "LightActionID", _switch addAction[ "SuperLights Off", { params [ "_target", "_caller", "_id", "_args" ]; _args params[ "_lights" ]; _info = if ( _target animationSourcePhase "SwitchPosition" == 0 ) then { [ "OFF", "SuperLights On", 1, 0 ] }else{ [ "ON", "SuperLightsLights Off", 0, 1 ] }; _info params[ "_lightState", "_actionText", "_switchPosition", "_switchLight" ]; _target animateSource[ "SwitchPosition", _switchPosition ]; _target animateSource[ "SwitchLight", _switchLight ]; [ [ _target, _actionText ], { params[ "_target", "_actionText" ]; _target setUserActionText[ _target getVariable "LightActionID", _actionText ] } ] remoteExec[ "BIS_fnc_call", 0, format[ "%1_actionState", _target call BIS_fnc_objectVar ] ]; [ _lights, _lightState ] remoteExec[ "TAG_fnc_lightsState", 0, format[ "%1_lightState", _target call BIS_fnc_objectVar ] ]; }, [ _lights ], 1, true, false ] ]; Share this post Link to post Share on other sites
Cruiser1092 3 Posted June 9 On 08/06/2024 at 02:42, JCataclisma said: Ok, trovato. Ma, finora, non ha alcuna addAction aggiuntiva come desideri, solo l'azione originale dell'interruttore. Ho diversi oggetti "Land_PortableLight_02_single_folded_black_F" collegati a un veicolo, nonché una scatola di commutazione "Land_TransferSwitch_01_F". C'è anche una logica di gioco. Tutti questi oggetti sono sincronizzati (tasto destro => sincronizza): lampade, quadro elettrico e logica. E questo è ciò che c'è negli attributi di LOGIC -> Init: Thanks for the reply! I tried to use this code (written below) to do what I would like. The script works. You turn the lights on and off using the "addaction" command on the power switch, only it only works once for both actions. I wish it could be done whenever I need it. But I'm stuck and I don't know how to make the action happen again. call{[this, "turn off", "", "", "true", "true", {(_this select 0) animateSource ["switchposition",0,1];}, {}, {{ _x setdamage 0.97;} forEach [lamp_a001,lamp_a002,lamp_a003]; (_this select 0) setObjectTextureGlobal [1,"#(argb,8,8,3)color(1,0,0,1,ca)"];}, {(_this select 0) animateSource ["switchposition",1,1]; { _x setdamage 0;} forEach [lamp_a001,lamp_a002,lamp_a003];}, [], 2, nil, true, false] call BIS_fnc_holdActionAdd;} call{[this, "turn on", "", "", "true", "true", {(_this select 0) animateSource ["switchposition",1,1];}, {}, {{ _x setdamage 0.0;} forEach [lamp_a001,lamp_a002,lamp_a003]; (_this select 0) setObjectTextureGlobal [1,"#(argb,8,8,3)color(1,0,0,1,ca)"];}, {(_this select 0) animateSource ["switchposition",0,1]; { _x setdamage 0;} forEach [lamp_a001,lamp_a002,lamp_a003];}, [], 2, nil, true, false] call BIS_fnc_holdActionAdd;} 1 Share this post Link to post Share on other sites
Necropaulo 31 Posted June 9 Hello, as indicated in the BIS_fnc_holdaction wiki, in your code you have the “remove after completion” parameter set to True, so your code as it stands can only be used once. To change this, simply change the parameter from True to False. call{[this, "turn off", "", "", "true", "true", {(_this select 0) animateSource ["switchposition",0,1];}, {}, {{ _x setdamage 0.97;} forEach [lamp_a001,lamp_a002,lamp_a003]; (_this select 0) setObjectTextureGlobal [1,"#(argb,8,8,3)color(1,0,0,1,ca)"];}, {(_this select 0) animateSource ["switchposition",1,1]; { _x setdamage 0;} forEach [lamp_a001,lamp_a002,lamp_a003];}, [], 2, nil, false, false] call BIS_fnc_holdActionAdd;} call{[this, "turn on", "", "", "true", "true", {(_this select 0) animateSource ["switchposition",1,1];}, {}, {{ _x setdamage 0.0;} forEach [lamp_a001,lamp_a002,lamp_a003]; (_this select 0) setObjectTextureGlobal [1,"#(argb,8,8,3)color(1,0,0,1,ca)"];}, {(_this select 0) animateSource ["switchposition",0,1]; { _x setdamage 0;} forEach [lamp_a001,lamp_a002,lamp_a003];}, [], 2, nil, false, false] call BIS_fnc_holdActionAdd;} This should do what you want 😁 1 Share this post Link to post Share on other sites
Cruiser1092 3 Posted June 9 Fantastic guys! works great! You are wonderful!😍 1 Share this post Link to post Share on other sites