sea2sky Posted May 2, 2017 Posted May 2, 2017 (edited) I realized I don't know how to determine if airborn unit/group is a player/client controlled or AI. Anybody knows that? Thanks! Edited May 2, 2017 by sea2sky i5-9600K@4.8GHz ★ 32Gb DDR4 ★ rtx5070ti ★ Quest Pro ★ Warthog on Virpil base
feefifofum Posted May 2, 2017 Posted May 2, 2017 The chat logs will say either a username or BLUE/RED AI for the kill messages if enabled. In the F10 map, when you click on a unit, I believe you'll see the person's callsign next to the unit/group name as well. THE GEORGIAN WAR - OFFICIAL F-15C DLC
sea2sky Posted May 3, 2017 Author Posted May 3, 2017 Sorry, I meant - how to figure that using lua scripting. i5-9600K@4.8GHz ★ 32Gb DDR4 ★ rtx5070ti ★ Quest Pro ★ Warthog on Virpil base
Stonehouse Posted May 3, 2017 Posted May 3, 2017 Use something like: if Unit.getPlayerName(unit name being checked) == nil if the above is true then it's AI. Note that "unit name being checked" is the actual unit name of the unit you are trying to figure out whether it is AI or human. 1
sea2sky Posted May 3, 2017 Author Posted May 3, 2017 Excellent! i5-9600K@4.8GHz ★ 32Gb DDR4 ★ rtx5070ti ★ Quest Pro ★ Warthog on Virpil base
gromit190 Posted May 4, 2017 Posted May 4, 2017 (edited) Use something like: if Unit.getPlayerName(unit name being checked) == nil Close. But the Unit.getPlayerName argument must be a unit, not a string (name). So you're gonna need to obtain the unit first (if you haven't already), then invoke "getPlayerName" for this unit. If this function returns a string, it is a player. If not, it's AI. -- obtain unit by name local unit = Unit.getByName(nameOfUnit) -- check if the unit has a "player name" if unit:getPlayerName() then -- it's a player else -- it's AI end Or if you prefer oneliners: if Unit.getByName(nameOfUnit):getPlayerName() then -- it's a player end http://wiki.hoggit.us/view/DCS_func_getByName http://wiki.hoggit.us/view/DCS_func_getPlayerName Edited May 4, 2017 by gromit190 Autonomous ground AI project
Stonehouse Posted May 4, 2017 Posted May 4, 2017 Yep you are right. Sorry I haven't had time to look at lua for quite a while so I am forgetting stuff. Close. But the Unit.getPlayerName argument must be a unit, not a string (name). So you're gonna need to obtain the unit first (if you haven't already), then invoke "getPlayerName" for this unit. If this function returns a string, it is a player. If not, it's AI. -- obtain unit by name local unit = Unit.getByName(nameOfUnit) -- check if the unit has a "player name" if unit:getPlayerName() then -- it's a player else -- it's AI endOr if you prefer oneliners: if Unit.getByName(nameOfUnit):getPlayerName() then -- it's a player endhttp://wiki.hoggit.us/view/DCS_func_getByName http://wiki.hoggit.us/view/DCS_func_getPlayerName
Recommended Posts