Jump to content

Recommended Posts

Posted (edited)

Hello,

 

Some time ago, I've prepared script thats function is after mission start, to show list of all units in the mission, then in the loop, check whether any of groups with names started with "RESP_" are killed and if so, then to spawn them.

Everything was fine, until I've added another unit to the group, where player is located with the "client" as pilot skill. Now the situation is, that whenever I'll join mission in "Client" position, no error is shown, but if I'll join in the "Player" position, error as in the subject appears and refers to line 21, where "if unitra:isActive() then" clause is located. Additionally, in the first scenario, no wingman is created, but in second one there appears wingman controlled by AI.

The whole script is as follows:

pipok = {}

function pipok.respawnGroup()
   local prefix = "RESP_"
   local refreshRate = 30
   for grpName, value in pairs(mist.DBs.groupsByName) do
       if string.find(grpName, prefix) then
           --trigger.action.outText(grpName, 2)
           if not Group.getByName(grpName) then
               trigger.action.outText("Respawning " .. grpName, 10)
               mist.respawnGroup(grpName, true)
           end
       end
   end
   mist.scheduleFunction(pipok.respawnGroup, nil, timer.getTime() + refreshRate)
end

for unitID, myUnit in pairs(mist.DBs.unitsByName) do
   --for _, aliveUnit in pairs(mist.DBs.aliveUnits) do
   local unitra = Unit.getByName(myUnit.unitName)
   if unitra:isActive() then
       jednostka = "Prawda"
       else
       jednostka = "Fałsz"
   end
   trigger.action.outText(myUnit.unitName .. " - " .. jednostka, 5)
end

trigger.action.outText("Executing Respawn by Prefix script, v.26",10)
pipok.respawnGroup()

 

And of course question is how what is the reason of this error message/how to get rid of it, and second one what causes to behave differenly, dependent of position the player will choose to play in.

Edited by Pipok

Natural Born Kamikaze

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

AMD Ryzen 5 3600, AMD Fatal1ty B450 Gaming K4, AMD Radeon RX 5700 XT, 32 GB RAM Corsair Vengeance LPX, PSU Modecom Volcano 750W, Virpil Constellation Alpha Prime on Moza AB9 base, Virpil MongoosT-50CM3 Throttle, Turtle Beach VelocityOne Rudder.

Posted

Only a guess off the top of my head but possibly this scripting bug is to blame 31682 - Client groups not accessible in multiplayer.

 

If you don't actually want to include clients in the script's processing then you could sidestep the issue by adding a condition unitra:getPlayerName = nil just prior to your check for isActive perhaps?

 

fyi thread mentioning script bugs - sorry I have no idea what the status of each is though. Grimes may be able to tell you

 

http://forums.eagle.ru/showthread.php?t=147792

Posted

Yes, indeed, after reading of some other scripts, I've noticed there's always plenty of "= nil" preceeding operations on units and groups, so I've applied the same in my script and error is no longer the issue. And for the second, I've just declared both airplanes as "Client" and there's no more wingman AI.

Thanks for pointing that article with bug description, I'll put that into my subscriptions.

Natural Born Kamikaze

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

AMD Ryzen 5 3600, AMD Fatal1ty B450 Gaming K4, AMD Radeon RX 5700 XT, 32 GB RAM Corsair Vengeance LPX, PSU Modecom Volcano 750W, Virpil Constellation Alpha Prime on Moza AB9 base, Virpil MongoosT-50CM3 Throttle, Turtle Beach VelocityOne Rudder.

  • Recently Browsing   0 members

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