Results 1 to 8 of 8

Thread: Displaying name of a unit closest to an object.

  1. #1

    Displaying name of a unit closest to an object.

    Hello,

    I have a mission with 1 objective so far, the objective is to find a satellite phone, and then tap the phone. I have the satellite phone set to appear at a random location within a building.

    I would like the player who "found" the phone to be displayed in a hint, I know somewhat how to do this, I have a trigger set up like this...

    Name: obj1trigger

    Activation: Any group member

    Condition:

    Code:
    this and player distance phone1 <= 2.5
    Activation:

    Code:
    hint format ["%1 has discovered a satellite phone", name ((list obj1trigger) select 0)] ; phone1 addAction ["Tap satellite phone", "tap_phone.sqf"]
    When the trigger is activated, a name IS displayed, but it is not always the name of the player that is closest to the object, can anyone help me display the correct name?

    Thanks,

    -AD

  2. #2
    nearestObjects is what you're searching for. The resulting list is ordered by the distance of each object of given type to given object, means, closest object is the first element in the list, aso.

    I suggest:
    Code:
    count nearestObjects [position phone1,["Man"],2.5] > 0
    as trigger condition, and the activation would be something like
    Code:
    hint format ["%1 has discovered a satellite phone", name (nearestObjects [position phone1,["Man"],2.5] select 0)] ; phone1 addAction ["Tap satellite phone", "tap_phone.sqf"]

  3. #3
    Staff Sergeant
    Join Date
    Sep 29 2008
    Location
    NM, USA
    Posts
    308
    Author of the Thread
    Quote Originally Posted by Bon View Post
    nearestObjects is what you're searching for. The resulting list is ordered by the distance of each object of given type to given object, means, closest object is the first element in the list, aso.

    I suggest:
    Code:
    count nearestObjects [position phone1,["Man"],2.5] > 0
    as trigger condition, and the activation would be something like
    Code:
    hint format ["%1 has discovered a satellite phone", name (nearestObjects [position phone1,["Man"],2.5] select 0)] ; phone1 addAction ["Tap satellite phone", "tap_phone.sqf"]
    Thanks, going to give that a try, I am assuming that the trigger has to now be activated by Game Logic.

    ---------- Post added at 06:14 PM ---------- Previous post was at 04:42 PM ----------

    Quote Originally Posted by Bon View Post
    nearestObjects is what you're searching for. The resulting list is ordered by the distance of each object of given type to given object, means, closest object is the first element in the list, aso.

    I suggest:
    Code:
    count nearestObjects [position phone1,["Man"],2.5] > 0
    as trigger condition, and the activation would be something like
    Code:
    hint format ["%1 has discovered a satellite phone", name (nearestObjects [position phone1,["Man"],2.5] select 0)] ; phone1 addAction ["Tap satellite phone", "tap_phone.sqf"]
    For some reason that isn't working.

  4. #4
    Sergeant Major SNKMAN's Avatar
    Join Date
    Aug 29 2006
    Location
    Germany ( Lake Constance )
    Posts
    1,616
    Well i suggest use a script instead of this ( strange ) on activation line and increase the distance to 5 just to make sure.

    Trigger Condition:
    count nearestObjects [phone1, ["Man"], 5] > 0

    Trigger On Activation:
    Phone1 = [] execVM "Phone1.sqf";

    Phone1.sqf
    Code:
    _objects = nearestObjects [phone1, ["Man"], 5];
    
    hint format ["%1 has discovered a satellite phone", name (_objects select 0) ];
    
    phone1 addAction ["Tap satellite phone", "tap_phone.sqf"];
    Last edited by SNKMAN; Mar 25 2010 at 22:32.

  5. #5
    How big is your trigger detection area?
    LoyalGuard
    Former OFPEC Editors Staff Member | Former ACE1 Dev Team Member
    My ArmA Projects
    "...brain-hurting expressions of realism like Loyalguard’s functioning Chernarus Electrical Grid." -PC Gamer

  6. #6
    Staff Sergeant
    Join Date
    Sep 29 2008
    Location
    NM, USA
    Posts
    308
    Author of the Thread
    Thanks for all the help guys, it works perfectly now.

    @Loyalguard - My trigger covers the entire building where the phone will be, activated by BLUFOR because without that, the OPFOR can accidentally trigger the hint, I have them patrolling the building.

    Thanks again,

    -AD

  7. #7
    Glad to hear it's working...you have a solution so the point is mostly moot, but I was asking because if your trigger covers the whole building that would explain why sometimes the trigger would return someone other than the unit discovering the phone because even though that unit is closest to the phone that unit will not necessarily be the first unit returned in list obj1trigger select 0.

  8. #8
    Staff Sergeant
    Join Date
    Sep 29 2008
    Location
    NM, USA
    Posts
    308
    Author of the Thread
    Quote Originally Posted by Loyalguard View Post
    Glad to hear it's working...you have a solution so the point is mostly moot, but I was asking because if your trigger covers the whole building that would explain why sometimes the trigger would return someone other than the unit discovering the phone because even though that unit is closest to the phone that unit will not necessarily be the first unit returned in list obj1trigger select 0.

    Ya, you're right, that is why I wanted to display the name of the closest player to the object rather than the player that activated the trigger. Due to the phone appearing at a random location then going by an area trigger alone wouldn't really solve it.

    After further testing, I am still having some difficulties with the 2 possible solutions that were suggested in this thread. I am trying some different combinations and when I find a combo that works I will be sure to post what worked here, or else will ask for some more help.

    -AD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •