Jump to content
Sign in to follow this  
Grumpy Old Man

Map Objects - is it possible to pass stop signs/park benches to a script?

Recommended Posts

Hey folks,

using the cursortarget I've been biting my teeth out to find a way how to pass certain objects, specifically park benches or stop signs to a script, since they won't give me anything to work with, even when using

hint str cursortarget

Using nearestobjects gives me some .p3d stuff, no idea what to do with that.

Any ideas on how to do this?

Cheers

Share this post


Link to post
Share on other sites

cursortarget doesn't work reliably on remote objects. It's good for debug and for getting when players are looking at particular objects, but if the object is remote to you, ie, an AI in an MP server, it'll likely give you nothing.

nearobjects and nearestobjects is the way forward, as you've found. What you are seeing is objects that don't have a classname. On Altis, you'll get a lot of pollen, insects and footprints so you'll want to disregard them. Set up an array with the p3d names of what you want to filter for, so in your case the p3d of the benches and signs, then check to see if your nearobjects individual elements are in your array.

By the way, unless you really need to sort these objects into distance from your reference, or if you're checking large radii, you should use nearobjects instead of nearestobjects as the latter sorts the results by distance for you.

Share this post


Link to post
Share on other sites

Awesome,

gonna try it out, didn't think of the array solution, I'll be a happy grumpy old man if this works. ;)

Cheers

Share this post


Link to post
Share on other sites

The in statement is key here, it's powerful and quite cheap on the cpu.

https://community.bistudio.com/wiki/in_Array

I tried the same method in A2 when choosing existing map objects which I wanted to hide IEDs under. It did work, in that I could find and use the objects, but it didn't work in that the objects attenuated the IED explosion and/or were undamagd by it.

I resorted to placing my own 'roadside clutter' objects.

Share this post


Link to post
Share on other sites

Coming back to what I wanted to achieve it seems that benches or phone booths don't even have a p3d name? How is that even possible?

So I guess there's no way to reference to them?

http://i.imgur.com/ickZFxq.jpg (118 kB)

http://i.imgur.com/ElwAzt1.jpg (230 kB)

Been standing right next to a bench and phone booth using the nearobjects command with a range of 15m.

Any other way to at least get the position of these objects?

Cheers

Share this post


Link to post
Share on other sites

Try to lower the radius maybe? You could be unlucky and have all the things 15m be the first part of the array. Perhaps you could also use copToClipboard and check there. Going off a small hint for every objects within 15m is not very reliable.

Share this post


Link to post
Share on other sites

@GOM - I've had issues with nearObjects and these objects. nearestObjects should be much more reliable:

{
   diag_log format ["%1", _x];
} forEach (nearestObjects [player, [], 15]);

Profit :)

Share this post


Link to post
Share on other sites

That did the trick, but I can't seem to find a way how to reference the found object from a script, any hints?

Edited by Grumpy Old Man

Share this post


Link to post
Share on other sites

nearestObjects is the way forward because it finds things that don't have classnames.

If I remember correctly (I'm not at my main PC ATM) it returns p3d names, so you can use those in the scripts.

Share this post


Link to post
Share on other sites

Hello,

For buildings I use this in the console: hint format ["%1", typeOf cursortarget]

And it works fine (not tested with everything in the game).

Share this post


Link to post
Share on other sites

Cursortarget won't detect these types of objects.

This will work but I wouldn't call it efficient.

 Sto = [];
 Fn = { 
 {
   Sto set [_foreachindex,lineintersectsobjs [(eyepos player),(atltoasl screentoworld [0.5,0.5]),objnull,objnull,false,_x]];
    } foreach [1,2,4,8,16,32];
     hintsilent format [" 
     ONLY_WATER: %1,
      NEAREST_CONTACT: %2,
       ONLY_STATIC: %3,
        ONLY_DYNAMIC: %4,
         FIRST_CONTACT: %5,
          ALL_OBJECTS: %6",
          Sto select 0,Sto select 1,Sto select 2,Sto select 3,Sto select 4,Sto select 5];

           switch (true) do {
           case  (["sign", str ( Sto select 1), true] call BIS_fnc_inString) : {player sidechat str ( Sto select 1)};
           case  (["bench",str ( Sto select 1), true] call BIS_fnc_inString) : {player sidechat str ( Sto select 1)};
           case  (["phone",str ( Sto select 1), true] call BIS_fnc_inString) : {player sidechat str ( Sto select 1)};// not tested

           };      
            };

             ["sample_id","onEachFrame","Fn"] call BIS_fnc_addStackedEventHandler;

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×