t.a.6 7 Posted February 9, 2016 And that://_this select 6 = throwed item; waituntil {(str (_this select 6)) == ""}; or waituntil {isnull (_this select 6)}; |"generic error in expression". (urrrhhhmm) Share this post Link to post Share on other sites
dreadedentity 276 Posted February 9, 2016 I'm not sure what your post is referencing, but "thrown" items like grenades will trigger a "fired" event handler. Not sure about placed objects, like mines. It looks like you are already using a fired EH so there's one issue can definitely see. Event Handlers run in an unscheduled environment, in which commands like sleep, uiSleep, and waitUntil cannot be used. If you try to use any of those commands in an unscheduled environment, you will get a "Generic error in expression" error, as you have seen. Share this post Link to post Share on other sites
t.a.6 7 Posted February 9, 2016 I'm not sure what your post is referencing, but "thrown" items like grenades will trigger a "fired" event handler. Not sure about placed objects, like mines. It looks like you are already using a fired EH so there's one issue can definitely see. Event Handlers run in an unscheduled environment, in which commands like sleep, uiSleep, and waitUntil cannot be used. If you try to use any of those commands in an unscheduled environment, you will get a "Generic error in expression" error, as you have seen. Thank you, and the first question is- `"addaction" on throwed items do not working, how to make it? Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted February 10, 2016 The following code works, when I replace the projectile with any other object, but I can't seem to find a way to get the action show up on the (smoke) grenade / light stick. player addEventHandler ["Fired", { _projectile = _this select 6; _projectile addAction ["Pickup this object", { _params = _this select 3; deleteVehicle (_this select 0); hintSilent _params; }, "You have picked up this object", 3, false, true]; //the following is just for visual tracking purposes _ehCounter = player getVariable ["ehCounter", 0]; _ehName = format ["eh_throw_%1", _ehCounter]; player setVariable ["ehCounter", _ehCounter + 1]; _arrow = createVehicle ["Sign_Arrow_Large_F", getPosATL _projectile, [], 0, "CAN_COLLIDE"]; [_ehName, "onEachFrame", { if (alive (_this select 1) && time - (_this select 3) < 10) then { (_this select 0) setPosATL getPosATL (_this select 1); } else { deleteVehicle (_this select 0); [_this select 2, "onEachFrame"] call BIS_fnc_removeStackedEventHandler; }; }, [_arrow, _projectile, _ehName, +time]] call BIS_fnc_addStackedEventHandler; }]; Share this post Link to post Share on other sites
t.a.6 7 Posted February 10, 2016 Is it possible to determine position of the item? (for like adding action to player if he are close enough or watching on or add some invisible object and add action to). Share this post Link to post Share on other sites
dreadedentity 276 Posted February 10, 2016 Is it possible to determine position of the item? (for like adding action to player if he are close enough or watching on or add some invisible object and add action to). You have to do something similar to this, I've used this in the past as a test, but never had an actual reason to use it. A better way to do it would be to add an action to the player through the use of the event handler, and pass the projectile to the addAction: //requires a global array THROWN_OBJECTS = []; player addEventHandler ["Fired", { //filter out all input that is not thrown if ((_this select 1) == "Throw") then { _proj = (_this select 6); //save thrown object to global array and save index # to be used in the addAction condition _index = THROWN_OBJECTS pushBack _proj; (_this select 0) addAction ["Hold grenade", { _target = _this select 0; _arg = _this select 3; //upon using the action, attach the thrown object to the player 2m in front, and 1m above (makes it waist height) _arg attachTo [_target, [0,1,1]]; }, _proj, 6, false, true, "", format ["THROWN_OBJECTS select %1 distance _target < 5", _index]]; }; }]; "Dead" grenades (exploded grenades, or smoke grenades that are out of smoke) are automatically turned into objNull, can be removed from the array using: THROWN_OBJECTS = THROWN_OBJECTS - [objNull]; However, this offers no benefit, as it breaks existing actions due to the way it's condition works (expecting a certain element to exist, removing array elements will mess up all active action conditions). You'll have to keep track of all objects, all actions, and delete/reassign them every time you delete one. Much more work than it's worth as the current code works perfectly and offers no script errors, the objNull distance checks all fail silently. Note this works with explosive grenades, and it's pretty funny to think that someone would pick up a live grenade and hold it until it explodes, killing them. Tested with explosive grenades, smoke grenades, and chemlights. All work Share this post Link to post Share on other sites
t.a.6 7 Posted February 10, 2016 Thanks but i actually knew all of it. The thing i want is like: 3d explosive interface , if someone can revive the script it would be great. 1 Share this post Link to post Share on other sites