Jump to content

Trying to get number of clients.


Go to solution Solved by Grimes,

Recommended Posts

Posted

Hi,

 

I trying to do something simple to get the number of clients.  I found the following MIST command mist.getUnitsbyAttribute().  Per the description on the Hoggit page, 

list = mist.getUnitsByAttribute({skill = 'Clients', coalition = "blue"}, 2, true)

should return a list of client IDs in the blue coalition.  I think this is a table, and the I use the "#table" to get the count of clients.  Or at least that is my thought.

 I have tried this (simple MP mission with just me in it) with the following script and it just returns "0".  I do load MIST first and then run this 10 seconds and 30 sconds after the mission starts.  

-- Simple test using MIST to get number of clients
local list = mist.getUnitsByAttribute({skill = 'Clients', coalition = "blue"}, 2, true)
local Num_Clients = #list
trigger.action.outTextForCoalition(2,"The current number of clients are: " ..  Num_Clients, 15)     -- Output snumber of clients


What ALL am I missing?  Do I need have MIST generate a table first?

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

  • Solution
Posted

The skill as saved in the DB is "Client" not "Clients". You should also be able to pass "human" as a skill value and it will include any aircraft set to player and client. 

Me being me not using my own functions that I write you can easily get it from iterating a table yourself. 

local list = {}
for uName, uData in pairs(mist.DBs.humansByName) do
   if uData.coalition == 'blue' then
      table.insert(list, uName)
   end
end

 

 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted

Thanks a lot for the FAST response!!

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

Posted
14 hours ago, Grimes said:

The skill as saved in the DB is "Client" not "Clients". You should also be able to pass "human" as a skill value and it will include any aircraft set to player and client. 

Me being me not using my own functions that I write you can easily get it from iterating a table yourself. 

local list = {}
for uName, uData in pairs(mist.DBs.humansByName) do
   if uData.coalition == 'blue' then
      table.insert(list, uName)
   end
end

 

 

Thanks again for this.  Gives me something to pick apart and learn from.

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

Posted

Hi AKA_Clutter,

Grimes and others helped me develop some client detection scripts that I use a lot.  See the scripts in the attached doc.  

Most of the time I use the client detection to initiate the action in my missions... 

Enjoy!

WC's Script & Mist Examples.lua

Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.

  • 2 weeks later...
Posted
On 4/14/2023 at 9:01 AM, Wrecking Crew said:

Hi AKA_Clutter,

Grimes and others helped me develop some client detection scripts that I use a lot.  See the scripts in the attached doc.  

Most of the time I use the client detection to initiate the action in my missions... 

Enjoy!

WC's Script & Mist Examples.lua 33.68 kB · 4 downloads

Hi Wrecking Crew.  

Sorry for the late reply.  Thanks for sharing.  I worked up something based on Grimes reply and it seems to work, but doesn't seem to be as elegant as yours.

 

I will look at yours as it does a lot more than mine, and I know I can learn some lua in doing so.

Thanks again.

Clutter

 

 

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...