madrussian 347 Posted August 11, 2017 Hopefully this should be a no-brainer, but I’m quite stuck atm. I need to assemble a list of all owner IDs (or any type of IDs) for all machines in a MP game. The trick is, my code is operating in Pre-Init space (as in, prior to “init.sqf” kicking off), via (added to "description.ext" per CBA documentation): class Extended_PreInit_EventHandlers { BubMission = call compile preprocessFile "XEH_preInit.sqf"; }; Why punish myself and attempt to tackle Pre-Init space? Spoiler In brief, I’ve written a Faction Selections utility that parses the configs for all units and vehicles, reconciles the results between the server and the clients, and creates series of CBA Settings where you can select your desired factions for the mission. Works great (on SP, HS, and DS), but so far it only works once you’re in-mission. I’d prefer to assemble the lists and such Pre-Init, so players can select the factions in the MP Briefing Screen (which operates Pre-Init). (Btw- Funny thing is, I just recently noticed you can access CBA Settings from MP Briefing Screen. Wish I saw that before I spent a week pulling my hair out, making all this work in-game. Lol, now I get to rewrite about 1/3 of my code getting this accessible from MP Briefing Screen too.) I’ve worked out how to get all this (see spoiler) working in the unscheduled environment of Pre-Init, except for one key detail: I need to assemble a list of all owner IDs on the server (or even a simple machine count), so I know when all the clients are done reporting in. The trouble is, in Pre-Init, there are no units yet. In other words, in PreInit the allUnits command returns an empty array (which btw strikes me as rather awesome… don’t you think? A world with no units, vehicles, and for that matter no insects, devoid of… well anything. Also time stands still, as in time command continuously returns 0. Ha, Arma’s Twilight Zone!) Normally, you can generally just spin through allUnits (and check isPlayer) to count the number of machines. This obviously won't work here, again due to no units. Turns out in Pre-Init space, remoteExecCall works great, so I can have all Clients report and count them on the Server. The trouble is, without a machine count I have no idea if any particular Client reporting in is the last one, or if more are coming. Any way to count “players” before they embody units? Or count the number of “players” signed into your game? (The game must know all player info in MP even at this stage, obviously because it has to transmit the mission to the Client machines, etc.) Anyone have any insight? It occurs to me there must be a way. Thanks for reading. Share this post Link to post Share on other sites
killzone_kid 1329 Posted August 11, 2017 https://community.bistudio.com/wiki/playersNumber 1 Share this post Link to post Share on other sites
madrussian 347 Posted August 11, 2017 Awesome killzone_kid, that should do it! EDIT: Opps, I spoke too soon. Again thanks for the idea, didn’t quite work though (of course I could always be missing something). EDIT2: This will work (with compromises... see below) Share this post Link to post Share on other sites
madrussian 347 Posted August 12, 2017 Command playersNumber simply returns the number of slots (per wiki). I tested this to be sure, and indeed with 2-slot mission and one single machine running Hosted Server MP game (with no other machines connected), thus with just 1 of the 2 slots occupied, playersNumber returned 2. I need to tally the actual number of total machines. In the example above that again would be 1 total machine (the hosted server) running 2-slot mission. Any ideas? Share this post Link to post Share on other sites
killzone_kid 1329 Posted August 12, 2017 Uncheck Enable AI Share this post Link to post Share on other sites
madrussian 347 Posted August 13, 2017 So, I was reluctant to uncheck Enable AI because my entire mission revolves around player-led AI groups. However, the initial “lobby” units in my mission are actually just placeholders anyway, and each player has selectPlayer called on his machine for player to embody his first real playable unit (which happens after the config scan, faction selection check, etc). All the initial placeholder guys get deleted quickly anyway. Long story short, yes for my particular mission playerNumbers will work! Having to uncheck "Enable AI" in not ideal though. When I open any MP mission I quickly notice one of two things: Grey “Nobody” in all the slots - This typically indicates a player-only MP game, probably with revive, and most likely with absolutely no AI in the player groups. (I quickly close these missions because I prefer traditional co-op) Red “AI” in all the slots - This typically indicates traditional co-op, AI will fill out the slots, possibly group-respawn. I also assume that if I’m the only one playing, I should pick first unit so I can lead the AI group. (This is my type of game and I continue and check it out!) So at the moment I am stuck making a mission that’s all about players leading groups of AI, but upon opening the mission it will appear to players to be a player-only MP game (due to all those grey “Nobody”s). Imo, would be nice to have a command that simply counts connected machines! Or an alternative syntax for playersNumber, that provides count of player-occupied slots only (instead of counting player & AI occupied slots). Anyhow, thanks again for the help… I can proceed. In the mean time, if anyone knows a way to count machines in PreInit space (and keep "Enable AI" checked), I'm all ears. Share this post Link to post Share on other sites