Spawning and keeping a global count of the number of spawns
I am trying to write a script that allows someone to spawn a vehicle from a box. I have got this part to work using the addAction command. However, I want to set a limit on the number of spawns that are available for the whole team. I have been unable to get it working in multiplayer. I had a look at the public variable page on the BIKI but it wasn't really very helpful to me as it did not tell me how to set the value of the public variable, nor get the value so I could compare it in an if statement. Here is the code that I have produced so far using the public variables but this does not spawn at all now:
I have another question, how would I get this script to spawn an object on a marker with a certain height (i.e. to go on a lhd deck?) because it says on the biki use setPos, but I have no clue how I would insert this into my script. Can anyone help me out here?
Found this on the comref: Spoiler:
createVehicle [type, position, markers, placement, special]
[type, position, markers, placement, special]: Array
Version 2.32 required.
Type of returned value:
Creates a vehicle of the given type (type is the name of the subclass in CfgVehicles). If the markers array contains several marker names, the position of a random one is used. Otherwise, the given position is used. The vehicle is placed inside a circle with this position as center and placement as its radius. Special properties can be: "NONE", "FLY" and "FORM".
veh = createVehicle ["Cobra", position player, , 0, "FLY"]
Is there a way to then use this to set the height of the marker and then set it to spawn on that marker or can I set it to spawn relative to the object which I am using the addaction from?
Where... 15.4 is the height to spawn the object at. From memory.... on the LHD I think the value you need is 15.4 or close to that. I may be totally wrong there. LOL!....but you can work it out. I'm sure.
Last edited by twirly; Feb 4 2012 at 23:38.
Thank you Twirly, it worked for me, couldn't quite figure it out on my own. Thank you again!
(height was slightly off, but thats easily fixed)
also noticed it doesn't like spawning aircraft onto the deck of the Khe Shan, do I need to set height or should I just let it spawn where it does by default? (may be the wrong height, I spawned a ACE HMMWV armored at the same height as the LAV's, but it was WAY higher then the LAV's)
I don't think the top one will work....as the vehicle hasn't been created yet in order to use it in the actual statement. The bottom one should.. Oooops...Just read it again...and neither one will work for the same reason.
You can also create the vehicle somewhere else and then move it to it's final position.
_mkrpos = getMarkerPos "hspawn1";
_veh = createVehicle ["UH1Y" , [0,0,30], , 0, "NONE"]; //bottom left corner of map... 30 up meters in the air
_veh setpos [_mkrpos select 0,_mkrpos select 1,26.3]; //move it to it's new location
I don't think you actually need the setPosASL and setPosATL commands just to spawn something at a height. I never use them. In certain cases though I might be wrong. Someone else might be a little clearer on that.... but all it takes is some testing.
Last edited by twirly; Feb 5 2012 at 22:58.