Jump to content
Sign in to follow this  
ablueman

List players on a server - mp command

Recommended Posts

Can you use a command to list all the online players on the server, so i can do an if statement on them.

Anyone know if there is a way to easily do this. The idea is to see if any clan members are on.

If so have a lock / unlock script on the MHQ (to stop the noobs driving it in to the red zone) but unlock it if there are no clan members on the server. I can handle this part but i have no idea how to list the players online.

Share this post


Link to post
Share on other sites

You can do the list by names or playerids. Variable called "playableunits" will have all the units that are player/playable in a MP mission. It will include AIs as well.

One, pretty simple, solution would be to just have everyone tell you their player id (from the profile menu). Make an array from them.

myClan = [123,34252,2553];

Then you can check the player in a script:

if (call compile format ["%1 in myClan",getPlayerUID player]) then {

hint "this one is my buddy";

};

Or, you can forget changing the IDs from strings to numbers and just do:

myClan = ["123","34252","2553"];

if (getPlayerUID player in myClan) then { };

PS: You do personalized weapon loadouts with IDs as well ;)

Share this post


Link to post
Share on other sites

gotta say, shk, liking you being around :) your VERY helpful and you give me ideas haha.

im going to be using this very soon thanks :)

Share this post


Link to post
Share on other sites
;)

Yeah im already doing something like that: http://forums.bistudio.com/showpost.php?p=1489412&postcount=7

The idea is that while WBG present addAction lock MHQ see script in above link, if WBG not present unlock MHQ. I will look more in to playableunits and see what I can come up with. Thanks.

--Edit --

Nice to see http://community.bistudio.com/wiki/playableUnits is so detailed >.<

Edited by ablueman
Update

Share this post


Link to post
Share on other sites

Well, playableunits hold all the units that are alive and are set as player or playable in editor. Dead and those slots that have AI disabled are not included. It's basically identical in working to "units group" command. Meaning, the list will update once the leader knows that an unit is dead.

It will return empty in SP and in editor preview.

myClan = ["111","222","333"];
_lock = false;
{
 if (getplayeruid _x in myClan) then { lock = true };
} foreach playableunits;

Edited by Shuko

Share this post


Link to post
Share on other sites

Ok tested with

if (wbg == 0) then
{
hint "UNLOCK THE MHQ";
} forEach playableUnits; 

This works, but I have a feeling this will only be checked on init.sqf so usefull as a chocolate teapot.

Do I need to create a loop to constantly check or is it better to do on connect / on disconnect check... ?

ohh posted at same time : Im using this for domination does that mean each time WBG member dies if hes the only wbg member on, the MHQ will unlock and relock when he respawns? ps: wbg is just the variable i have which sets to 1 if someone is a wbg member or 0 for not.

BTW im not using an array im using a switch. Im still struggling to get to grips with providing the same functionality of my switch statements with an array. Check that link if you have time bud. http://forums.bistudio.com/showpost.php?p=1489412&postcount=7

Edited by ablueman

Share this post


Link to post
Share on other sites

Too late for my brain, good luck. ;)

Hope the playableunits helped.

Share this post


Link to post
Share on other sites
Too late for my brain, good luck. ;)

Hope the playableunits helped.

hahah dont abandon me now :) ok bud thanks for your help will keep trying

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  

×