jshock 512 Posted April 14, 2014 Hello Scripting Community, I'm trying to set up a range that leaves marking dots where the targets are hit, but then have the ability to clear the range of just those markers. I have it all setup in my head but can't get to understanding how to count a specific object within the list of the trigger or within the confines of a defined array with more than just one type of object present, I know what to do after that, but how can I get there. The object classname is: "Sign_Sphere10cm_F" I have an eventhandler on each target: this addEventHandler ["HitPart", {_spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3);}]; And I was thinking of listing the objects within a specific trigger area, then pulling out all the objects with the above classname and placing them within an empty array, then doing a simple deletevehicle _array command. Any help is greatly appreciated! Share this post Link to post Share on other sites
Larrow 2800 Posted April 14, 2014 (edited) Hit part returns the shooter, you could place the reference to their own hit markers in an array on their characters. Something like...UNTESTED this addEventHandler ["HitPart", { _spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3); _shooter = _this select 0 select 1; _temp = _shooter getVariable ["hitMarkers",[]]; _temp set [count _temp, _spr]; _shooter setVariable ["hitMarkers",_temp]; }]; Then when ever you need to clean the range for that person { deleteVehicle _x; }foreach (player getvariable ["hitMarkers",[]]); Edited April 14, 2014 by Larrow fixed typo in code Share this post Link to post Share on other sites
AldoUSMC 10 Posted April 14, 2014 Thanks for this Larrow: Putting the following into a targets Initialization Box produces markers upon the target being hit: this addEventHandler ["HitPart", { _spr = "Sign_Sphere10cm_F" createVehicle [0,0,0]; _spr setPosASL (_this select 0 select 3); Adding in the below in addition to the above gives some type of error (nothing in the error box/window) and does not allow the target box to close in editor: _shooter = _this select 0 select 1; _temp = _shooter getVaraible ["hitMarkers",[]]; _temp set [count _temp, _spr]; _shooter setVariable ["hitMarkers",_temp]; }]; Putting the second PHP in a sqf called "deletedots.sqf" and calling it in a trigger via nul = [] execVM "deletedots.sqf"; unfortunately does not clear the dots.... when you say above "you could place the reference to their own hit markers in an array on their characters" Did you intend for the first PHP to be placed within the ini box of a playable unit and not on a target to be shot at ? Regards & Thanks for looking at this issue with us AldoUSMC Share this post Link to post Share on other sites
f2k sel 164 Posted April 14, 2014 It's just a typo getVaraible should be getVariable works fine. Share this post Link to post Share on other sites
AldoUSMC 10 Posted April 14, 2014 It's just a typo getVaraible should be getVariableworks fine. F2k, Thanks...absolutely correct....sry I did not catch that on my own. My next level of exploration is to tie this to an area (target or marker) and then use an object (laptop etc) to reset a series of targets within the confines of that marker/trigger area. In essence: I have two firing lanes.... I fire on targets in lane 1 while someone else fires on lane 2....after I've checked my targets I can clear them on lane 1 but it doesn't disrupt lane 2's target markers. I appreciate the help Gents...very good of you all. Regards AldoUSMC Share this post Link to post Share on other sites
f2k sel 164 Posted April 14, 2014 You may get away with just a single addaction as it should only show for the local player and the markers are stored in players variable space. this addaction ["Reset Markers",{{ deleteVehicle _x; }foreach (player getvariable ["hitMarkers",[]])},0,0,true,true,"","_target distance _this <3 "]; I can't say for sure as I don't do MP scripting. Share this post Link to post Share on other sites
AldoUSMC 10 Posted April 15, 2014 F2k Sel and Larrow, Thank you very much for the above mentorship....we were able to get this working just fine using your above on a Dedicated Server. Nice to have folks like you out here in the world that are willing to help others push through the brain-blocks. F2k Sel: your suggestion worked nicely as a good basic start point for a KD range since each shooter only clears their own targets....multiple people can be firing and scoring, coming and going on the range and not have to worry about disrupting someone else's shooting string by accidentally erasing their fellow shooter's hits. Does require a global somewhere on the map incase a shooter comes...fires...leaves ..and doesn't erase their hits.. Regards and Semper Fidelis AldoUSMC Share this post Link to post Share on other sites
coolfact 10 Posted May 21, 2014 Is it posible to make it global? Share this post Link to post Share on other sites
Cerebos 0 Posted September 20, 2015 Hello all, I dont know if i post in the right topic but my problem seems to be similar After long search all codes are a total fail My goal is to catch 1 random string in mags of player, but this item must belong of a certain class Here is the problem: _typeName = myArray select ([item_of_CfgMagazines >> class] in _mags randomly); // result must be a string ! { if (_x in _mags) then { _config = configFile >> "CfgMagazines" >> _x; _text = getText (_config >> "displayName"); for "_x" from 0 to 0 do { player removeMagazine _x; }; }; } forEach myArray; This code work but remove all items of the same class in _mags :angry: Only 1 randomly item selected must be removed ! Is anyone can save me ?? Share this post Link to post Share on other sites
jshock 512 Posted September 20, 2015 A for loop that runs for one iteration is kind of pointless? And what do you mean by a certain class, as in a certain class of magazines or a certain soldier class? Share this post Link to post Share on other sites
Cerebos 0 Posted September 20, 2015 Hi jshock Thanks for the quick reply Yes, this loop select all the elements of myArray, thats the problem! I know all my codes are probably wrong and to be redone And what do you mean by a certain class, as in a certain class of magazines or a certain soldier class? I mean a sub-class of magazines (for items class like drinks, foods, etc etc...) Share this post Link to post Share on other sites