brainboy 5 Posted March 4, 2019 Can it be added to the script that when the car is opened and closed, the car lights up a flash? Share this post Link to post Share on other sites
pierremgi 4890 Posted March 4, 2019 { _x addAction [...] } forEach vehicles; in init.sqf or in a trigger set to true (instead of this) Trigger must be global (not server only), non repeatable. 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 3 minutes ago, pierremgi said: { _x addAction [...] } forEach vehicles. in init.sqf or in a trigger set to true (instead of this) Trigger must be global (not server only), non repeatable. ok Can it be added to the script that when the car is opened and closed, the car lights up a flash? Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 { _x addAction} forEach vehicles. [ if (locked this < 2) then {"Lock"} else {"Unlock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { [_target,2] remoteExec ["lock",_target]; [_target, "car"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Unlock"]; } else { [_target,0] remoteExec ["lock",_target]; [_target, "car"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Lock"]; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; is that right? Share this post Link to post Share on other sites
pierremgi 4890 Posted March 4, 2019 10 minutes ago, brainboy said: { _x addAction} forEach vehicles. is that right? No. That's not what I wrote. The addAction [ <code>] is inside the { } forEach. For lights up and flash. Sure. You'll find some existing code for that. 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 4 minutes ago, pierremgi said: No. That's not what I wrote. The addAction [ <code>] is inside the { } forEach. For lights up and flash. Sure. You'll find some existing code for that. ok thanks man Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 4 hours ago, Maff said: This working on my end. The script to detect "specified item" within 7 metres on the ground is all that I could come up with. You will need to add in your own sound classnames. Change "addItemOK" and "addItemFailed" as needed. this addAction [ if (locked this < 2) then {"Lock"} else {"Unlock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { [_target,2] remoteExec ["lock",_target]; [_target, "addItemOK"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Unlock"]; } else { [_target,0] remoteExec ["lock",_target]; [_target, "addItemFailed"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Lock"]; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; I am a bit confused here... You need every civilian vehicle to have this addAction on? Is that right? My problem with the script that the writer solved is just when I'm lock/unlock the car i need to flash the light car when lock/unlock do you scrip for that? Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 5 hours ago, pierremgi said: No. That's not what I wrote. The addAction [ <code>] is inside the { } forEach. For lights up and flash. Sure. You'll find some existing code for that. { _x addAction [ if (locked _x < 2) then {"Lock"} else {"Unlock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { [_target,2] remoteExec ["lock",_target]; [_target, "car"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Unlock"]; if (!isEngineOn _target) then { _target engineOn true; }; //if (!isEngineOn _target) then { _target engineOn true; }; sleep 0.5; //if (!isPilotLight _target) then { _target PilotLight false; }; } else { [_target,0] remoteExec ["lock",_target]; [_target, "car"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Lock"]; //if (!isPilotLight _target) then { _target PilotLight true; }; //sleep 0.5; //if (!isPilotLight _target) then { _target PilotLight false; }; if (isEngineOn _target) then { _target engineOn false; }; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; }forEach vehicles; do you think i writte this right for engine on and light on? Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 6 hours ago, Maff said: This working on my end. The script to detect "specified item" within 7 metres on the ground is all that I could come up with. You will need to add in your own sound classnames. Change "addItemOK" and "addItemFailed" as needed. this addAction [ if (locked this < 2) then {"Lock"} else {"Unlock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { [_target,2] remoteExec ["lock",_target]; [_target, "addItemOK"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Unlock"]; } else { [_target,0] remoteExec ["lock",_target]; [_target, "addItemFailed"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Lock"]; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; I am a bit confused here... You need every civilian vehicle to have this addAction on? Is that right? { _x addAction [ if (locked _x < 2) then {"Lock"} else {"Unlock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { [_target,2] remoteExec ["lock",_target]; [_target, "car"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Unlock"]; [_target setPilotLight true,true,false] call BIS_fnc_MP; [_target engineOn true,true,false] call BIS_fnc_MP; sleep 0.5; [_target setPilotLight false,true,false] call BIS_fnc_MP; } else { [_target,0] remoteExec ["lock",_target]; [_target, "car"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "Lock"]; [_target setPilotLight true,true,false] call BIS_fnc_MP; [_target engineOn false,true,false] call BIS_fnc_MP; sleep 0.5; [_target setPilotLight false,true,false] call BIS_fnc_MP; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; }forEach vehicles; Alright. The script works well and I've added some extra lines to make the remote unlock the vehicle, turn the engine on and make the lights blink. All of these functions works very well localy but in multiplayer turned out players can't see the lights turnning on and the engines goes off immediately after turning on. The thing is players can see these effects while using them but others can't can you help me for this? Share this post Link to post Share on other sites
pierremgi 4890 Posted March 4, 2019 [_target,true] remoteExec ["engineOn",_target] 1. Do not use BIS_fnc_MP anymore. remoteExec instead. Take time to have a look at this command. 2. In MP, in your addAction code, each time you see for a command, especially for vehicles for which their locality can often change, remoteExec on the local (owner) PC (here where _target is). Player (the caller) and vehicle (the target) are not often on the same PC. Try with setPilotLight. Not tested. I don't at this time if Arma engine overrides the command or not. (The problem is that many behaviors like switch on/off lights are already coded by engine and depend on behavior mode of the units...) Should be not the case for an empty vehicle. 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 5, 2019 15 hours ago, pierremgi said: [_target,true] remoteExec ["engineOn",_target] 1. Do not use BIS_fnc_MP anymore. remoteExec instead. Take time to have a look at this command. 2. In MP, in your addAction code, each time you see for a command, especially for vehicles for which their locality can often change, remoteExec on the local (owner) PC (here where _target is). Player (the caller) and vehicle (the target) are not often on the same PC. Try with setPilotLight. Not tested. I don't at this time if Arma engine overrides the command or not. (The problem is that many behaviors like switch on/off lights are already coded by engine and depend on behavior mode of the units...) Should be not the case for an empty vehicle. thank you man it work I had a question in order to be able to completely delete the inventory action. On a car, I have to write a line? Share this post Link to post Share on other sites
Maff 251 Posted March 5, 2019 2 hours ago, brainboy said: I had a question in order to be able to completely delete the inventory action. On a car, I have to write a line? Removing the inventory action from vehicles is not possible as far as I know. 1 Share this post Link to post Share on other sites
Dedmen 2714 Posted March 5, 2019 2 hours ago, Maff said: Removing the inventory action from vehicles is not possible as far as I know. Only with config mod. 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted March 5, 2019 5 hours ago, brainboy said: I had a question in order to be able to completely delete the inventory action. You can disable this with the eventhandler inventoryopened https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#InventoryOpened 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted March 5, 2019 I was writing an access script , for vehicles , ammoboxes and static weapons but never publish it. Maybe sometime this will be available ! 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted March 5, 2019 Here is a different approach : set a variable to an object : ex : this setVariable ["Var_GF_Access_Inventory",true]; and add this in the initplayerlocal.sqf inGameUISetEventHandler ["action", " _target = _this select 0; _action = _this select 3; if ( cursorTarget in vehicles && _target getvariable ['Var_GF_Access_Inventory',false] && _action in ['Rearm','Gear','Inventory'] ) then {true} else {false} " ]; 1 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 5, 2019 55 minutes ago, GEORGE FLOROS GR said: Here is a different approach : set a variable to an object : ex : this setVariable ["Var_GF_Access_Inventory",true]; and add this in the initplayerlocal.sqf inGameUISetEventHandler ["action", " _target = _this select 0; _action = _this select 3; if ( cursorTarget in vehicles && _target getvariable ['Var_GF_Access_Inventory',false] && _action in ['Rearm','Gear','Inventory'] ) then {true} else {false} " ]; { [_x, "LOCKED"] remoteExec ["setVehicleLock"]; _x addAction [ if (locked _x < 2) then {"unlock"} else {"lock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { [_target,2] remoteExec ["lock",_target]; [_target, "carlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "unlock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,true] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; } else { [_target,0] remoteExec ["lock",_target]; [_target, "carunlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "lock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,false] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; //null= execVM "inventoryon.sqf"; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; }forEach vehicles; I wrote with the help of friends a line that I can open and close in the car with a remote control, but now I intend to have it locked the door car as it is written in this script, do not open the inventory, and when unlocked the inventory has work and it will be repeated, and when someone does it, it will happen to everyone? Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted March 5, 2019 3 minutes ago, brainboy said: set a variable to an object : ex : this setVariable ["Var_GF_Access_Inventory",true]; so when it's locked you will add also a variable ( true ) and ( false ) when it's not. Tip : use the <> code button and include your code inside and if it's a long code , use also the spoiler before 1 Share this post Link to post Share on other sites
Maff 251 Posted March 5, 2019 5 hours ago, Maff said: Removing the inventory action from vehicles is not possible as far as I know. 3 hours ago, Dedmen said: Only with config mod. Ah! Out of curiosity, if the inventory action is removed via a config, would pressing your inventory keybind still open a vehicles inventory? 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 5, 2019 3 minutes ago, GEORGE FLOROS GR said: so when it's locked you will add also a variable ( true ) and ( false ) when it's not. Tip : use the <> code button and include your code inside and if it's a long code , use also the spoiler before can you writte for me idont know how it work Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted March 5, 2019 17 minutes ago, brainboy said: idont know how it work 1 hour ago, GEORGE FLOROS GR said: and add this in the initplayerlocal.sqf inGameUISetEventHandler ["action", " _target = _this select 0; _action = _this select 3; if ( cursorTarget in vehicles && _target getvariable ['Var_GF_Access_Inventory',false] && _action in ['Rearm','Gear','Inventory'] ) then {true} else {false} " ]; and this in your initServer.sqf { [_x, "LOCKED"] remoteExec ["setVehicleLock"]; _x setVariable ["Var_GF_Access_Inventory",true]; _x addAction [ if (locked _x < 2) then {"unlock"} else {"lock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { _target setVariable ["Var_GF_Access_Inventory",true]; [_target,2] remoteExec ["lock",_target]; [_target, "carlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "unlock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,true] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; } else { _target setVariable ["Var_GF_Access_Inventory",false]; [_target,0] remoteExec ["lock",_target]; [_target, "carunlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "lock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,false] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; //null= execVM "inventoryon.sqf"; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; }forEach vehicles; But just to know , if you want the code to work with the spawned vehicles as well you need to loop your code 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted March 5, 2019 29 minutes ago, GEORGE FLOROS GR said: if you want the code to work with the spawned vehicles as well you need Spoiler 29 minutes ago, GEORGE FLOROS GR said: and add this in the initplayerlocal.sqf inGameUISetEventHandler ["action", " _target = _this select 0; _action = _this select 3; if ( cursorTarget in vehicles && _target getvariable ['Var_GF_Access_Inventory',false] && _action in ['Rearm','Gear','Inventory'] ) then {true} else {false} " ]; GF_Access = { _this setVariable ["Var_GF_Access",true]; _this setVariable ["Var_GF_Access_Inventory",true]; _this addAction [ if (locked _x < 2) then {"unlock"} else {"lock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { _target setVariable ["Var_GF_Access_Inventory",true]; [_target,2] remoteExec ["lock",_target]; [_target, "carlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "unlock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,true] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; } else { _target setVariable ["Var_GF_Access_Inventory",false]; [_target,0] remoteExec ["lock",_target]; [_target, "carunlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "lock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,false] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; //null= execVM "inventoryon.sqf"; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; }; [] spawn { while {true} do { waitUntil{uisleep 1; { if ( ((alive _x)) && (!(_x getVariable ["Var_GF_Access",false])) && ( (_x isKindOf "Car") or (_x isKindOf "Tank") or (_x isKindOf "Air") or (_x isKindOf "Ship") or (_x isKindOf "StaticWeapon") ) ) then { _x call GF_Access; _x setVehicleLock "LOCKED"; }; }forEach vehicles; }; }; }; 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 5, 2019 33 minutes ago, GEORGE FLOROS GR said: and this in your initServer.sqf { [_x, "LOCKED"] remoteExec ["setVehicleLock"]; _x setVariable ["Var_GF_Access_Inventory",true]; _x addAction [ if (locked _x < 2) then {"unlock"} else {"lock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { _target setVariable ["Var_GF_Access_Inventory",true]; [_target,2] remoteExec ["lock",_target]; [_target, "carlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "unlock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,true] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; } else { _target setVariable ["Var_GF_Access_Inventory",false]; [_target,0] remoteExec ["lock",_target]; [_target, "carunlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "lock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,false] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; //null= execVM "inventoryon.sqf"; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; }forEach vehicles; But just to know , if you want the code to work with the spawned vehicles as well you need to loop your code how can i chang this scrip to mod for use in dedicated server? Share this post Link to post Share on other sites
brainboy 5 Posted March 5, 2019 52 minutes ago, GEORGE FLOROS GR said: and this in your initServer.sqf { [_x, "LOCKED"] remoteExec ["setVehicleLock"]; _x setVariable ["Var_GF_Access_Inventory",true]; _x addAction [ if (locked _x < 2) then {"unlock"} else {"lock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { _target setVariable ["Var_GF_Access_Inventory",true]; [_target,2] remoteExec ["lock",_target]; [_target, "carlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "unlock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,true] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; } else { _target setVariable ["Var_GF_Access_Inventory",false]; [_target,0] remoteExec ["lock",_target]; [_target, "carunlock"] remoteExec ["say3D"]; _target setUserActionText [_actionId, "lock"]; [_target,true] remoteExec ["setPilotLight",_target]; [_target,false] remoteExec ["engineOn",_target]; sleep 0.5; [_target,false] remoteExec ["setPilotLight",_target]; //null= execVM "inventoryon.sqf"; } }, [], 2, true, true, "", "('ToolKit' in items _this) or (if ( count ( ( _target nearObjects 7 ) select { ( getItemCargo _x select 0 select 0 ) find 'ToolKit' >= 0 } ) > 0 ) then { true } else { false })" ]; }forEach vehicles; But just to know , if you want the code to work with the spawned vehicles as well you need to loop your code Thank you very much for the guidance you gave and the line you wrote that caused the inventory to open and close, but there is a problem. When inventory is closed if you open your inventory and open it in near the car, you can pick item in inventory car from crate I need when inventory not working No one can move things inside the inventory car Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted March 5, 2019 19 minutes ago, brainboy said: if you open your inventory and open it in near the car, PS : you don't need to quote the whole post ! add also inside the initPlayerlocal.sqf : player addEventHandler ["InventoryOpened",{ params ["_unit","_container"]; _Access = false; if (_container getvariable ["Var_GF_Access_Inventory",false]) then { systemchat "NO Access"; _Access = true; }; _Access }]; 1 Share this post Link to post Share on other sites