Jump to content

using the new addgroup function


xcom

Recommended Posts

Hi,

 

I'm trying to use the new addgroup function, can someone give a full example on how to use it?

Couldn't find one in the wiki.

 

The function -

Group function coalition.addGroup
(
enum country.id country,
enum Group.Category groupCategory,
table groupData)

 

I'm trying something like -

 

Group function coalition.addGroup
(
enum country.id "RED",
enum Group.Category "UNIT",
table 
           {
                                       ["alt"] = 1524,
                                       ["type"] = "FW-190D9",
                                       ["unitId"] = 399,
                                       ["psi"] = -2.1777839908415,
                                       ["alt_type"] = "BARO",
                                       ["skill"] = "Average",
                                       ["y"] = 536171.42857143,
                                       ["x"] = -201337.14285714,
                                       ["name"] = "190D9 - 1",
                                       ["payload"] = 
                                       {
                                           ["pylons"] = 
                                           {
                                           }, -- end of ["pylons"]
                                           ["fuel"] = 461,
                                           ["flare"] = 0,
                                           ["chaff"] = 0,
                                           ["gun"] = 100,
                                       }, -- end of ["payload"]
                                       ["speed"] = 138.88888888889,
                                       ["heading"] = 2.1777839908415,
                                       ["callsign"] = 112,
                                       ["onboard_num"] = "10",
           }
)

 

But something is wrong... :helpsmilie:

 

Thanks.


Edited by xcom
  • Like 1
Link to comment
Share on other sites

The documentation shows what the variables are, but not the right way to do it exactly. Here is a corrected version of your example.

local unitTable = {
["units"] = 
{
	[1] = 
	{                
                       ["alt"] = 1524,
                                       ["type"] = "FW-190D9",
                                       ["unitId"] = 399,
                                       ["psi"] = -2.1777839908415,
                                       ["alt_type"] = "BARO",
                                       ["skill"] = "Average",
                                       ["y"] = 536171.42857143,
                                       ["x"] = -201337.14285714,
                                       ["name"] = "190D9 - 1",
                                       ["payload"] = 
                                       {
                                           ["pylons"] = 
                                           {
                                           }, -- end of ["pylons"]
                                           ["fuel"] = 461,
                                           ["flare"] = 0,
                                           ["chaff"] = 0,
                                           ["gun"] = 100,
                                       }, -- end of ["payload"]
                                       ["speed"] = 138.88888888889,
                                       ["heading"] = 2.1777839908415,
                                       ["callsign"] = 112,
                                       ["onboard_num"] = "10",
},
["name"] = dynSpawnGp1
["hidden"] = false

}

coalition.addgroup(country.id.GERMANY, Group.Category.AIRPLANE, unitTable)

Here is another example of a shilka that will spawn approximately randomly inside the zone.

 

local pos = trigger.misc.getZone('spawnZoneA')
local ranpos = {}

ranpos.x = pos.point.x + math.random(pos.radius * -1, pos.radius)
ranpos.z = pos.point.z + math.random(pos.radius * -1, pos.radius)

local data = {
["visible"] = false,
["groupId"] = math.random(10, 20),
["tasks"] = 
{
}, -- end of ["tasks"]
["hidden"] = false,
["units"] = 
{
	[1] = 
	{
		["y"] = ranpos.z,
		["type"] = "ZSU-23-4 Shilka",
		["name"] = string.char(math.random(65,90)),
		["unitId"] = math.random(40, 50),
		["heading"] = 0,
		["playerCanDrive"] = true,
		["skill"] = "Average",
		["x"] = ranpos.x,
	}, -- end of [1]
}, -- end of ["units"]
--["y"] = 650342.85714286,
--["x"] = -292285.71428571,
["name"] = string.char(math.random(65,90)),
--["start_time"] = 0,
--["task"] = "Ground Nothing",
} -- end of [1]

coalition.addGroup(country.id.RUSSIA, Group.Category.GROUND, data)


Edited by Grimes
  • Like 1

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

Link to comment
Share on other sites

Thanks for the examples Grimes, very helpful!

 

Few questions -

1. I saw in the mission file that above the unit itself are the tables for the Waypoints, is it possible to add them as well? if not than which path will the new group take? and is it possible to add a new path?

 

2. Is it possible to add the group in a country that doesn't have the airplane available for selection? I'm asking because in one of my missions, Germany is in the wrong side and therefore I would have to make the mission all over again.

 

3. Not regarding addgroup, is it possible to send groups/units to certain WPs with the script engine?

Planning on sending units to preplanned WPs with flag conditions, but this should be by sending the groups/units to WPs back and forth.

 

Thanks!


Edited by xcom
Link to comment
Share on other sites

1. addGroup() only adds the group to the mission. You have to give them a new mission task after they spawn. This also answers the 3rd question. So yes you can dynamically task AI around.

 

2. Yes. You can do some interesting things..

Screen_130325_183158.jpg

 

 

You can spawn a Mig-29S to Italy and arm it with Aim-120s if you wanted to. But yeah, because spawning is based on the countries that means you can spawn whatever you want to that country. It also means that if a country is neutral you can still spawn stuff in and the unit will be neutral. I'm not 100% sure if that is a purposeful or accidental feature. For instance neutral units will no appear on the map and are truly neutral, AI won't attack them and they won't attack back.

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

Link to comment
Share on other sites

Thanks.

 

I just saw someone add the WPs also, should that work?

http://forums.eagle.ru/showpost.php?p=1738489&postcount=123

If not than how can I add them with a script?

 

Also, You say I can add a mission task, is that possible with scripts or is it better to do with triggers?

 

 

EDIT - I just gave your script a try, I'm getting an error that :30:'}' expected (to close '{' at line 2) near '='.

I tried to fix it, but still doesn't seem to work -

 

 

local unitTable = 
{
["units"] = 
{
	[1] = 
	{                
									["alt"] = 1524,
                                       ["type"] = "FW-190D9",
                                       ["unitId"] = 399,
                                       ["psi"] = -2.1777839908415,
                                       ["alt_type"] = "BARO",
                                       ["skill"] = "Average",
                                       ["y"] = 536171.42857143,
                                       ["x"] = -201337.14285714,
                                       ["name"] = "190D9 - 1",
                                       ["payload"] = 
                                       {
                                           ["pylons"] = 
                                           {
                                           }, -- end of ["pylons"]
                                           ["fuel"] = 461,
                                           ["flare"] = 0,
                                           ["chaff"] = 0,
                                           ["gun"] = 100,
                                       }, -- end of ["payload"]
                                       ["speed"] = 138.88888888889,
                                       ["heading"] = 2.1777839908415,
                                       ["callsign"] = 112,
                                       ["onboard_num"] = "10",
	},
},
["name"] = dynSpawnGp1
["hidden"] = false
},

coalition.addgroup(country.id.GERMANY, Group.Category.AIRPLANE, unitTable)

 

 

 

Thanks


Edited by xcom
Link to comment
Share on other sites

I fixed that problem (There was a missing comma after the [name]) but got a diffrent problem, I'm probebly not running it correctly.

What I did is put that whole script into a file.lua and did DO Script File, is that correct for the script you gave?

 

I tried it with this code and it worked -

 

coalition.addGroup(country.id.RUSSIA, Group.Category.AIRPLANE, {

["units"] =

{

[1] =

{

["alt"] = 1524,

["type"] = "FW-190D9",

["unitId"] = 399,

["psi"] = -2.1777839908415,

["alt_type"] = "BARO",

["skill"] = "Average",

["y"] = 536171.42857143,

["x"] = -201337.14285714,

["name"] = "190D9 - 1",

["payload"] =

{

["pylons"] =

{

}, -- end of ["pylons"]

["fuel"] = 461,

["flare"] = 0,

["chaff"] = 0,

["gun"] = 100,

}, -- end of ["payload"]

["speed"] = 138.88888888889,

["heading"] = 2.1777839908415,

["callsign"] = 112,

["onboard_num"] = "10",

},

},

["name"] = dynSpawnGp1,

["hidden"] = false

})

 

Link to comment
Share on other sites

Last I checked the waypoints are not used when you add them. So you will have to create and set their path after you add the group.

 

You can put it into either a do script or a do script file, both work just fine.

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

Link to comment
Share on other sites

Found a bug - After destroying a plane/vehicle that has been respawned with a similar unit name the message says that a building has been destoyed rather than the new unit name which was put in the script.

 

Also, I noticed that if i had the bf109 mod installed, anyone who joined my multiplayer server and didn't have the mod installed had got connection interupted, despite that there was no unit of bf109 in the mission.

Link to comment
Share on other sites

I've noticed it seems like addGroup only works for the server. Any way around this?

 

What exactly are you spawning that is appearing server side only?

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

Link to comment
Share on other sites

What exactly are you spawning that is appearing server side only?

Infantry units. Georgian Ak47 and RPGs.

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

Just tested it with tanks & an airplane (Su-25T). The tanks didnt work (T72, Shilkas and MTLB) but the airplane did spawn on both server and client... I don't have Combined Arms installed on one of the computers, could that be an issue?

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

I don't want to be "that guy" but I'd really really appreciate some quick help on this. I've spent a few days doing some heavy scripting in a mission for my squads thursday flying and now this issue pops up and I can't figure out how to work around it... :/

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

Sure! ;)

 

coalition.addGroup(0, Group.Category.GROUND, {
                               ["visible"] = true,
                               ["taskSelected"] = true,
                               ["route"] = 
                               {
                                   ["spans"] = 
                                   {
                                   }, -- end of ["spans"]
                                   ["points"] = 
                                   {
                                       [1] = 
                                       {
                                           ["alt"] = 10,
                                           ["type"] = "Turning Point",
                                           ["ETA"] = 0,
                                           ["alt_type"] = "BARO",
                                           ["formation_template"] = "",
                                           ["y"] = 631114.28571429,
                                           ["x"] = -328142.85714286,
                                           ["ETA_locked"] = true,
                                           ["speed"] = 5.5555555555556,
                                           ["action"] = "Off Road",
                                           ["task"] = 
                                           {
                                               ["id"] = "ComboTask",
                                               ["params"] = 
                                               {
                                                   ["tasks"] = 
                                                   {
                                                   }, -- end of ["tasks"]
                                               }, -- end of ["params"]
                                           }, -- end of ["task"]
                                           ["speed_locked"] = true,
                                       }, -- end of [1]
                                   }, -- end of ["points"]
                               }, -- end of ["route"]
                               ["groupId"] = 1,
                               ["tasks"] = 
                               {
                               }, -- end of ["tasks"]
                               ["hidden"] = false,
                               ["units"] = 
                               {
                                   [1] = 
                                   {
                                       ["y"] = 631114.28571429,
                                       ["type"] = "T-72B",
                                       ["name"] = "Unit #12",
                                       ["unitId"] = 1,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328142.85714286,
                                   }, -- end of [1]
                                   [2] = 
                                   {
                                       ["y"] = 631154.28571429,
                                       ["type"] = "T-72B",
                                       ["name"] = "Unit #13",
                                       ["unitId"] = 13,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328182.85714286,
                                   }, -- end of [2]
                                   [3] = 
                                   {
                                       ["y"] = 631194.28571429,
                                       ["type"] = "T-72B",
                                       ["name"] = "Unit #14",
                                       ["unitId"] = 14,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328222.85714286,
                                   }, -- end of [3]
                                   [4] = 
                                   {
                                       ["y"] = 631134.28571429,
                                       ["type"] = "T-72B",
                                       ["name"] = "Unit #15",
                                       ["unitId"] = 15,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328262.85714286,
                                   }, -- end of [4]
                                   [5] = 
                                   {
                                       ["y"] = 631174.28571429,
                                       ["type"] = "ZSU-23-4 Shilka",
                                       ["name"] = "Unit #16",
                                       ["unitId"] = 16,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328302.85714286,
                                   }, -- end of [5]
                                   [6] = 
                                   {
                                       ["y"] = 631114.28571429,
                                       ["type"] = "BMP-2",
                                       ["name"] = "Unit #17",
                                       ["unitId"] = 17,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328342.85714286,
                                   }, -- end of [6]
                                   [7] = 
                                   {
                                       ["y"] = 631154.28571429,
                                       ["type"] = "BMP-2",
                                       ["name"] = "Unit #18",
                                       ["unitId"] = 18,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328382.85714286,
                                   }, -- end of [7]
                                   [8] = 
                                   {
                                       ["y"] = 631194.28571429,
                                       ["type"] = "BMP-2",
                                       ["name"] = "Unit #19",
                                       ["unitId"] = 19,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328422.85714286,
                                   }, -- end of [8]
                                   [9] = 
                                   {
                                       ["y"] = 631134.28571429,
                                       ["type"] = "BMP-2",
                                       ["name"] = "Unit #20",
                                       ["unitId"] = 20,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328462.85714286,
                                   }, -- end of [9]
                                   [10] = 
                                   {
                                       ["y"] = 631174.28571429,
                                       ["type"] = "MTLB",
                                       ["name"] = "Unit #21",
                                       ["unitId"] = 21,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328502.85714286,
                                   }, -- end of [10]
                                   [11] = 
                                   {
                                       ["y"] = 631114.28571429,
                                       ["type"] = "MTLB",
                                       ["name"] = "Unit #22",
                                       ["unitId"] = 22,
                                       ["heading"] = 0,
                                       ["playerCanDrive"] = true,
                                       ["skill"] = "High",
                                       ["x"] = -328542.85714286,
                                   }, -- end of [11]
                               }, -- end of ["units"]
                               ["y"] = 631114.28571429,
                               ["x"] = -328142.85714286,
                               ["name"] = "New Vehicle Group2",
                               ["start_time"] = 0,
                               ["task"] = "Ground Nothing",
                           })

Here is also a mission im testing the issue on

mp spawntest.miz

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

Well that was frustrating to figure out, even though the problem was staring me in the face. It appears clients and shared group/unit Ids don't mix. You are spawning the ground group and the first unit of the group with the same groupId and unitId as the client. In single player/host, I'm not sure why the whole group still spawns in. But the client just won't see the group. Make sure the group and unitIds are unique, and it will work.

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

Link to comment
Share on other sites

Well that was frustrating to figure out, even though the problem was staring me in the face. It appears clients and shared group/unit Ids don't mix. You are spawning the ground group and the first unit of the group with the same groupId and unitId as the client. In single player/host, I'm not sure why the whole group still spawns in. But the client just won't see the group. Make sure the group and unitIds are unique, and it will work.

Hmm... I tried this and it still doesnt work for me. Are there any restrictions on what unitID/groupID numbers one can use? Could you provide a working version of my mission so I can see what you did?

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

Ids must be any positive number.

 

I commented out the aircraft group as part of the trial and error process. Along with a few other items.

 

But I can in fact verify it spawning does work for clients as I ran another mission and new vehicle groups spawned as intended.

mp spawntest_UID.miz

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

Link to comment
Share on other sites

THANK YOU THANK YOU SOOO MUCH! I did figure out what it was that I did wrong. Looking at your mission and step by step replicating the differences I found the problem: the line

["visible"] = true,

must be:

["visible"] = false,

For some reason I changed that line when I was programming.:doh: Millions of internets to you for being so nice to help me out when I was stuck!

DCS AJS37 HACKERMAN

 

There will always be bugs. If everything is a priority nothing is.

Link to comment
Share on other sites

  • 3 weeks later...

Sorry, when I hijack your thread, but do you have any example how to give an added group a path to go?

 

I am now trying for days to give an added group some path to go, but since MIST functions as groupToRandomPoint do not seem to work I found no way and ended helplessly here. ;)

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Oh, I got it...mist.GoRoute works also for units inserted with the addGrp command, :thumbup:

 

Here an example I finally got working, based on MIST and Psyrixx Extraction Script (which I slowly begin to understand... :cry: ):

 

local heli = Unit.getByName('heli') 
local heligroup = Group.getByName('heli') 
local helipos = heli:getPosition().p
local heliheading = mist.getHeading(heli)    

local targetunit = trigger.misc.getZone('test')
local targetunitpos = {}

targetunitpos.x = targetunit.point.x + math.random(targetunit.radius * -1, targetunit.radius)
targetunitpos.z = targetunit.point.z + math.random(targetunit.radius * -1, targetunit.radius)
               
local data = {
                                  ["visible"] = false,
                                  ["groupId"] = "PontiacInf",
                                  ["taskSelected"] = true,
                                  ["hidden"] = false,
                                  ["units"] = 
                                  {
                                     [1] = 
                                     {
                                        ["y"] = helipos.z + 8,
                                        ["type"] = "Soldier M4",
                                        ["name"] = "PontiacInf",
                                        ["unitId"] = 1,
                                        ["heading"] = heliheading,
                                        ["playerCanDrive"] = true,
                                        ["skill"] = "Excellent",
                                        ["x"] = helipos.x,
                                     },
                                   [2] = 
                                     {
                                        ["y"] = helipos.z,
                                        ["type"] = "Soldier M4",
                                        ["name"] = "PontiacInf",
                                        ["unitId"] = 2,
                                        ["heading"] = heliheading,
                                        ["playerCanDrive"] = true,
                                        ["skill"] = "Excellent",
                                        ["x"] = helipos.x  + 8,
                                     },
                                   [3] = 
                                     {
                                        ["y"] = helipos.z - 8,
                                        ["type"] = "Soldier M4",
                                        ["name"] = "PontiacInf",
                                        ["unitId"] = 3,
                                        ["heading"] = heliheading,
                                        ["playerCanDrive"] = true,
                                        ["skill"] = "Excellent",
                                        ["x"] = helipos.x,
                                     },
                                   [4] = 
                                     {
                                        ["y"] = helipos.z,
                                        ["type"] = "Soldier M4",
                                        ["name"] = "PontiacInf",
                                        ["unitId"] = 4,
                                        ["heading"] = heliheading,
                                        ["playerCanDrive"] = true,
                                        ["skill"] = "Excellent",
                                        ["x"] = helipos.x - 8,
                                     },                          
                                  },
                               ["name"] = "PontiacInf",
                               ["task"] = "Ground Nothing",
                               } 
coalition.addGroup(country.id.USA, Group.Category.GROUND, data)
trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Troops are disembarking, hold position!"), 10)

local infgroup = Group.getByName('PontiacInf')    

function generateWaypoints(targetunit, heli, waypointType)
       local waypoints = {}
       local targetunit = trigger.misc.getZone('test')
       local targetunitpos = {}

       targetunitpos.x = targetunit.point.x + math.random(targetunit.radius * -1, targetunit.radius)
       targetunitpos.z = targetunit.point.z + math.random(targetunit.radius * -1, targetunit.radius)
       
       local helipos = heli:getPosition().p
       local landingpos = Unit.getByName("PontiacInf"):getPosition().p

       local targetpoint = {
               ["type"] = "Flyover Point",
               ["ETA"] = 0,
               ["y"] = targetunitpos.z,
               ["x"] = targetunitpos.x,
               ["ETA_locked"] = true,
               ["speed"] = 15,
               ["speed_locked"] = true,
       }


       local landingpoint = {
               ["type"] = "Flyover Point",
               ["ETA"] = 0,
               ["y"] = landingpos.z,
               ["x"] = landingpos.x,
               ["ETA_locked"] = true,
               ["speed"] = 15,
               ["speed_locked"] = true,
       }
       
       if waypointType == 'LZ' then
               waypoints[#waypoints+1] = mist.ground.buildWP(landingpoint, 'Off Road', 20)
               waypoints[#waypoints+1] = mist.ground.buildWP(targetpoint, 'Diamond', 20)

       end
       
       return waypoints
end

LZ = generateWaypoints(targetunit, heli, 'LZ')
trigger.action.outText("Airborneassault on the move!", 40)

                               
mist.goRoute(infgroup, LZ)                    
   

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • 5 years later...

I have problems spawning a new group. I am doing this code to dynamically set number of units. Why does it not work? No error popup windows.

 

 

function spawnGroup(__pos, _groupName, _radius, _country, _num)

   _pos = coord.LLtoLO(__pos.latitude, __pos.longitude)
   local _coord1, _coord2
   local _randx = _pos.x + math.random(0 - _radius, _radius)
   local _randy = _pos.z + math.random(0 - _radius, _radius)
   
   spawnedUnits = {}
   for i=1, _num do
       _randx = _pos.x + math.random(0 - _radius,_radius)
       _randy = _pos.z + math.random(0 - _radius,_radius)
       
       spawnedUnits[i] ={
                       ["type"] = "LAV-25",
                       ["transportable"] = 
                       {
                           ["randomTransportable"] = false,
                       }, -- end of ["transportable"]
                       ["x"] = _randx,
                       ["y"] = _randy,
                       ["unitId"] = i+1,
                       ["skill"] = "Excellent",
                       ["name"] = "Ground Unit" .. i,
                       ["playerCanDrive"] = true,
                       ["heading"] = 0.28605144170571
                   }
   end

   
   coalition.addGroup(country.id.USA, Group.Category.GROUND, {
               ["visible"] = true,
               ["taskSelected"] = true,
               ["route"] = 
               {
               }, -- end of ["route"]
               ["groupId"] = 666,
               ["tasks"] = 
               {
               }, -- end of ["tasks"]
               ["hidden"] = false,
               ["units"] = 
               {
                   spawnedUnits,
               }, -- end of ["units"]
               ["y"] = _pos.z,
               ["x"] = _pos.x,
               ["name"] = _groupName,
               ["start_time"] = 0,
               ["task"] = "Ground Nothing",
           })
end

p = {}

trigger.action.outText("Hello", 1)
p.latitude = 41.932222
p.longitude = 41.876666
spawnGroup(p, "Group666", 1000, country.id.USA, 1)
trigger.action.outText("World", 1)

Link to comment
Share on other sites

Got it working, instead of declaring and defining groupTable in the function call of addGroup I did this:

groupData = {
               ["visible"] = true,
               ["taskSelected"] = true,
               ["route"] = 
               {
               }, -- end of ["route"]
               ["groupId"] = 666,
               ["tasks"] = 
               {
               }, -- end of ["tasks"]
               ["hidden"] = false,
               ["y"] = _pos.z,
               ["x"] = _pos.x,
               ["name"] = _groupName,
               ["start_time"] = 0,
               ["task"] = "Ground Nothing",
               }
               
   groupData.units = spawnedUnits;

   
   coalition.addGroup(country.id.USA, Group.Category.GROUND, groupData)

Link to comment
Share on other sites

  • 1 year later...
The documentation shows what the variables are, but not the right way to do it exactly. Here is a corrected version of your example.

local unitTable = {
["units"] = 
   {
       [1] = 
       {                
                       ["alt"] = 1524,
                                       ["type"] = "FW-190D9",
                                       ["unitId"] = 399,
                                       ["psi"] = -2.1777839908415,
                                       ["alt_type"] = "BARO",
                                       ["skill"] = "Average",
                                       ["y"] = 536171.42857143,
                                       ["x"] = -201337.14285714,
                                       ["name"] = "190D9 - 1",
                                       ["payload"] = 
                                       {
                                           ["pylons"] = 
                                           {
                                           }, -- end of ["pylons"]
                                           ["fuel"] = 461,
                                           ["flare"] = 0,
                                           ["chaff"] = 0,
                                           ["gun"] = 100,
                                       }, -- end of ["payload"]
                                       ["speed"] = 138.88888888889,
                                       ["heading"] = 2.1777839908415,
                                       ["callsign"] = 112,
                                       ["onboard_num"] = "10",
},
["name"] = dynSpawnGp1
["hidden"] = false

}

coalition.addgroup(country.id.GERMANY, Group.Category.AIRPLANE, unitTable)

 

 

Could someone give me an example with full pylons, please? I do not know the structure of ["pylons"] = {} from your example.

 

I have tried to use ["pylons"] = pUnit:getAmmo() using an existing pUnit unit, but it did not work. The spawned aircraft did not have any weapon on its pylons.


Edited by Tiramisu
Link to comment
Share on other sites

Could someone give me an example with full pylons, please? I do not know the structure of ["pylons"] = {} from your example.

 

I have tried to use ["pylons"] = pUnit:getAmmo() using an existing pUnit unit, but it did not work. The spawned aircraft did not have any weapon on its pylons.

 

I'd suggest to create a couple of planes with the desired loadouts, and then use a text editor to find those planes and, hence, their loadouts/pylons within the mission file. An example for your request could be (rockets on pylons):

 

["payload"] = 
	{
		["pylons"] = 
		{
			[3] = 
			{
				["CLSID"] = "{FW_190_R4M_RGHT_WING}",
			}, -- end of [3]
			[2] = 
			{
				["CLSID"] = "{FW_190_R4M_LEFT_WING}",
			}, -- end of [2]
		}, -- end of ["pylons"]
		["fuel"] = 388,
		["flare"] = 0,
		["chaff"] = 0,
		["gun"] = 100,
	}, -- end of ["payload"]

Link to comment
Share on other sites

  • Recently Browsing   0 members

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