Jump to content
Sign in to follow this  
b00tsy

Create vehicle on trigger.

Recommended Posts

Hi,

I have been searching the wiki and the forum, but I can't seem to find exactly what I am looking for. Well I saw a couple of related topics, but I could not get it to work as described there.

I am looking for a simple way to create a vehicle after a town has been cleared with a trigger.

Now is saw this:

[(getmarkerpos test), 0, "BMP3", east] call BIS_fnc_spawnVehicle;

But this does not do anything when I tried it in a trigger. I also added a function module to see if that does anything, but nada.

Any hints on how to get it to work is appriciated.

Share this post


Link to post
Share on other sites

I think you need to put the marker name in qoutations for it to work.

[(getmarkerpos "test"), 0, "BMP3", east] call BIS_fnc_spawnVehicle;

Share this post


Link to post
Share on other sites
I think you need to put the marker name in qoutations for it to work.

Yeah indeed, I forgot to add that. It still wont work however :(

So I created a trigger activated with bluefor present and a countdown set to 15 seconds and placed the code on the 'on act' and made it type switch, but when the trigger activates I see no vehicle created at the marker position.

Share this post


Link to post
Share on other sites

Do you need the () around the getmarkerpos and marker name?

And why the switch type, have you tried with none?

Im not at my playing computer so I cant test it myself

Share this post


Link to post
Share on other sites
Do you need the () around the getmarkerpos and marker name?

And why the switch type, have you tried with none?

Im not at my playing computer so I cant test it myself

I tried it without the () and without any type active, but nothing still. I do not get any errors or anything.

Share this post


Link to post
Share on other sites

There's nothing wrong with the code as long as you named the marker correctly.

Name the marker test and not "test"

[(getmarkerpos "test"), 0, "BMP3", east] call BIS_fnc_spawnVehicle;

check the trigger is going off by setting it to display some text.

Share this post


Link to post
Share on other sites

Yeah I did add a sound to the trigger to check if it activates and the trigger is named test without the quotes. I hear the sound, but nothing. Weird that it wont work if everything is correct. I also placed the code without the "east" as I do not believe that is needed anyway, but also that does not create the vehicle. The marker is a default empty trigger with just the name added.

Share this post


Link to post
Share on other sites

I walked all the way to my other computer and tested it and it works.

this is what I used [getmarkerpos "test", 0, "BMP3", east] call BIS_fnc_spawnVehicle;

Do you have arma2? bmp3 is from arma2 if im correct

Share this post


Link to post
Share on other sites

I used the same thing and nothing for me. I am trying to get it to work on OA, but I tried the code with several class names:

[getmarkerpos "test", 0, "HMMWV", west] call BIS_fnc_spawnVehicle;

this one for example which should work in OA, but still no vehicle when the trigger activates.

With creating objects I can fake it by placing the object underground and then with a trigger change the position to above ground. It gives the same result, but vehicles I can't place underground.

Thanks for the help anyway!

Edit: I got it! I was using the class names I found in the wiki and they were ArmA2 class names. I now found the right class names and it works.

Thanks for the help.

Edited by B00tsy

Share this post


Link to post
Share on other sites

Yeah I have, but did not use combined ops. Haven't touched arma 2 since the release of OA :)

Share this post


Link to post
Share on other sites

I have two more questions :)

I have now got the vehicle spawn working properly, but I also want to link a script to the created vehicle. I have created a simple respawn script that I want to combine to that new created vehicle.

This is what I have:

[getmarkerpos "award1", 0, "HMMWV_MK19_DES_EP1", west] call BIS_fnc_spawnVehicle; hint "HMMWV (Mk19) available!";

and I also want to add this to the created vehicle:

[this, 120] exec "vehirespawn.sqs"; 

I am sure it is something simple to combine both codes, but I am unsure how to do it. I think giving the created vehicle a name would do it and then replace "this" with the vehicle name, but don't know how/where to add a vehicle name to it.

I also have some problems with letting a spawned group to patrol at a marker position.

_dgrp = [(getmarkerpos "test_1"),east,6] call bis_fnc_spawngroup; sleep 10; _dgrp = [(getmarkerpos "test_1_1"),east,6] call BIS_fnc_taskPatrol;

The group spawns properly, but the taskPatrol does not seem to activate, the opfor men just keep standing there. What am I doing wrong?

---------- Post added at 11:49 AM ---------- Previous post was at 10:30 AM ----------

Ohh and one more question >_<

I can't seem to create empty vehicles. Any hints on how to do that would be apriciated too.

edit again: the last I figured out. In case other people finds it useful:

_veh = "MtvrRepair_DES_EP1" createVehicle (getMarkerPos "award2");

Spawns empty vehicle.

Still would like to know how to add respawn script to the added vehicle and how to get the patrol function to work.

Edited by B00tsy

Share this post


Link to post
Share on other sites

I'cant check right now but this may work for the first 2 questions.

temp = [getmarkerpos "award1", 0, "HMMWV_MK19_DES_EP1", west] call BIS_fnc_spawnVehicle; hint "HMMWV (Mk19) available!";car1 = temp select 0;[car1, 120] exec "vehirespawn.sqs";

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks that looks logical. Unfortunately it did not work. The vehicle does get spawned, but after destroying it it does not respawn. I will keep messing with it some more.

Share this post


Link to post
Share on other sites

You could put !alive car1 in a trigger condition and in on act [car1, 120] exec "vehirespawn.sqs";

That should respawn car1 when dead.

Without knowing how your script is laid out it's a bit difficult.

Share this post


Link to post
Share on other sites

That unfortunately did not work either.

I am using this respawn script:

?! (local server): exit
~3
_vehicle = _this select 0
_delay = _this select 1
_empty = true
_disabled = false
_moved = false

_startpos = getpos _vehicle
_startdir = getdir _vehicle
_type = typeof _vehicle

#waiting
~2
_newpos = getpos _vehicle
?! (_newpos select 0 in _startpos) or not (_newpos select 1 in _startpos): _moved = true

?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not (isnull commander _vehicle): _empty = false
? (isnull driver _vehicle) and (isnull gunner _vehicle) and (isnull commander _vehicle): _empty = true

?! (canmove _vehicle) or (canfire _vehicle): _disabled = true
? (canmove _vehicle) and (canfire _vehicle): _disabled = false
? (_disabled) and (_empty): goto "spawn"
? (_moved) and (_empty): goto "spawn"
goto "waiting"

#spawn
~_delay
?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not(isnull commander _vehicle): _empty = false
?! (_empty): goto "waiting"
deletevehicle _vehicle
~0.5
_newveh = _type createvehicle _startpos
_newveh setpos _startpos
_newveh setdir _startdir
[_newveh, _delay] exec "vehirespawn.sqs"
exit

It works great when I place the activation code in the init of a vehicle, but it refuses to work with a new created vehicle.

Share this post


Link to post
Share on other sites

How about you add the vehicle to a group instead of just side west.

[getmarkerpos "award1", 0, "HMMWV_MK19_DES_EP1", group] call BIS_fnc_spawnVehicle;

and when you call the fnc_spawnvehicle you delete the unit that started the group so the vehicle dont want to go to the unit.

Then with a trigger you start your script when the group is not alive.

Hope you understand what I mean :)

Share this post


Link to post
Share on other sites

You need to place a functions manager before any function would work.

Share this post


Link to post
Share on other sites

You lost me sorry :) I have only tried to learn all the scripting for a short time, i'm already glad that I get most of the basic stuff working so far.

Well, the most important thing (create/spawn vehicles) works so thats good. The mission will only be a bit more hardcore when a vehicle is lost and not replaced with a new one.

I will give this a rest for now before I get a headache from it and continue with other stuff in the mission :P

---------- Post added at 02:53 PM ---------- Previous post was at 02:51 PM ----------

You need to place a functions manager before any function would work.

Yes it contains a function module and a gamelogic trigger named 'Server' for the respawn script to work. Or do I have to give the module a name as well?

Share this post


Link to post
Share on other sites
You need to place a functions manager before any function would work.

That's a good point but not the problem in this case.

The code I posted does work but not as you'd expect.

It only works if the car is destroyed the first time using

car1 setdamage 1 

using a weapon the first time will destroy it but not let it respawn.

After you'd destroyed it the first time with setdamage you can then use a weapon against it and it will respawn

I can respawn empty vehicles without a problem

car1 = "HMMWV_MK19_DES_EP1" createVehicle (getMarkerPos "award1"); hint "HMMWV (Mk19) available!";[car1, 12] exec "vehirespawn.sqs";

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×