spinter Posted June 1, 2013 Posted June 1, 2013 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
spinter Posted June 1, 2013 Author Posted June 1, 2013 (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 June 1, 2013 by spinter ====VIAF==== Spinter 155° "Pantere Nere" TsSimComms My Site aiupgrade.net
Grimes Posted June 1, 2013 Posted June 1, 2013 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 Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
spinter Posted June 1, 2013 Author Posted June 1, 2013 thx Grimes! I need to extract the id of the helicopters that I create in a multiplayer mission, the helicopters are there but not yet with a human on board! ====VIAF==== Spinter 155° "Pantere Nere" TsSimComms My Site aiupgrade.net
spinter Posted June 2, 2013 Author Posted June 2, 2013 how can I get the id when I load the mission from the existing mission? I need to retrieve the id of the helicopters loaded during the creation of the mission! ====VIAF==== Spinter 155° "Pantere Nere" TsSimComms My Site aiupgrade.net
Recommended Posts