Jump to content

Recommended Posts

Posted

I have 2 helicopters I Pilot the other one but they are both empty ee to fly in multiplayer, I have to Detect id helicopter from the script even if they are inside.

 

This error code back to me if they are not inside the unit, how can I do?

 

 
function getUnitID2(unitName)
 local unit = Unit.getByName(unitName)
 local unitID = nil
 if unit ~= nil then
   unitID = unit:getID()
 end
 return unitID
end
local ely_id2 = getUnitID2('Pilot #1')
 trigger.action.outText(ely_id2, 5)

 

 

sorry for my eng

====VIAF====

Spinter 155° "Pantere Nere"

 

TsSimComms

 

My Site aiupgrade.net

 

 

 

Posted (edited)

local heligroup = Group.getByName('New Helicopter Group') 
trigger.action.outText(Group.getID(heligroup), 15)

 

I also this code returns an error if they are not in cockpit!

Edited by spinter

====VIAF====

Spinter 155° "Pantere Nere"

 

TsSimComms

 

My Site aiupgrade.net

 

 

 

Posted

Non-spawned client aircraft and dead AI return nil with Group.getByName() and Unit.getByName(). So it is best to do a precautionary check to make sure the group/unit/object is alive in the first place before you try to manipulate data retrieved from said object:

 

if Group.getByName(''New Helicopter Group') then

local heligroup = Group.getByName('New Helicopter Group') ... etc

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

  • Recently Browsing   0 members

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