Forum Jump :

Author Message

hotas  



Posts: 21
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2009-03-30 18:09        
     
I'm working on a teleport to near a vehicle, I'm missing something because the teleported player spwans center of the vehicle.

I have tried:
unit setPos [(getPos "vehiclename") select 0, (getPos "vehiclename") select 1, 0]

if I'm not mistaken you have to change the second entry after the comma to value to change the y position. Trying this results in the player in the water. Please help.


Author Message

W0lle  

call me evil


Posts: 1960
Rank:


Country: de
Location:
Occupation: CWR² Project Lead
Age: 103
In-game name:

 
#2 Posted at 2009-03-30 19:11        
     
This is what I'm using:

unitname setPos [((getPos objectname select 0)+5),((getPos objectname select 1)+5),0]

You need to play with the values a bit until you get the position right. +5 can be inverted by using -5 for example. 0 value is the center of the vehicle.


Advertisement


Author Message

hotas  



Posts: 21
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2009-03-30 19:37        
     
Thanks WOlle,
in this statement:
unitname setPos [((getPos objectname select 0)+5),((getPos objectname select 1)+5),0]

I'm not understanding, is the select =false(0) then Select = true(1)? Could you point me in the right direction on how the brackets and squiggles are used while making a statement.


Author Message

W0lle  

call me evil


Posts: 1960
Rank:


Country: de
Location:
Occupation: CWR² Project Lead
Age: 103
In-game name:

 
#4 Posted at 2009-03-30 20:10        
     
no 0 and 1 has nothing to do with true false here, it's first and second position (x and y).


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 49
In-game name: Myke

 
#5 Posted at 2009-03-30 20:33        
     
short description about the brackets:

Square brackets: [ ]
Those are used for arrays. A array is a list with multiple values separated by commata. Most common use is for positions:
[x, y, z]
These three values represent an exact 3D position, containing longitude, latitude and height.
Individual values inside an array are accessed by the "select" command, followed by a number which represents the position of the value inside an array. This position is zero-indexed so the first value is "select 0", the second is "select 1" and so on.
Inside a script this could look like this:
_3d_pos = [0.00000, 0.00000, 0.00000];
_longitude = _3d_pos select 0;
_latitude = _3d_pos select 1;
_height = _3d_pos select 2;


Round brackets: ( )
Those are used as in standard mathematics. So they make sure that certain calculations are made in correct order. Taking W0lle's code as example:
((getPos objectname select 0)+5)
read as:
get position of object "objectname" (which returns a 3d array, remember), select first value (select 0) and add 5 to this number.


Hope this brings some light into the coding.


OT: It is W0lle with a zero, not WOlle. :D


Author Message

hotas  



Posts: 21
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2009-03-30 20:57        
     
many many thanks this did cut down on some questions.

P.S.
Sorry for the WOlle spelling, guess spell check missed one hee hee


Author Message

W0lle  

call me evil


Posts: 1960
Rank:


Country: de
Location:
Occupation: CWR² Project Lead
Age: 103
In-game name:

 
#7 Posted at 2009-03-30 21:14        
     
Don't worry about the spelling. You have no idea what variations people came up with in the past. :)


Author Message

hotas  



Posts: 21
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#8 Posted at 2009-03-30 21:44        
     
Hopefully the last question about this. How would you incorporate a way to spwan in the same direction of the unit?
This is what I'm using:

unitname setPos [((getPos objectname select 0)+5),((getPos objectname select 1)+5),0];unitname setdir getdir objectname;

Thanks again.


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 49
In-game name: Myke

 
#9 Posted at 2009-03-30 21:55        
     
If your code wont work, try to work with round brackets:

unitname setdir (getdir objectname);

First things first. Before you can apply a direction you need to determine the direction previously. So the brackets should make sure the line gets the required direction first and then it applies it to the unit.


Author Message

hotas  



Posts: 21
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#10 Posted at 2009-03-31 01:00        
     
Thanks all. The problem is if I move the unit the player still tele's to the unit's original spwan position. Here's what I have so far anymore suggestions on how to make this work would be great.
[/code]class Groups
	{
		items=2;
		class Item0
		{
			side="WEST";
			class Vehicles
			{
				items=1;
				class Item0
				{
					position[]={9791.395508,139.994995,10059.310547};
					azimut=187.391998;
					id=0;
					side="WEST";
					vehicle="ACE_SoldierWB";
					player="PLAYER COMMANDER";
					leader=1;
					skill=0.600000;
					text="me";
					init="this setdir getdir mobilebase";
				};
			};
		};
		class Item1
		{
			side="LOGIC";
			class Vehicles
			{
				items=1;
				class Item0
				{
					position[]={9677.227539,139.994995,10109.667969};
					id=2;
					side="LOGIC";
					vehicle="Logic";
					leader=1;
					skill=0.600000;
					text="teleport";
					init="this setPos [(getPos mobilebase select 0),((getPos mobilebase select 1)-5),0]; ";
				};
			};
		};
	};
	class Vehicles
	{
		items=2;
		class Item0
		{
			position[]={9730.525391,139.994995,9972.595703};
			id=1;
			side="EMPTY";
			vehicle="FlagCarrierWest";
			skill=0.600000;
		};
		class Item1
		{
			position[]={9774.609375,139.994995,10036.179688};
			id=3;
			side="EMPTY";
			vehicle="M113_MHQ";
			skill=0.600000;
			text="mobilebase";
		};
	};
	class Sensors
	{
		items=1;
		class Item0
		{
			position[]={9796.583008,139.994995,9989.653320};
			a=0.000000;
			b=0.000000;
			activationBy="ALPHA";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			expActiv="player setpos getPos teleport";
			class Effects
			{
			};
		};
	};


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 49
In-game name: Myke

 
#11 Posted at 2009-03-31 01:18        
     
I assume you don't have a script which moves the gamelogic continuosly with the mobilebase. The way you try this would be necessary.

However, for now the most simple way is to remove the gamelogic and in the trigger replace teleport with mobilebase. Or more precise:
player setpos [(getPos mobilebase select 0),((getPos mobilebase select 1)-5),0];


Author Message

hotas  



Posts: 21
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#12 Posted at 2009-03-31 01:48        
     
THANKS :yes