DanAK47 1 Posted January 24, 2005 Is there an easy way to detect a unit's true number, not just the index of it in the units array? The index number becomes mismatched when another unit in the group dies. I also can't define it at the start of the mission. It needs to be checked whenever the script is executed, which may be after a unit in the group dies. I need to delete a unit and recreate it using createUnit but when I do this it does not get the same number in the group (rather, it takes the number of a deceased unit). If there is no command or existing script to check this I can make a workaround, but if a command for it exists it would save me trouble. Share this post Link to post Share on other sites
General Barron 0 Posted January 25, 2005 Well, the index of the unit would have been your best bet I would think, but obviously that isn't working in this case. However, the "onmapsingleclick" command does return an array of the selected units in a group, so perhaps the order of that array may help you. Other than that, I can only suggest storing the information in a global variable at the start of the mission, or else just going for the workaround. What is this for, might I ask? Share this post Link to post Share on other sites
DanAK47 1 Posted January 25, 2005 For the watch script I was struggling with in another post. You can click on the map and the unit will target it with the main gun. I'm recreating the unit to get around the disableAI problem. Returning the unit doesn't really help, I have his name, but need the number. Would be nice if I could split apart what it says when you hint format it. I'll just make a bogus magazine and add it to the unit x amount of times and check the number of that magazine to see what his number is. Share this post Link to post Share on other sites
General Barron 0 Posted January 25, 2005 Quote[/b] ]Would be nice if I could split apart what it says when you hint format it. Hmm... I can't remember what exactly it shows when you hint/format a unit, but doesn't it look something like this? WEST Alpha Black 2 Unless I am mistaken, it never shows the units name, unless that unit is a player. If that is the case, you might be able to use it. As long as you know the unit's side, and you know the unit's group designation, then you can do a number of string comparisons, and check which one matches. So essentially, your comparison would look something like this: _group = "alpha black" _side = "WEST" ? format ["%1",_soldier] == format ["%1 %2 1",_side,_group] : _num = 1 You think that could work? Share this post Link to post Share on other sites
DanAK47 1 Posted January 25, 2005 Never thought of using that, thanks. ? format ["%1",_soldier] == format ["%1:1",group _soldier] returns true when he's the first unit. Originally it was spitting out "WEST WEST Alpha Black 1" Only thing is, it doesn't work for the player because of the name displayed at the end. This isn't a problem because the script runs for AI, but it could become one in MP if a player disconnects. Share this post Link to post Share on other sites
General Barron 0 Posted January 26, 2005 Ah, good idea on using the "group" command in the format. Didn't realize that it displayed the same "WEST alpha black" stuff as in the unit/format command. Good to know this technique works; I may need to use it later on. Share this post Link to post Share on other sites
Spinor 0 Posted January 26, 2005 Quote[/b] ]Only thing is, it doesn't work for the player because of the name displayed at the end. This isn't a problem because the script runs for AI, but it could become one in MP if a player disconnects. I think for players, it appends the player name in brackets, i.e. if your above check doesn´t give true, also check: ? format ["%1",_soldier] == format ["%1:1(%2)",group _soldier,name _soldier] (check the actual format, though, I am not sure about the exact format) Share this post Link to post Share on other sites
DanAK47 1 Posted January 26, 2005 Yeah, I will have to do that. But first I will need to check if the person was ever a player in the past, because the name only displays if they were. It might disappear when they disconnect, but I doubt that. That would make things way too easy. I'll check with my other PC sometime. Share this post Link to post Share on other sites