Jump to content
Blitzen88

Getting classnames of all units and pasting it to clipboard

Recommended Posts

Is there a way to get the classname of all the units placed on a map (in particular vehicle crew members) via some sort of script?

 

I am aware of the typeof and getdescription commands but I dont know how to convert the return into something that is copied to the clipboard, etc. 

 

Im trying to pull the classnames of a large amount of crew members and I thought there had to be a more efficient approach than going one-by-one. 

  • Like 1

Share this post


Link to post
Share on other sites

use the find function and pull things out selectively ...its pretty tedious parsing names but worth it

Share this post


Link to post
Share on other sites

triggerCrew.sqf

 

Spoiler

_triggerList = allUnits inAreaArray "ladyS";
 

_wordo = '...SO...\n' ;
hint (str _wordo) ;
{

_carX = vehicle  (_x )  ;
_wordo = _wordo + (str (_carX)) + ' ... ' + ( str ( _x) ) + '\n'; 

_selecto = ([_x] select 0) ; 
_wordo = _wordo + (str _selecto) + '...\n' ;

_getV = fullcrew _carX ;
_wordo = _wordo + (str _getV) + '._._.\n' ;
_getD = _getV select 0 ;
_getDD = _getD select 0 ;

_getCar = _carX  ;


_namD = name _getDD ; 

//doGetOut _getDD  ;

[_getDD]  join grpNull ;
_dog = (group _getDD) ;
_getDD  assignAsGunner _getCar  ;

_dog addVehicle _getCar  ;
[_getDD] orderGetIn true;
sleep 3 ;
[_getDD] join bobby ;

_wordo = _wordo + (str _getDD  ) + '.x.x.\n' ;
_wordo = _wordo + (str _namD   ) + '.JK.\n' ;

} forEach _triggerList  ;
hint (str _wordo) ;

use this to help you control the units in a vehicle stuck as drivers in a marker zone... 
or create your own marker and call this one out...just study how arrays are accessed by getting

the first element as an array itself...which is confusing

Share this post


Link to post
Share on other sites
53 minutes ago, bLAcKmAgE87 said:

use the find function and pull things out selectively ...its pretty tedious parsing names but worth it

I dont get what you linked? I will try to keep looking at it. I have improved by scripting knowledge but Im still a beginner. 

Share this post


Link to post
Share on other sites

Missed a closing bracket on first element 😉

copyToClipboard str ((entities [["Man"], [], true]) apply { typeOf _x });

Apply is one of those commands I always forget about, so useful!

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, Blitzen88 said:

I dont get what you linked? I will try to keep looking at it. I have improved by scripting knowledge but Im still a beginner. 

 

basically the sqf just takes the names from _treesPlants = ["CUP_b_","CUP_c_","CUP_p_","CUP_t_f","CUP_t_p"] and 

searches all the configs for those tags. 

Then it spawns a forest. Sorry about all the weird math in there. 

 

[_treesPlants] execVM "theForest.sqf";  

 

could be rewritten to return the list of all of those objects ...such as "Man".
Then use the first sqf in a way to initiate those specific objects in a second bet. 

However... i'd rather look for more specific details than specific tags. And run off them right away. 

58 minutes ago, Harzach said:

Missed a closing bracket on first element 😉


copyToClipboard str ((entities [["Man"], [], true]) apply { typeOf _x });

Apply is one of those commands I always forget about, so useful!

 


...that's something new to learn for my mod. 
 

Share this post


Link to post
Share on other sites
8 hours ago, Harzach said:

Missed a closing bracket on first element 😉


copyToClipboard str ((entities [["Man"], [], true]) apply { typeOf _x });

Apply is one of those commands I always forget about, so useful!

 

I will give this a try. Thank you. 

Share this post


Link to post
Share on other sites
27 minutes ago, Blitzen88 said:

I will give this a try. Thank you. 

 

It's @dreadedentity's code from his post above

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, Harzach said:

 

It's @dreadedentity's code from his post above

I dont know what Im doing wrong.

 

I put the code into a script, executed it via a radio trigger, opened notepad, tried to paste and nothing happened.

Share this post


Link to post
Share on other sites

Works fine here, but you've added multiple points of possible failure. Just run this in the debug console:

_classes = ((entities [["Man"], [], true]) apply { typeOf _x });
hint str _classes;

 

Share this post


Link to post
Share on other sites

Run

allUnits apply {typeOf _x} 

in debug console and the output will show up below. There you can select it with mouse and use ctrl+c

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, _foley said:

allUnits apply {typeOf _x} 

 

 

Yes, even simpler!

 

copyToClipboard str (allUnits apply {typeOf _x});

 

  • Like 1

Share this post


Link to post
Share on other sites

Ok... so I'm gunna use the  type property to get every single vehicle (1) or unit (0) to make "The Matrix" with a virtual scenario with everything there. I just need to get it so that I can check it from the from config files. 
I guess that's why I like this post so much.
The typeOf function can return the explicit type while the type property returns the implicit type. Or both are implicit.
 Because I can start my script using my script and your deal too. I'll parse through some properties and get back to ya. 
https://community.bistudio.com/wiki/apply ----> Take every unit (allUnits)... and put them back in the array as a type. Much cheaper than my parsing. Cool thx!

Edited by bLAcKmAgE87
oh

Share this post


Link to post
Share on other sites

if you want to get rid of the duplicates then you can use:
 

_types = [];

{
 _types pushBackUnique (typeOf _x);
} forEach allUnits;

copyToClipboard str _types;

or

 

_types = allUnits apply {typeOf _x};
copyToClipboard str (_types arrayIntersect _types);

I guess there are speed differences between both solutions but I dont like to test it^^

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites



ok...so this one creates a entire array of whatever vehicles you got... just save the the sqf in your mish folder and run off using init.sqf ... or run with the ingame debugger while in editor and playing. 
You should be able to literally walk around all the tanks copters and planes or what not... 
hopefully this helps you and I script some more


...also...it copies to the clipboard...
To view the array...or list really...

I create a html page and paste everything into a text...
that is...
I create a text file and wait... and use the replaceall function on ',' or commas you can say... then replace with <br>...
then I save a text file as .html using the" <html><p>#YOURPASTE </p></html> " as the only text in between my ""s.... #YOURPASTE is the clipboard part....

paste in there and run the html to see the list your working with...that's how i got it all goin
 

https://steamcommunity.com/sharedfiles/filedetails/?id=2793505357
https://steamcommunity.com/sharedfiles/filedetails/?id=2793517490
there now you believe me
https://steamcommunity.com/sharedfiles/filedetails/?id=2793614006

Share this post


Link to post
Share on other sites
On 4/12/2022 at 5:48 AM, sarogahtyp said:

if you want to get rid of the duplicates then you can use:
 


_types = [];

{
 _types pushBackUnique (typeOf _x);
} forEach allUnits;

copyToClipboard str _types;

or

 


_types = allUnits apply {typeOf _x};
copyToClipboard str (_types arrayIntersect _types);

I guess there are speed differences between both solutions but I dont like to test it^^

I will try these out.

 

Edit: Will this return classnames for vehicles?

Share this post


Link to post
Share on other sites
1 hour ago, Blitzen88 said:

I will try these out.

 

Edit: Will this return classnames for vehicles?

Replace "allUnits" with "vehicles" and it will 😉

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

×