brainboy 5 Posted March 3, 2019 Hello. I'm trying to create a remote control to lock/unlock vehicles is Arma3. By far, I've written a script which allows to interact with all locks. I'm intending to make an object (with specific class name) the requirement for that. Like a car-shop owner who has the key for every vehicles. Can anyone help me complete my script or suggest anything better to make me do it? this addAction [(if ((locked this < 2)) then {"Lock"} else {"Unlock"}), {if ((locked (_this select 0) < 2)) then {(_this select 0) lock 2; (_this select 0) setUserActionText [(_this select 2), "Unlock"];} else {(_this select 0) lock 0; (_this select 0) setUserActionText [(_this select 2), "Lock"];};}]; Share this post Link to post Share on other sites
Maff 251 Posted March 3, 2019 (edited) addAction... So many headaches with this in the past! this addAction [ if (locked this < 2) then {"Lock"} else {"Unlock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { _target lock 2; _target setUserActionText [_actionId, "Unlock"]; } else { _target lock 0; _target setUserActionText [_actionId, "Lock"]; } } ]; Edited March 3, 2019 by Maff Extra brackets not needed. 1 1 Share this post Link to post Share on other sites
pierremgi 4905 Posted March 4, 2019 [_target,0] remoteExec ["lock",_target] ... in MP 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 11 hours ago, Maff said: addAction... So many headaches with this in the past! this addAction [ if (locked this < 2) then {"Lock"} else {"Unlock"}, { params ["_target", "_caller", "_actionId", "_arguments"]; if (locked _target < 2) then { _target lock 2; _target setUserActionText [_actionId, "Unlock"]; } else { _target lock 0; _target setUserActionText [_actionId, "Lock"]; } } ]; I'm intending to make an object (with specific class name) the requirement for that to lock/unlock the car Like a car-shop owner who has the key for vehicles Where should this text be the name of the specific class name that needs to be only the class name to the person to be able to open and close the lock car? Can you write an example to the top lines you wrote me? Share this post Link to post Share on other sites
Maff 251 Posted March 4, 2019 @brainboy Give this a try... I have not tested it as I am off out. Only a player with the class of BLUFOR VR Entity should see the action. I have also added @pierremgi's suggested remoteExec. 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 setUserActionText [_actionId, "Unlock"]; } else { [_target,0] remoteExec ["lock",_target]; _target setUserActionText [_actionId, "Lock"]; } }, [], 2, true, true, "", " typeOf _this isEqualTo "B_Soldier_VR_F" " ]; You may need to change the last string to: typeOf _this isEqualTo 'B_Soldier_VR_F' 1 Share this post Link to post Share on other sites
Maff 251 Posted March 4, 2019 5 hours ago, pierremgi said: [_target,0] remoteExec ["lock",_target] ... in MP Nice one! I wondered if remoteExec was needed, I thought lock was global. 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 not working eror missing ] line 23 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 I need someone to have a item With specified class name in the bag to open and close the car for Example Whenever a person has a pencil in his bag, he can open and close the car Share this post Link to post Share on other sites
Maff 251 Posted March 4, 2019 (edited) Works: 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 setUserActionText [_actionId, "Unlock"]; } else { [_target,0] remoteExec ["lock",_target]; _target setUserActionText [_actionId, "Lock"]; } }, [], 2, true, true, "", "typeOf _this isEqualTo 'B_Soldier_VR_F'" ]; 9 minutes ago, brainboy said: Whenever a person has a pencil in his bag, he can open and close the car Jesus! There are magic pencils in ArmA? That shouldn't be too difficult to script. Does the item have to be in their bag only - Nowhere else? Edited March 4, 2019 by Maff 'B_Soldier_VR_F' 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 pencil just for example i need to change the class name Whatever i want no item can be in bag in ground and... Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 6 minutes ago, Maff said: Works: 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 setUserActionText [_actionId, "Unlock"]; } else { [_target,0] remoteExec ["lock",_target]; _target setUserActionText [_actionId, "Lock"]; } }, [], 2, true, true, "", "typeOf _this isEqualTo ""B_Soldier_VR_F""" ]; Jesus! There are magic pencils in ArmA? That shouldn't be too difficult to script. Does the item have to be in their bag only - Nowhere else? yes now work thanks man thnaks very much I need someone to have a item With specified class name in the bag or in ground to open and close the car just someone to have this item Share this post Link to post Share on other sites
Maff 251 Posted March 4, 2019 OK. The item would need to be an inventory item. I'm sad to say the example pencil is not an inventory item. Just so I understand fully; If there are NONE of these "specified items" in the players backpack OR on the ground near the vehicle, the action to lock/unlock will not be shown. Is that correct? 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 yes thats all i need the item with specified class name to i can use for remot the car to some one has that item can lock/unlock the car Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 It's great if it can be a item inventory Share this post Link to post Share on other sites
Maff 251 Posted March 4, 2019 I've used the "ToolKit" item just for an example. Take care when editing the classname, the classname should have an apostrophe instead of quotation marks. 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 setUserActionText [_actionId, "Unlock"]; } else { [_target,0] remoteExec ["lock",_target]; _target setUserActionText [_actionId, "Lock"]; } }, [], 2, true, true, "", "'ToolKit' in items _this" ]; I am still playing around with a method of detecting inventory items on the ground. 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 its work man its great thank you I took your time today and thank for that, I have just two questions 1.Is it possible to play a sound to open and sound to close permanently to work beautifully? *I know how to work with sound. I just do not know how to run it in this line* 2.Is it possible for this line to run from the beginning for all civilian cars and only the person who has the item(toolkit) can open and close it? Share this post Link to post Share on other sites
Maff 251 Posted March 4, 2019 7 minutes ago, brainboy said: its work man its great thank you I took your time today and thank for that, I have just two questions 1.Is it possible to play a sound to open and sound to close permanently to work beautifully? *I know how to work with sound. I just do not know how to run it in this line* 2.Is it possible for this line to run from the beginning for all civilian cars and only the person who has the item(toolkit) can open and close it? It's no bother. 1. So, play a sound when you lock and unlock a vehicle? That is possible. Do you have a sound or sounds in mind that you could share the classname? 2. So, everyone can see the vehicle lock state (Locked / Unlocked) but, without the "specified item" they cannot lock or unlock the vehicle? That should be pretty straightforward to do using conditions. 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 1.yes in my description named car1 for open and car2 for close 2.yes but Just for all civilian car Because this script can only be used for a car Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 If it's hard for the civilian machines, It is not a problem for all the machines to show the lock state Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 can you do for every vehicle in arma to show lock state? Share this post Link to post Share on other sites
Maff 251 Posted March 4, 2019 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? 1 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 It can be done for all the vehicle inside the game, but every one have the toolkit can lock/unlock the car? can this work for any mod like rhs or cup or only work for defult arma? Share this post Link to post Share on other sites
pierremgi 4905 Posted March 4, 2019 24 minutes ago, brainboy said: It can be done for all the vehicle inside the game, but every one have the toolkit can lock/unlock the car? can this work for any mod like rhs or cup or only work for defult arma? Do you spawn vehicles in game or all vehicles are from editor? 1 Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 all vehicles in editor Share this post Link to post Share on other sites
brainboy 5 Posted March 4, 2019 But I want to run it automatically and I do not need to name cars to work that scrip Share this post Link to post Share on other sites