OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: David on 30 May 2006, 10:45:25

Title: CreateUnit
Post by: David on 30 May 2006, 10:45:25
I'm trying to create a script that will spawn Ai in a given area, but failing.

Heres what i have so far.

I created a marker and called it Flag1Spawn, this is where I want the AI created, I then have the script called, ["Flag1Spawn"] exec "ai_respawn.sqs"

The contents of the ai_respawn.sqs as below

Code: [Select]
_FlagSpawn = _this Select 0

"SoldierWB" createUnit [getmarkerPos "_FlagSpawn",groupAlpha]

No AI is spawned in the area I want them to be, anyone got any ideas?
Title: Re: CreateUnit
Post by: Pim on 30 May 2006, 10:55:11
Hello David,

I assume here that _flagspawn is a marker name. In this case the

Code: [Select]
getMarkerPos "_flagspawn"
should be

Quote
getMarkerPos _flagspawn

since the marker name is already a string, implying that you have added a "" too much.

Also make sure that the "groupAlpha" variable points to a group on the map. I mean, it seems you have copied this value from the command reference, but this variable actually determines to what group the new unit is added. When a new unit is joined to the group of the player, for instance, "groupalpha"
could be replaced by "group player" (without the "" 's).

Hope this is of any help, Pim
Title: Re: CreateUnit
Post by: Pilot on 30 May 2006, 13:25:17
Make sure that groupAlpha already exists before you try to create a unit into that group.  You can do this by creating a unit of the same side and typing this in the init field:
groupAlpha = group this; deletevehicle this;

This will create the group, groupAlpha, but will also delete that unit so it is no longer on the map.

-Pilot