Jump to content
Sign in to follow this  
McArcher

Moving units placed in editor

Recommended Posts

I have placed several playable units on map in Editor. they are named like "RU_player_1", "RU_player_2", and so on. I want to move them to another position when the game starts by this code:

// moving players to base RU

marker_name_prefix_RU = "RU_player_";

for "i" from 1 to max_side_size do

{

(marker_name_prefix_RU + str i) setPos [(respawn_east_pos select 0) + (i - 7)*5, (respawn_east_pos select 1) +20];

};

respawn_east_pos is set correctly, because I see dynamically created vehicles around it. But starting units dont change their positions. Error says:

Error in expression <ze do

{

(marker_name_prefix_RU + str i) setPos [(respawn_east_pos select 0) + (i>

Error position: <setPos [(respawn_east_pos select 0) + (i>

Error setpos: Тип ПоÑледовательноÑть, ожидаетÑÑ ÐžÐ±ÑŠÐµÐºÑ‚

Translation of last string quoted is: Error setpos: Type Sequence, expected Object.

Please help, why this doesn't work. How to move starting positons for playable units via script?

---------- Post added at 12:24 AM ---------- Previous post was at 12:19 AM ----------

for [{i=1},{i<=max_side_size},{i=i+1}] do

doesn't help either :(

---------- Post added at 01:26 AM ---------- Previous post was at 12:24 AM ----------

_SideHQ_RU = createCenter east;

_group1_RU = createGroup east;

_group1_RU setGroupId ["Crazy People", "GroupColor2"];

_tmp_soldier = "RU_Soldier" createVehicle [(respawn_east_pos select 0) + (i - 7)*5, (respawn_east_pos select 1) +20, 0];

setPlayable _tmp_soldier;

created a soldier, but he is not seen as a playable role at start.

"RU_Soldier" createUnit [ [(respawn_east_pos select 0) + (i - 7)*5, (respawn_east_pos select 1) +20, 0], _group1_RU, ""];

setPlayable "RU_Soldier";

doesn't do anyting :( doesn't even create any living being :(

Share this post


Link to post
Share on other sites

There seem to be two problems.

RU_player_1 setPos [(getpos respawn_east_pos select 0) + (i - 7)*5, (getpos respawn_east_pos select 1) +20];

should move one player however (marker_name_prefix_RU + str i) fails as it now becomes a string not an object.

I don't know how to make a string back into an object.

I think what's happening is that (marker_name_prefix_RU + str i) instead of RU_player_1 is doing this "RU_player_1" if that makes sense

---------- Post added at 02:26 AM ---------- Previous post was at 01:33 AM ----------

Maybe you could use a trigger placed over the units

Set anyone present

on act null=[thislist] execVM "codename.sqf";

and the code

objects = _this select 0;
c=0;
{
  _x setPos [(getpos respawn_east_pos select 0) + (c - 7)*5, (getpos respawn_east_pos select 1) +20];
c=c+1; 
 } foreach objects;

Edited by F2k Sel

Share this post


Link to post
Share on other sites
RU_player_1 setPos [(getpos respawn_east_pos select 0) + (i - 7)*5, (getpos respawn_east_pos select 1) +20];

is working!

big-big thanks to you! Next step is to use array of this objects. I think it will work too.

Share this post


Link to post
Share on other sites

Using thislist in a trigger will puts the units found there in an array for you.

A very good command when you get the hang of it.

Share this post


Link to post
Share on other sites

i decided not to make "function calls" (if they can be named here so), but used just simpe code

// moving players to base RU

RU_players = [RU_player_1, RU_player_2, RU_player_3, RU_player_4, RU_player_5, RU_player_6, RU_player_7, RU_player_8, RU_player_9, RU_player_10, RU_player_11, RU_player_12, RU_player_13, RU_player_14, RU_player_15];

i = 0;

{

_x setPos [(respawn_east_pos select 0) + (i - 7)*5, (respawn_east_pos select 1) +20, 0];

i=i+1;

} foreach RU_players;

it works! thanks!

i think it can even be optimized (to put "respawn_east_pos select 0" and "respawn_east_pos select 1' into a variable to decrease time of calculations, i wonder if BIS compiler automatically does this?)

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  

×