Home   Help Search Login Register  

Author Topic: Grabbing a laser  (Read 1087 times)

0 Members and 1 Guest are viewing this topic.

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Grabbing a laser
« on: 24 Dec 2008, 05:07:47 »
How does one go about grabbing a designator's laser target and saving it as a variable/in an array?

Or am I a dog just chasing the laser pointer dot?   :D :P

Luke
Pesky Human!!
Wort Wort Wort.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Grabbing a laser
« Reply #1 on: 24 Dec 2008, 11:41:55 »
Use nearObjects to detect objects of types "LaserTargetC", "LaserTargetE" or "LaserTargetW".

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Grabbing a laser
« Reply #2 on: 26 Dec 2008, 02:11:59 »
In my idiocy I still can get it to work,\.

two things:
Can you search for just "LaserTarget" without a side?
and
Can someone give a script for my to do this?

I cant make it work for the life of me. :weeping:

Luke
Pesky Human!!
Wort Wort Wort.

Offline ModestNovice

  • Members
  • *
Re: Grabbing a laser
« Reply #3 on: 26 Dec 2008, 02:29:32 »
try something like:

init.sqf
Code: [Select]
LaserCheck =
{
private ["_laserPos"];
_source = _this select 0;
_weapon = _this select 1;
_ammo = _this select 4;

if (_weapon == "Laserdesignator") then
{
LaserTarget = objNull;

_laser = nearestObject [_source, _ammo];

while {!isNull _laser} do
{
_laserPos = getPos _laser;
Sleep 0.001;
};

_targets = nearestObjects [_laserPos, ["LaserTargetC", "LaserTargetE" , "LaserTargetW"], 1.5];
_target = _targets select 0;
LaserTarget = _target;
//Now you can use LaserTarget in other scripts or stuff
hint format ["%1",LaserTarget];
};
};

player addEventHandler ["Fired", {_this spawn LaserCheck}];
"The road became empty and the people disappeared. The clouds ran away; opened up the sky, and one by one I watched every constellation die."
- Sean "Slug" Daley