Jump to content
  • 0

'line 30: getpos is undefined variable in expression _box1


Darihon

Question

Hello,

 

I'm here with my next problem. I've made a static location for my "mission" and I want the box to spawn there, but it keeps giving me this annoying error as shown in the title above.

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: TODO: Author Name
//////////////////////////////////////////////////////////////////
private ["_HQ","_unitGroup","_box1","_squad1","_squad2"]; 
sleep 1;
/////////////////////////////////////////////////////////////////
[nil,nil,rTitleText,"The Skalisty Island chest has been spawned.", "PLAIN",10] call RE;
//don't edit this, unless you know what you are doing!
_HQ = createCenter east;
_unitGroup = createGroup east;
EAST setfriend [WEST,0];
west setfriend [civilian,0];
//end -- dont edit -- 
 
staticcoords = [ 
[4896.16,10016.5,0]
];

 
 
 
 
 
 
//PUTS OBJECTS DOWN
 
//creates the box
_box1 = createVehicle ["GERBasicWeapons_EP1",[ _box1 setpos [(getpos staticcoords select 0)+0,(getpos staticcoords select 1)-0]],[],0,"can_collide"];
 
 
//clears the loot that was inside already.
clearmagazineCargoGlobal _box1;
clearweaponCargoGlobal _box1; 
 
_box1 addWeaponCargoGlobal ["M240",2];
_box1 addWeaponCargoGlobal ["M249",1];
_box1 addMagazineCargoGlobal ["ItemBriefcase50oz",1];
_box1 addMagazineCargoGlobal ["ItemGoldBar",5];
 
//Spawn Unit
_squad1 = _unitGroup createUnit ["Bandit1_DZ", [ _squad1 setpos [(getpos _box1 select 0)+2,(getpos _box1 select 1)-6]], [], 10, "PRIVATE"];
_squad2 = _unitGroup createUnit ["Bandit1_DZ", [ _squad2 setpos [(getpos _box1 select 0)-2,(getpos _box1 select 1)+6]], [], 10, "PRIVATE"];
 
//set them to hostile 
[_squad1] joinSilent _unitGroup;
[_squad2] joinSilent _unitGroup;
 
//Add the behaviourS1
_squad1 enableAI "TARGET";
_squad1 enableAI "AUTOTARGET";
_squad1 enableAI "MOVE";
_squad1 enableAI "ANIM";
_squad1 enableAI "FSM";
_squad1 setCombatMode "RED";
_squad1 setBehaviour "COMBAT";
 
//Gives AI Weapons
_squad1 addWeapon "M240";
_squad1 addMagazine "100Rnd_762x51_M240";
_squad1 addMagazine "100Rnd_762x51_M240";
_squad2 addWeapon "M136";
_squad2 addMagazine "M136";

I hope one of oyu can help me, since I ain't able to find the 'mistake' by myself. 

 

Thanks in advance,

 

Darryl

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

you cant use getpos on a position, that wont work ... try this:

//creates the box
_box1 = createVehicle ["GERBasicWeapons_EP1",(staticcoords select 0)],[],0,"CAN_COLLIDE"];

and for the units, try this:
 
//Spawn Unit
_squad1 = _unitGroup createUnit ["Bandit1_DZ", [(getpos _box1 select 0)+2,(getpos _box1 select 1)-6], [], 10, "FORM"];
_squad2 = _unitGroup createUnit ["Bandit1_DZ", [(getpos _box1 select 0)-2,(getpos _box1 select 1)+6], [], 10, "FORM"];

you dont actually need to use setpos unless you change direction ... and if you do, use setpos after you changed the direction.

Link to comment
Share on other sites

  • 0

Now I'm getting this error: 

 

1 elements provided, 3 expected. 

_box1 = createVehicle ["GERBasicWeapons_EP1",[(staticcoords select 0)],[],0,"CAN_COLLIDE"];

NVM! Got it working :D

_box1 = createVehicle ["GERBasicWeapons_EP1",(staticcoords select 0),[],0,"CAN_COLLIDE"];

Thank you very much, Halvhjearne!

Link to comment
Share on other sites

  • 0

 

Now I'm getting this error: 

 

1 elements provided, 3 expected. 

_box1 = createVehicle ["GERBasicWeapons_EP1",[(staticcoords select 0)],[],0,"CAN_COLLIDE"];

 

i made an error and it should be:

_box1 = createVehicle ["GERBasicWeapons_EP1",(staticcoords select 0),[],0,"CAN_COLLIDE"];

expecting staticcoords to be an array and this will select the first position in that array

staticcoords = [[4896.16,10016.5,0]];

 ... if you changed static cords to not be in an array,

staticcoords = [4896.16,10016.5,0];

change it so it is not selecting the first element or first element will be the first number of the postion, hence the 1 element provided 3 expected error ..

Link to comment
Share on other sites

  • 0

Alright, got the chest working and spawning now, but the box isn't accesible. 

_box1 = createVehicle ["GERBasicWeapons_EP1",(_pos select 0),[],0,"can_collide"];

_pos is declared:

_pos = staticcoords call BIS_fnc_selectRandom;

 

staticcoords = [ 
[[4896.16,10016.5,0]]
];
Link to comment
Share on other sites

  • 0

lets address this in the right order ...

 

 

_pos is declared:

_pos = staticcoords call BIS_fnc_selectRandom;

 

now _pos is the position, no need to select further as you need all three of these elements ... so this is wrong:

 

_box1 = createVehicle ["GERBasicWeapons_EP1",(_pos select 0),[],0,"can_collide"];

 

should be:

_box1 = createVehicle ["GERBasicWeapons_EP1",_pos,[],0,"CAN_COLLIDE"];
Link to comment
Share on other sites

  • 0

Hmm, strange. 

What you said doesn't work either.

//creates the box
_box1 = createVehicle ["GERBasicWeapons_EP1",[0,0,0],[],0,"CAN_COLLIDE"];
_box1 setpos _pos;

I guess I will stick with 1 static location then ^^.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...