thedog88 4 Posted May 18, 2013 hey guys, so i've searched and only found 1 thread with a similar question and that thread had no replies so let me try this in a new one. mission: player must deliver water and food to a location (using objects from my soon to be released ARP pack) execution: player receives the locations and packs food into his bag. he goes there and simply drops 2 or 3 of each item on the ground and the task is completed (or trigger is fired). i remember a mission had something similar, you had to mark a downed chopper with a strobe and then CAS came in and destroyed it. i pretty much need to detect if a player drops a certain amount of objects in a location, simply dumping them from the inventory ideally however, if somebody has a work around ill be glad to try it. this whole scenario has to be mp compatible as well. i found this code while searching and modified it but it didnt work and i doubt its MP compatible. (player in this) and ("arp_objects_boxmre_m" in Magazines Player) anyways, any help is appreciated, thanks guys :) Share this post Link to post Share on other sites
2nd ranger 282 Posted May 18, 2013 (edited) This used to be a pain in the ass because you'd have to check the contents of the groundWeaponHolder when you dropped the item, but they recently added "Take" and "Put" eventHandlers for this (there is a bug ticket for "Take" not working properly though). After a quick test, the "put" event seems to work pretty well. In this example I must drop 3 MX mags within 5m of a unit called theGuy. A hint appears telling me when I have dropped the correct item, and another tells me when I have dropped the required amount. itemsDelivered = 0; [color="#B22222"]//--- global variable checking how many mags I have dropped.[/color] player addeventhandler ["Put",{ _player = _this select 0; [color="#B22222"]//--- player who dropped something[/color] _object = _this select 1;[color="#B22222"] //--- physical location of the dropped object[/color] _type = _this select 2; [color="#B22222"] //--- item classname[/color] if ((_object distance theGuy) > 5) exitwith {}; if (_type == "30Rnd_65x39_caseless_mag") then {itemsDelivered = itemsDelivered + 1; hint "item delivered!"}; }]; [color="#B22222"] //--- now checking when enough mags have been dropped near him.[/color] [] spawn { waituntil {itemsDelivered == 3}; hint "You gave all the things to the guy!"; }; Edited May 18, 2013 by 2nd Ranger Share this post Link to post Share on other sites
thedog88 4 Posted May 18, 2013 oh wow this seems perfect. im going to give it a shot in a bit and report back. is this simply executed via sqf or how would i implement this? right now i have an addaction on a civi "talk to civi" which triggers a sqf for the conversation and also gives the player the task. could i just throw it in there or would i have to fire this one separately somewhere else? Share this post Link to post Share on other sites
sturmfalkerda 8 Posted May 18, 2013 Wow, nice script, I have a question, will this work on not valid things..?? I have ITEMNULL as a item in my loot script to lower the spawnrates on all items, but the wierd thing is they drop blank items that dont weigh anyything, lol, so I was going to do this so people could help the server by bringing the items back.... that or remove the wierd objects somehow lolol would this work? hint "You gave all the things to the guy!"; _player execVM "Whateverthenameofmycharactercustomizationscriptis.sqf"; **EDIT** realised this is a bit of a hijack.... I also was going to ask if my player peram is correct.... Share this post Link to post Share on other sites
2nd ranger 282 Posted May 18, 2013 oh wow this seems perfect. im going to give it a shot in a bit and report back. is this simply executed via sqf or how would i implement this? right now i have an addaction on a civi "talk to civi" which triggers a sqf for the conversation and also gives the player the task. could i just throw it in there or would i have to fire this one separately somewhere else? Well, you could put it in the action script as long as you've sorted that out for MP compatibility. Actions are local to the player who called them, so unless you're broadcasting the effects of the action to everybody, only the player who initiated the action will see the conversation and get the task. If you haven't already you should check out BIS_Fnc_MP for that. The check part should probably be run on the server, perhaps from the init file, like this itemsDelivered = 0; [color="#B22222"]//--- global variable defined for everyone[/color] if (isServer) then { [color="#B22222"]//--- script checking the items running only on the server[/color] [] spawn { waituntil {sleep 1; itemsDelivered == 3}; sleep 1; hint "You gave all the things to the guy!"; }; }; Then you could use publicVariable each time itemsDelivered is increased in the main script, so that you can use a trigger to detect when the task should be complete, for example. There are various ways to make sure it works properly in MP, but it depends how you have the action script set up, really. Share this post Link to post Share on other sites
thedog88 4 Posted May 18, 2013 yeah the way its setup is that the player firing the action gets the conversation (no sense for the whole server to hear that) and then the task is given to all players through the init. once the task is complete a trigger is fired completing the task for everybody. Share this post Link to post Share on other sites