Jump to content
Sign in to follow this  
santafee

Spawning Units with triggered SQF

Recommended Posts

Hey, i have to spawn some guys with a trigger later in the game.

I found a example to spawn units with SQF, but i did something wrong...

Men1 createUnit ["USMC_Soldier", [6046.9497,300.98999,7761.481], [], 0, "CAN_COLLIDE"];

Men2 createUnit ["USMC_Soldier", [6046.8276,300.99203,7764.0254], [], 0, "CAN_COLLIDE"];

Hint"Units Created";

i tried it easy and made a trigger for the SQF with onact "player exec "Spawn.sqf";

Is something in the SKript wrong or how i call it? Thank you.

Share this post


Link to post
Share on other sites

yes.

exec is for sqs. you have to use

execvm for sqf

player execvm "Spawn.sqf";

Share this post


Link to post
Share on other sites

Ok thanks so far but looks like the Code is not right cause i get the Hint message at the end, but the units dont appear..?

notice that it only worked with

nul=execVM "SpawnMGroup.sqf"; but the units dont appear, only the hint

Edited by Himmelsfeuer

Share this post


Link to post
Share on other sites

umm where did you get this CAN_COLLIDE from ?

_somegroup = group player; // or any other groups
_dude1 ="USMC_Soldier" createUnit[[6046.9497,300.98999,7761.481],_somegroup];
_dude2 ="USMC_Soldier" createUnit[[6046.9497,300.98999,7761.481],_somegroup];

but according to your positions.. you will spawn men 7 KM up in air

Edited by nuxil

Share this post


Link to post
Share on other sites

Huh that works, thanks.

Hm i copied the position from my last mission sqm, where they stand.

how else would i get the exact coordinates, where i need them?

Important is that are spawn as single unit and the direction and the exact position is right......Im a bit confused with the [X,Y,Z] thing from the mission.sqm now..

Share this post


Link to post
Share on other sites

you can forexample place a marker where you want your men to be spawned

the you just use

createUnit[getMarkerpos "MarkerName",_somegroup];

afik there is no moutan 7.7 KM high in arma2 :p

Share this post


Link to post
Share on other sites

omg lol

well yea they should just stand on the ground...

_dude1 ="USMC_Soldier"createUnit[getMarkerpos "M1",_somegroup];

does not work arghhh why?

Share this post


Link to post
Share on other sites

because you need a whitespace

_dude1 ="USMC_Soldier"createUnit[getMarkerpos "M1",_somegroup];

like

_dude1 ="USMC_Soldier" createUnit[getMarkerpos "M1",_somegroup];

Share this post


Link to post
Share on other sites
omg lol

well yea they should just stand on the ground...

_dude1 ="USMC_Soldier"createUnit[getMarkerpos "M1",_somegroup];

does not work arghhh why?

Try this:

_somegroup = createGroup WEST;

_dude1 = "USMC_Soldier" createUnit [(getMarkerPos "M1"), _somegroup];

Share this post


Link to post
Share on other sites

Argh still not working with that space:confused:

Ahh Thanks that works! Last Question, how i set the direction right completly=)^?!

Share this post


Link to post
Share on other sites

_dude1 setdir (getdir player);

depends on what dir you want.

Share this post


Link to post
Share on other sites

Ah k thanks a lot!:)i will try some things with that now

---------- Post added at 07:58 PM ---------- Previous post was at 07:16 PM ----------

If i want to implent the direction for the Unit, like you posted before,where do i have to write it in the code, cause after the 2 lines it did not work..

_somegroup = createGroup WEST;

_dude1 = "USMC_Soldier" createUnit [(getMarkerPos "M1"), _somegroup];

_dude1 setDir 200;

this didnt work..thanks...!

Share this post


Link to post
Share on other sites

that should work

are you sure the dude is not facing south / south west ?

or did you want the dude to move in one direction ?

Share this post


Link to post
Share on other sites

No hes facing allways the same direction..

Maybe it has to be in the line where is set up?

Share this post


Link to post
Share on other sites

hmm strange.. maybe the script is done so fast that while the unit is created the script is already at setdir. therfor it has no unit to setdir on..

try

_dude1 = "USMC_Soldier" createUnit [(getMarkerPos "M1"), _somegroup];

waituntil {(!Isnull _dude1)};

_dude1 setDir 200;

if that doesnt work.. i have no idea.. maybe post you entire script and how you activate it.

Edited by nuxil

Share this post


Link to post
Share on other sites

mh no, not working...

well theres no bigger script actually.Its only to place 5-10 Soldiers for a little Sequenz. I call the SQF File with a simple Trigger :

nul=execVM "SpawnMGroup.sqf";

Share this post


Link to post
Share on other sites

Just tried myself and the unit does take new direction but immediately turn back to original position, dunno why :shrug:

Share this post


Link to post
Share on other sites

yes... i also tested it,, it does exactly what JW said.. strange..

i also tried putting the dir in create command.. nogo

_dude1 = "USMC_Soldier" createUnit [[_px,_py,_pz], _somegroup,"this setdir 200"];

i guess you have to add in dowatch or lookat

Share this post


Link to post
Share on other sites

You can also do a dude stop true; this works but as soon as you set it to true he will return to original direction!

---------- Post added at 08:51 PM ---------- Previous post was at 08:47 PM ----------

Use the doStop command that works. doStop dude;

So doing something like this works:

_somegroup = createGroup WEST;

"USMC_Soldier" createUnit [getMarkerPos "M1", _somegroup,"dude = this ;", 0.5, "corporal"];

sleep 3;

_dir = direction dude;

dude setDir _dir - 180;

doStop dude;

waituntil {!alive dude};

hint "dude is dead";

Share this post


Link to post
Share on other sites

Wow allways gets complicated...

_somegroup1 = createGroup WEST;

_dude1 = "USMC_Soldier" createUnit [(getMarkerPos "M1"), _somegroup1];

sleep3;

_dir = direction _dude1;

_dude1 setDir _dir - 180;

doStop dude;

....did not work,wheres the mistake again;-(

Share this post


Link to post
Share on other sites
Wow allways gets complicated...

_somegroup1 = createGroup WEST;

_dude1 = "USMC_Soldier" createUnit [(getMarkerPos "M1"), _somegroup1];

sleep3;

_dir = direction _dude1;

_dude1 setDir _dir - 180;

doStop dude;

....did not work,wheres the mistake again;-(

This could be the problem. _dude vs dude.

Share this post


Link to post
Share on other sites
damn ...nope

also tried dude only instead _dude :(

Then try this and only edit the direction value:

_somegroup = createGroup WEST;

"USMC_Soldier" createUnit [getMarkerPos "spawn", _somegroup,"dude = this ;", 0.5, "corporal"];

dude setDir 140;

doStop dude;

This is tested and working.

Share this post


Link to post
Share on other sites

hmm..

i tried you code sinppet JW Custom

it doesnt work for me.. i tried setting 90 deg..

he spawns.. changes to dir 90, then turn back up north, "0" then he starts to watch W..

damn stupid AI..

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  

×