Jump to content

Recommended Posts

Posted

Hi! It's me again...

 

Is it possible to make a message displaying the composition of a certain group to the player?

 

The group is spawned with some elements of randomization so it may consist of between two and ten vehicles ranging from MBTs to trucks.

 

I want for instance a message for ten seconds saying

 

"Enemy group of 7 vehicles.

1x T-72B

3x BMP-1

3x URAL 375"

 

Is this possible? If so, how?

 

As always, thanks.

Posted

Quick and dirty. May contain errors.

Basically iterate the units in the group and build a table of unit names and count the number of each. Then build a message based on that table.

local names = {}
local units = Group.getByName('whatever'):getUnits()
for i = 1, #units do
local typeName = Unit.getByName(units[i]):getTypeName()
if not names[typeName] then
	names[typeName] = 1
else
	names[typeName] = names[typeName] + 1
end
end

local msg = {}
msg[#msg+1] = "Target consists of " .. #units .. "vehicles \n"
for name, num in pairs(names) do
msg[#msg+1] = num .. 'x ' .. name .. '\n'
end

trigger.action.outText(table.concat(msg), 20)

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

As I said I wrote it fairly quickly so I'm not surprised there was an error. Probably just change the 4th line to this to fix it.

 

local typeName = Unit.getTypeName(units)

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 for trying to help man, you know I appreciate it but I don't say it as often as I should.

 

local names = {}

local units = Group.getByName('Group1'):getUnits()

for i = 1, #units do

local typeName = Unit.getTypeName(units)

if not names[typeName] then

names[typeName] = 1

else

names[typeName] = names[typeName] + 1

end

end

 

local msg = {}

msg[#msg+1] = "Target consists of " .. #units .. "vehicles \n"

for name, num in pairs(names) do

msg[#msg+1] = num .. 'x ' .. name .. '\n'

end

 

trigger.action.outText(table.concat(msg), 20)

 

gave me

 

[string "C:\Users\...\Temp\DCSV~mis000286A"]:4:

Parameter #1 (unit name string) missed

start traceback:

[C]: ?

[C]: in function 'getByName'

[string

"C:\Users\...\Temp\DCSV~mis0000286A":4: in main chunk]

 

EDIT: I FORGOT TO UPDATE THE SCRIPT FILE! IT WORKS!!!

Posted

Does this display the units in the order they are in the group?

 

Bonus question: Is it possible to get the unit ID of say the third unit in a group of five?

Posted

Hey EasyEB,

 

I've scripted such a feature for my missions once before. Basically I added a radio command for players to ask for "Intel on closest enemy vehicles". When fired, it prints out a message saying type of units, number of units, heading and distance (from player group lead) to the closest "cluster" of enemy vehicles.

 

I've recently broken the feature (because it was a part of a project where I changed some core stuff), but I'm quite eager to fix it again. I'll let you know when it is ready :)

 

Here's the output format:

 

4 M-1 Abrams located 9nm N/NE of group lead

 

What do you think of the format?

The current "name" for this feature is "IOCEV" which is ugly af, so I'm looking for suggestions for a different name.

Posted
Hey EasyEB,

 

I've scripted such a feature for my missions once before. Basically I added a radio command for players to ask for "Intel on closest enemy vehicles". When fired, it prints out a message saying type of units, number of units, heading and distance (from player group lead) to the closest "cluster" of enemy vehicles.

 

I've recently broken the feature (because it was a part of a project where I changed some core stuff), but I'm quite eager to fix it again. I'll let you know when it is ready :)

 

Here's the output format:

 

 

 

What do you think of the format?

The current "name" for this feature is "IOCEV" which is ugly af, so I'm looking for suggestions for a different name.

 

I think the output could be shortened a bit and perhaps a little clearer. Perhaps a bit like a BRA call like

 

4x M-1 Abrams bearing 22 for 9 from lead.

 

As for the name, I think GUCK - Ground Unit Call Knowledge. Or perhaps Familiar Unit Call Knowledge.

Posted
I think the output could be shortened a bit and perhaps a little clearer. Perhaps a bit like a BRA call like

 

4x M-1 Abrams bearing 22 for 9 from lead.

 

I agree

 

 

As for the name, I think GUCK - Ground Unit Call Knowledge. Or perhaps Familiar Unit Call Knowledge.

 

:megalol:

Posted
Hi! It's me again...

 

Is it possible to make a message displaying the composition of a certain group to the player?

 

The group is spawned with some elements of randomization so it may consist of between two and ten vehicles ranging from MBTs to trucks.

 

I want for instance a message for ten seconds saying

 

"Enemy group of 7 vehicles.

1x T-72B

3x BMP-1

3x URAL 375"

 

Is this possible? If so, how?

 

As always, thanks.

 

 

Hello. Just have a look at the C4SIR script.

  • Recently Browsing   0 members

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