Sorry for the lack of posts recently. It is not that I have no content to post, I have tonnes. I’ve been quite busy (and still am) with other things + the ISP terrorist engineers deprived me of my Internet for a few days, which kinda messed things up. But first of all I’d like to say big thank you (спасибо) to Nazar, for another donation! You’re spoiling me, Nazar :)

Anyway, today I’m going to release another extension I made. Quite recently BIS added new command – squadParams, which makes content of squad.xml file available to mission makers. TBH I am not too fast about squad.xml implementation. I think in 2014 the whole process should be a bit less painful. It has some potential and I was going to test something, but then I remembered Steam had a nice API and one of the functions was to retrieve friend list for any user (provided the user profile is not private).

Consider this. You can already join friend’s game from Steam. With a bit of further tweaking you can put the player with his friend in the same squad upon player joining the server. What you need is to know who is friend with whom. And this is where Steam API comes handy. The IDs API operates with are the same UIDs available in Arma 3 (not Arma 2) with getPlayerUID command or via _uid var in onPlayerConnected.

So I took my url_fetch extension and modified it to retrieve friend list for passed UID from Steam. How does it work? Due to security limitations, the extension has to be server side. So when player joins the server you can just go ahead and feed extension the player UID like this:

onPlayerConnected { "get_friends" callExtension _uid; };

onPlayerConnected will execute only server side by default if placed in init.sqf for example. The extension will contact steam API and retrieve (or not :) ) the friend list for this user and store it internally. If you call the extension again, for example:

_result = "get_friends" callExtension getPlayerUID (playableUnits select 0);

you will either get “WAIT”, if fetching is still in progress, or “[]” if fetching failed or player has private profile or has no friends, or something like this if everything is fine:

[ "76561197965565385","76561197977088328","76561197979284389", "76561197983917529","76561197990835078","76561198007489546", "76561198009320375","76561198013020910","76561198018221755", "76561198023999280","76561198025492474","76561198034167818", "76561198035333552","76561198063488310","76561198065555502", "76561198071941786","76561198072809368" ]

It will be a string obviously, so needs call compile to become array. Steam allows something like 300 friends. I did some calculation and with extension output limit of 10K, 300 UIDs can currently fit in a single output. I might make some extension handling examples later on.

The “[]” result is quite vague, so for debugging purposes only you can call extension with “ERROR” to see the last error.

_result = "get_friends" callExtension "ERROR"; //DOWNLOAD FAILED

If result is “[]” and last error is “” this would mean player has no friends. Because “[]” could also mean something went wrong with internet connection, if you call extension again with the same UID it will try to fetch friend list again. When the result is successful it will be permanently stored inside .dll until you either restart the server or clear internal .dll memory with “CLEAR” command:

_result = "get_friends" callExtension "CLEAR"; //123

The number returned will indicate how many results were in memory before it got cleared. On very long running servers it could be particular useful to clear results from .dll memory. “ABOUT” will return some about information with version number.

What you need to get it running? VS2013 redistributables (check url_fetch page for more info). Download get_friends v1.0, unzip and drop the .dll next to arma3server.exe on the server.

Enjoy,
KK

EDIT: Thanks to Soul for his comment (below), it looks like Arma 2 has been updated to Steam ID system, so this extension should now be compatible with A2 as well.