ramon_dexter 14 Posted March 21, 2015 While playing with Arsenal, I found backpacks with packed in tents and backpacks. These are neat and could be used as rpg objects. My question is, how do I use addAction command on sleeping bag or tent, assembled out of baclpack? Share this post Link to post Share on other sites
lordbooka 159 Posted March 21, 2015 Yes, you could. Please check at: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#WeaponAssembled and https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#WeaponDisassembled but beware about locality, the action you just added will not be sent across the network to other players. Share this post Link to post Share on other sites
ramon_dexter 14 Posted March 25, 2015 Can you please make an example? I really dont know what co call or how to use these... Share this post Link to post Share on other sites
das attorney 858 Posted March 25, 2015 Can you please make an example? I really dont know what co call or how to use these... If you search this forum, you will find someone posted an example mission a while ago. Share this post Link to post Share on other sites
das attorney 858 Posted April 1, 2015 Hello, can you pelase point in the direction (meaning: for what to look)?I have searched first 10 pages of the newly released missions and found nothing that has deployable sleeping bags with sleeping functionality. And I'm sorry, but I don't have enough time to download every one mission and then search it for one function. So if you know what mission this was, you'll be very helpful is you tell me. If not, not. http://forums.bistudio.com/showthread.php?181753-Respawn-Tents&highlight=SLEEPING Share this post Link to post Share on other sites
Ranwer135 308 Posted April 3, 2015 While playing with Arsenal, I found backpacks with packed in tents and backpacks. These are neat and could be used as rpg objects. My question is, how do I use addAction command on sleeping bag or tent, assembled out of baclpack? I am sorry, but I am afraid that this script (or mod like addon) has already been created :/ However, its great that some people brought this up, cause I havn't released my mod version due to unpopularity :P Here: http://www.armaholic.com/page.php?id=24540 Share this post Link to post Share on other sites
dreadedentity 278 Posted April 3, 2015 Here's a little piece of code for something I was working on a few months ago, I never did finish it though. This code makes it so that if you sit down (I don't really remember which button does that), you will have an option to "Wait 2 hours". It's extremely simple, but this could probably help you get along faster: player addAction ["Wait 2 Hours", { _date = date; _date set [3, (_date select 3) + 2]; setDate _date; }, [], 0, false, true, "", "(animationState player) == 'amovpsitmstpsnonwnondnon_ground'"]; Share this post Link to post Share on other sites
[evo] dan 79 Posted April 3, 2015 Yes, you could.Please check at: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#WeaponAssembled and https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#WeaponDisassembled but beware about locality, the action you just added will not be sent across the network to other players. So the event being fired off by either of these will only be triggered local to the unit that did the assemble/disassemble and not serverwide? Would be useful to put up on the Biki. Share this post Link to post Share on other sites
dreadedentity 278 Posted April 3, 2015 Dan;2912371']So the event being fired off by either of these will only be triggered local to the unit that did the assemble/disassemble and not serverwide? Would be useful to put up on the Biki. I believe Das was talking about adding the action to the unit, actions are local, and it is already on the wiki Share this post Link to post Share on other sites
[evo] dan 79 Posted April 3, 2015 (edited) I believe Das was talking about adding the action to the unit, actions are local, and it is already on the wiki Ahh, ok. Just wanted to know as I may be using it for the respawn tents being built and adding it to a serverside variable. Just tried it, got it to work locally, i just need to figure out how to get it to trigger on both the server and the client. (i'm hosting a local dedi via TADST for testing). I get the logged output, but not the server, I guess I have to change the 'player' to something else, but i'm not sure what. init.sqf: player addEventHandler ["WeaponAssembled", "hint 'event triggered'; [] execVM 'evhscript.sqf'"]; evhscript.sqf: "meh" call BIS_fnc_log; I get the hint and the log both turn up on client, nothing in the server rpt. ---------- Post added at 11:03 PM ---------- Previous post was at 09:25 PM ---------- Heres what I've done to get the thing I wanted to work: init.sqf: player addEventHandler ["WeaponAssembled", "hint 'event triggered'; [[[],'evhscript.sqf'],'BIS_fnc_execVM',false,true] call BIS_fnc_MP;"]; evhscript.sqf: if(isServer) then { "meh" call BIS_fnc_log; }; Edited April 3, 2015 by [EVO] Dan Share this post Link to post Share on other sites
ramon_dexter 14 Posted April 5, 2015 (edited) DreadedEntity: This code works like a charm. With a little fix in animation name. Good one! [EVO] Dan: Well, basicly this fires when the sleeping bag is assembled. Good. But I want to add action to that deployed sleeping bag object. I tried putting B_respawn_sleeping_bag_brown_f addaction ["Sleep for 8 hours", "skipTime 8"] But it don't work. I don't know how to directly add action to this object. Is it possible? EDIT: I was trying to build something like this: if ('sc_bedroll' in items player) then { player addAction ["Rozbalit spacák", "player removeItem 'sc_bedroll'"]; _SleepBag = "Land_Sleeping_bag_blue_F" createVehicle position player; _SleepBag addAction ["Sleep for 8 hours", {_date = date; _date set [3, (_date select 3) + 8]; setDate _date;}, [], 0, false, true, "", ""]; _SleepBag addAction ["Pack the sleeping bag", "deleteVehicle '_SleepBag'; player addItem 'sc_bedroll';"]; }; But even if the condition is met (I'm not sure if I'm using the syntax right), the option is not visible. Can anybody tell me what am I doing wrong? The sc_bedroll object is from scorch's inventory items. Edited April 5, 2015 by ramon_dexter Share this post Link to post Share on other sites
Ranwer135 308 Posted April 6, 2015 :rollseyes: Next time, go on: community.bistudio.com For your scripts :/ Here it is, but as I said before, u may try out my script in my mission which is basically the same but works in MP and SP. Note that if u do, and u share it publicly or in server, give me credit. Player addAction ["Deploy sleeping bag", "bag.sqf"]; //bag.sqf createVehicle B_respawn_sleeping_bag_brown_f; ---------- Post added at 09:57 ---------- Previous post was at 09:50 ---------- Edit: after reading it, your better off trying out my camping script as i linked in the page before. I have already started on creating a sleep function for MP, which involves dialogs. Also, the skipping time code u are looking for is: skipTime 30; ---------- Post added at 10:00 ---------- Previous post was at 09:57 ---------- Link to all commands for ArmA 3: https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3 Share this post Link to post Share on other sites
ramon_dexter 14 Posted April 6, 2015 (edited) I was trying to build something myself and created this. This code should allow player to place a sleeping bag on ground, sleep in it and then pack it and return it to plyer's inventory. This is added on player's init line. If player has sc_bedroll in inventory, new actions shows up in actionmenu. this addAction ["Unpack sleeping bag", "sleepingBag.sqf", nil, 6, false, true, "", "_this == _target AND 'sc_bedroll' in (items _this)"]; And the sleepingBag.sqf: _SleepBag = "Land_Sleeping_bag_blue_F" createVehicle position player; player removeItem "sc_bedroll"; _SleepBag addAction ["Sleep for 8 hours", {_date = date; _date set [3, (_date select 3) + 8]; setDate _date;}, [], 0, false, true, "", ""]; _SleepBag addAction ["Pack the sleeping bag", "deleteVehicle 'Land_Sleeping_bag_blue_F'; deleteVehicle 'Land_ClutterCutter_Medium_F'; player addItem 'sc_bedroll';", [], 0, false, true, "", ""]; _SleepBag = "Land_Sleeping_bag_blue_F" createVehicle position player; ////this works - the sleeping bag is placed on the ground player removeItem "sc_bedroll"; ////to remove the bedroll from inv - player places it on the ground _SleepBag addAction ["Sleep for 8 hours", {_date = date; _date set [3, (_date select 3) + 8]; setDate _date;}, [], 0, false, true, "", ""]; ////this also works - the "sleeping action" skips time as planned _SleepBag addAction ["Pack the sleeping bag", "deleteVehicle 'Land_Sleeping_bag_blue_F'; deleteVehicle 'Land_ClutterCutter_Medium_F'; player addItem 'sc_bedroll';", [], 0, false, true, "", ""]; ////this part of the code don't work - i see the action in the actionmenu, but it does nothing. It don't delete the sleepingbag and it don't add the sc_bedroll object into inventory. What am I doing wrong? Ranwer: The skipTime command only skipstime, but leaves AI untouched. I thought that playing with dat would be better. And also, this works. Edited April 6, 2015 by ramon_dexter Share this post Link to post Share on other sites
Larrow 2822 Posted April 6, 2015 _SleepBag addAction ["Pack the sleeping bag", "deleteVehicle 'Land_Sleeping_bag_blue_F'; deleteVehicle 'Land_ClutterCutter_Medium_F'; player addItem 'sc_bedroll';", [], 0, false, true, "", ""]; ////this part of the code don't work - i see the action in the actionmenu, but it does nothing. It don't delete the sleepingbag and it don't add the sc_bedroll object into inventory. You need to delete the sleeping bag via a reference to the object. A class type will not work _SleepBag addAction [ "Pack the sleeping bag",{ _Bag = _this select 3 select 0; deleteVehicle _Bag; player addItem 'sc_bedroll'; }, [ _sleepingBag ], 0, false, true, "", ""]; Here i pass a reference to the sleeping bag into the action via the arguments array. The passed reference is then got by the actions code by using _this select 3 select 0, where select 3 is the array [ _sleepingBag ] and select 0 is the reference _sleepingBag. Share this post Link to post Share on other sites
ramon_dexter 14 Posted April 6, 2015 (edited) Larrow: Thanks, this works like was intended. But I made a little improvement to the thing - I don't like grass poking through the sleeping bag. So I added a grass cutter object and attached the cutter object to the sleeping bag. Now I need to know, how to remove both sleeping bag and grass cutter. here is the code: _cutter = "Land_ClutterCutter_Medium_F" createVehicle position player; _SleepBag = "Land_Sleeping_bag_blue_F" createVehicle position player; _SleepBag attachTo [_cutter, [0,0,0.05]]; player removeItem "sc_bedroll"; _SleepBag addAction ["Sleep for 8 hours", {_date = date; _date set [3, (_date select 3) + 8]; setDate _date;}, [], 0, false, true, "", ""]; _SleepBag addAction [ "Pack the sleeping bag",{ _Bag = _this select 3 select 0; deleteVehicle _Bag; player addItem 'sc_bedroll'; }, [ _SleepBag ], 0, false, true, "", ""]; This method creates the sleeping bag in random place around player. I have an idea: How do I make to create this sleeping bag where I'm looking (I mean, the cursor/pointer/crosshair location). Edited April 6, 2015 by ramon_dexter Share this post Link to post Share on other sites
Larrow 2822 Posted April 6, 2015 _pos = screenToWorld [ 0.5, 0.5 ]; _cutter = createVehicle [ "Land_ClutterCutter_Medium_F", _pos, [], 0, "NONE" ]; _SleepBag = createVehicle [ "Land_Sleeping_bag_blue_F", _pos, [], 0, "NONE" ]; _SleepBag attachTo [_cutter, [0,0,0.05]]; player removeItem "sc_bedroll"; _SleepBag addAction ["Sleep for 8 hours", {_date = date; _date set [3, (_date select 3) + 8]; setDate _date;}, [], 0, false, true, "", ""]; _SleepBag addAction [ "Pack the sleeping bag",{ _Bag = _this select 3 select 0; _cut = _this select 3 select 1; deleteVehicle _Bag; deleteVehicle _cut; player addItem 'sc_bedroll'; }, [ _SleepBag, _cutter ], 0, false, true, "", ""]; screenToWorld gets the world coordinates of the screen position, [0.5, 0.5] being the center of the screen. Screen width/height are a 0->1 range. I have changed your createVehicle commands to the array version. I believe it is generally faster, although not particularly important here its a good habit to get into. I have passed the reference to the _cutter into the action using the arguments array along with the sleeping bag and deleted it when the action is used. Share this post Link to post Share on other sites
ramon_dexter 14 Posted April 6, 2015 Larrow, thank you again. You are one of a few, who explains his code. This is really helpful for me, since I have problems with learning from documentation. I need to have an example code with explanation. That way I learn much faster than from documentation. Share this post Link to post Share on other sites
Larrow 2822 Posted April 6, 2015 You may find that looking somewhere close to the player or other object still makes the sleeping bag spawn not directly where you are looking. When a vehicle is created the engine tries to look for the nearest clear spot to spawn the vehicle. If you change "NONE" in the createVehicle lines to "CAN_COLLIDE" the engine will not do this and will instead place it exactly where asked. Thought that may help. Share this post Link to post Share on other sites
Ranwer135 308 Posted April 10, 2015 Camping script has been published, no need for sweat and stress ;) http://forums.bistudio.com/showthread.php?190719-Tent-Campfire-and-Sleep-Script-RELEASE! Share this post Link to post Share on other sites