voidbyte 13 Posted August 4, 2019 Hello, since hours now, I try to spawn units with a script. Thought that might become the easiest part ever. But it turns out that this is much more challenging then everything else ive done so far. Background: I want a reusable script, that, if working, can be ported to headless clients (later) In the end, I want to make a new mission, place a few "whatever" (I used "Marker_GetIn_ACR" for this) and give them names like: "redfor_1", "redfor_2", "redfor_3"; and the Script will identify these "whatevers" as marker positions to spawn redfor units of a given kind. Means, I want to develop it once and can easy reuse it. My first attemp was something like this: // for test purpose, just a few static positions _sLocations = ["opfor_0", "opfor_1", "opfor_2", "opfor_3", "opfor_4", "opfor_5"]; "O_Survivor_F" createUnit [getMarkerPos _sLocations]; Expected result: I spawn a suvivor at all the _sLocations positions. But that failed. Fixed it, failed again and again and again... what ever I change to the code, adding groups, sides, direct coordinates.. it always have a new error. So I think spawning a whole array dont work this way. Will do it with an ForEach later. Lets spawn a single unit on a single postition. And that is where it become redicolous. I tried: _grp = createGroup west; _grp createUnit ["O_Survivor", (getmarkerpos "opfor_0"), [], 0, "NONE"]; That does exactly nothing. It dont spawn anything nor give it out an error massage. So I cant do anything better without a hint whats wrong here. And because of this, i looked again in the CreateUnit BIS-Reference. They say the command has this scheme: Quote type createUnit [position, group, init, skill, rank] Ok, I think, lets do exactly whats in there: _type = "O_Survivor_F" _here = "opfor_0"; _group = createGroup west; _init = ""; _skill = 0.5; _rank = "PRIVATE"; _type createUnit [_here, _group, _init, _skill, _rank]; And again.. error over error. Whatever I change, a new Error pops up. Tried like this will result in a "0 Elements given, 3 expected" error. And even in BIS own examples they dont follow their own scheme. So im out of options here. Google the problem always lead to people who post super complicated scripts for mass crowding, patrolling etc.. And I thought that spawning a single enemy on a simple position would be easy... If you see whats wrong, i appreciate your help. Share this post Link to post Share on other sites
wogz187 1086 Posted August 4, 2019 @voidbyte, Quote since hours now, I try to spawn units with a script. It's frustrating for sure. Quote Background: I want a reusable script, that, if working, can be ported to headless clients (later) I can't really help with your syntax because I'm still baffled by variables, too. This module might help you get a head-start with, Quote "That does exactly nothing. It dont spawn anything nor give it out an error massage." Have fun! 1 Share this post Link to post Share on other sites
Lucullus 71 Posted August 4, 2019 Pay attention to the syntax! _grp = createGroup east; _unit = _grp createUnit ["O_Survivor_F",(getMarkerPos "opfor_0"),[],0, "NONE"]; _type = "O_Survivor_F"; _here = getmarkerpos "opfor_0"; _group = createGroup east; _init = ""; _skill = 0.5; _rank = "PRIVATE"; _type createUnit [_here,_group,_init,_skill,_rank]; 2 Share this post Link to post Share on other sites
Sgt. Dennenboom 98 Posted August 4, 2019 You're making small but different syntax errors with everything you're trying to do, read the createUnit page more carefully. Your first code-block is nonsense, but you figured that out yourself too. Your second code-block uses "O_Survivor" as the class, which doesn't exist (It's ""O_Survivor_F") Your third code-block has uses a marker as the spawn point instead of a position. Here's how you achieve what you want to achieve: _markerArray = ["opfor_0", "opfor_1", "opfor_2", "opfor_3", "opfor_4", "opfor_5"]; _unitClass = "O_Survivor_F"; { (createGroup EAST) createUnit [_unitClass,getMarkerPos _x,[],0,"NONE"]; } forEach _markerArray; 3 Share this post Link to post Share on other sites
voidbyte 13 Posted August 4, 2019 13 minutes ago, Sgt. Dennenboom said: You're making small but different syntax errors with everything you're trying to do, read the createUnit page more carefully. Your first code-block is nonsense, but you figured that out yourself too. Your second code-block uses "O_Survivor" as the class, which doesn't exist (It's ""O_Survivor_F") Your third code-block has uses a marker as the spawn point instead of a position. Here's how you achieve what you want to achieve: _markerArray = ["opfor_0", "opfor_1", "opfor_2", "opfor_3", "opfor_4", "opfor_5"]; _unitClass = "O_Survivor_F"; { (createGroup EAST) createUnit [_unitClass,getMarkerPos _x,[],0,"NONE"]; } forEach _markerArray; Hey, thank you for the help. But your code also don't do anything. It does not spawn units nor throws it an error. I begin to think that the problem is not the code but something else.. maybe the trigger, maybe mods... Share this post Link to post Share on other sites
Sgt. Dennenboom 98 Posted August 4, 2019 My script works just fine for me. Where/how do you execute it? How did you create your markers? Share this post Link to post Share on other sites
voidbyte 13 Posted August 4, 2019 I have a simple trigger. When a BlueFor walks over, execVM "scripts/spawndrop.sqf"; will be executed. And in this file is a copy and paste of your code contained. Quote it out and write "hint "Hello"; works fine. so the trigger is working. But i have those Mods installed: TFAR CUP Aliabad Ares BWmod Carter CBA (All CUP extras, like Terrains, Units, Vehicles etc..) Lingor Pandora Wakeisland Ace AceX Do you see any that can inflict a missbehavior? Share this post Link to post Share on other sites
Sgt. Dennenboom 98 Posted August 5, 2019 I don't think any of these mods would affect this extremely basic script, so what I'm currently thinking of is that your markers are defined wrong. Execute the following script in the debug console so you can see the positions of your markers: ["opfor_0", "opfor_1", "opfor_2", "opfor_3", "opfor_4", "opfor_5"] apply {getMarkerPos _x}; If these positions are [0,0,0], then the markers don't actually exist and your units spawn there. Share this post Link to post Share on other sites
voidbyte 13 Posted August 5, 2019 Hey, this also just give me back an "invalid number in expression" Error. I made a quick video, that show all the steps i have done so far. Maybe that helps to see where my mistake is. Hopefully my english is understandable :D Share this post Link to post Share on other sites
Dedmen 2704 Posted August 5, 2019 12 minutes ago, voidbyte said: "invalid number in expression" Might be copy-paste forum bug. Copying from forum sometimes inserts invisible character. Yep. Right after the semicolon in your video at 2:17 I get it too if I copy the code from @Sgt. Dennenboom if I select up to the next line. 2 Share this post Link to post Share on other sites
voidbyte 13 Posted August 5, 2019 Hey Dedmen, thank you for that. At least we are one step further.. Now i got: Quote [[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]] as output. Next question is: Why don't he get the correct positions... EDIT: OK... for my next Test, I used those wierd MapMarkers. And guess what: it works perfectly. Sadly those mapthings are not usable for me, because I want to spawn Enemys inside buildings and whereever I want. Is there a workaround?! Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 5, 2019 Hello there voidbyte ! EOS script is a good option. But there are several spawn scripts as well. 1 Share this post Link to post Share on other sites
Sgt. Dennenboom 98 Posted August 5, 2019 Wait you used something else than map markers to indicate where you wanted to spawn enemies @voidbyte? The "getMarkerPos" command only works for map markers, not for objects. If you're using some kind of helper object to indicate the spots do: _spawnObjectArray = [opfor_0,opfor_1,opfor_2,opfor_3,opfor_4,opfor_5]; _unitClass = "O_Survivor_F"; { (createGroup EAST) createUnit [_unitClass,getPos _x,[],0,"NONE"]; } forEach _spawnObjectArray; The createUnit command with the "NONE" special argument places the unit on an approximate position at a free spot near that position. To make the command spawn the unit exactly where you want, either change "NONE" to "CAN_COLLIDE", or set the position of the unit after it was spawned, like such: _spawnObjectArray = [opfor_0,opfor_1,opfor_2,opfor_3,opfor_4,opfor_5]; _unitClass = "O_Survivor_F"; { _unit = (createGroup EAST) createUnit [_unitClass,[0,0,0],[],0,"NONE"]; _unit setPosASL getPosASL _x; (getPosASL is used because it's accurate inside buildings too, unlike the standard getPos) } forEach _spawnObjectArray; 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 6, 2019 6 hours ago, voidbyte said: Is there a workaround?! Check also if you like my WIP GF Zone Spawner Script-Mod : +GF_Zone_Spawner.Stratis.zip Expires in: 29 days 20:56:43 | Size: 19.7 KB | 06.08.19 uploaded More news will be here available : Thanks ! 1 1 Share this post Link to post Share on other sites