OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: nEO iNC on 06 Feb 2008, 10:50:19
-
Hey,
I'm trying to figure out a way of determining the distance a shell flies when fired. ???
Any help appreciated.
Cheers
-
This should work:
// myshells.sqf
private["_myshell", "_pos_shell"];
_myshell = _this select 0;
if (local (_this select 1)) then
{
while {!isNull _myshell} do
{
_pos_shell = getPos _myshell;
Sleep 0.001;
};
hint format["Distance: %1m", ((_this select 1) distance _pos_shell)];
};
//init.sqf
myunit addEventHandler ["Fired", {[(nearestObject[_this select 0, _this select 4]), _this select 0] execVM "myshells.sqf"}];
-
Nice one Mandoble...! :good:
Will give that a try later...
Thanks for the quick response...
-
Hey Mandoble,
Tried your code but it doesn't appear to work... :(
Just seem to get a 'nothing' value reported when the gun fires.
eg. Distance: SCALARM
Any ideas what might be causing this..?
-
nEO iNC, do not post consecutively.
A couple fo days should pass first, if you have something to add after a short period of time modify your post instead of replying to yourself.
Just seem to get a 'nothing' value reported when the gun fires.
You don't get the error message?
Gives me an 'Generic error in expression'
Error Generic error in expression
Suspending not allowed in this context
Error in expression <shell } do
{
_posshell = getPos _shell;
Sleep 0.002;
};
hint format["Distance: %>
Error position: <Sleep 0.002;
}; :dunno:
-
Code corrected above, now you'll get a more or less accurate value.
-
h-, apologies, won't happen again...
Mandoble, thanks again... Appreciated...