Jump to content
Sign in to follow this  
OmniMax

Checking if a person is inside a vehicle?

Recommended Posts

I'm having some problem with some code to check if a person is inside a static defense weapon. Whenever I run the script I crash with an error 7.

Here is the code in question:

#check
if ((assignedGunner c130_nose) == 0): Hint format["Nobody inside!"]
end

I'm assuming a null object returns 0, I just don't know syntactically what is wrong with the code.

Share this post


Link to post
Share on other sites

You can use this:

if (isNull assignedGunner pod) then { 
       hint "No one inside!"; 
   } else { 
       hint format["This guy is gunning: %1", assignedGunner pod];
};

Edited by kylania
Figured it out. :)

Share this post


Link to post
Share on other sites

Thank you, I skipped ARMA so I'm not sure when they abandoned the poor goto scheme of scripting or if you could always use C style braces. I never knew this and it will make life a lot easier.

If I wanted to execute the command of the activating unit of the script (command added via AddAction) and as far as the OFP days go:

_unitWithAction = _this select 0;

_activatingUnit = _this select 1;

_actionIndex = _this select 2;

So why doesn't this line of code work?

if (isNull assignedGunner pod) then { 
(_this select 1) moveInGunner pod;
   } else { 
       hint format["This guy is gunning: %1", assignedGunner pod];
};

The pod is empty yet the activating unit doesn't get moved into the empty pod. _this select because the array is made when you invoke AddAction and _ActivatingUnit already exists, correct?

EDIT: Okay, it works, but not when the action is invoked inside a vehicle, because the activating unit is whatever vehicle you're in. Wonder how to solve this one... any ideas?

Edited by OmniMax

Share this post


Link to post
Share on other sites

Might be since _this is local, but who is calling that action from what?

If it's an action that seems to indicate that it's a player doing this, and if it's a player and a static gun, why not just have them use the default 'Get In' option?

What's the scenario for this action/gun/thingie? :)

Edit: Ahh, I see, so this is an AC-130 type thing, trying to get a gunner into an attachTo'd weapon from inside?

Edited by kylania

Share this post


Link to post
Share on other sites

Ah, it isn't doing moveInGunner because it thinks the activation is the vehicle you're in and moveInGunner/moveIn series requires a soldier argument.

What I'm trying to accomplish?

Something like this:

arma22009-07-0901-31-09-60-1.jpg?t=1247117798

Ever since OFP and seeing the juicy VBS and VBS2 videos, people have wanted a way to either walk in vehicles or have multiple gun positions per vehicle. So I've attached these M2s on a C130 with attachTo and it works pretty well. I haven't tested it out in multiplayer yet, though. If it works, the implications are really good for modders and such.

My game mode is simple: Two C-130s with their appropriate OPFOR/BLUFOR attached machine guns "dogfight" each other. The M2s are going to be invulnerable with an event handler, but the guys in the guns are not invulnerable (tested). If a pilot/gunner dies, he is respawned in the middle of the ocean with a corresponding trigger. That trigger moves him into his side's C130's cargo. I want the script to be able to put him on the guns outside while being in the C130's cargo.

Whichever C130 dies\runs out of fuel\ammo\crashes first loses. Simple and mindless fun and proof-of-concept.

However, I'm going to have a problem with this _activatingUnit, whoever is in the C130 and triggers the action is going to pass the C130 as the activating unit, unless you know of some work around?

I appreciate your help thus far. I'm a computer science student and I dwell in C and C++ so the data types of ARMA's engine drive me nuts and I wasn't aware you could use C like braces; but the last time I coded any script I must have been 15 and had very little knowledge of such things.

So, any work around ideas? :confused:

Share this post


Link to post
Share on other sites

My first thought was to use a dialog. I setup a quick test and got it halfway working. I can EITHER get in the C-130 from outside OR get in the M119 from outside, but from inside.. nothing.

To be honest though, vehicle placement and dialogs are well above me, but here's what I got so far. Pretty sure the doGetOut isn't working properly, since it seems to stop at that point.

Update: YAY! Got it working! If you use setPos to yank the player out of the vehicle they are in, you can then immediately plop them back into the OTHER vehicle. Next up would be to make it dynamic, so instead of Player it would be whoever pushed the button.

myPositionPicker.hpp:

class myPositionPicker
{
name=myPositionPicker;
idd=-1;
movingEnable=1;
controlsBackground[]={};
objects[]={};
controls[]={mySeatBtn, myGunnerBtn, myMessage, myBackground, myFrame};

class mySeatBtn:RscButton
{
	idc=-1;
	text="Cargo";
[b]		action="player setpos (getmarkerpos ""suck""); player moveincargo [plane, 2]; closedialog 0;";[/b]
	x=0.366666666666667;
	y=0.32;
	w=0.05;
	h=0.0266666666666667;
};

class myGunnerBtn:RscButton
{
	idc=-1;
	text="Gunner";
[b]		action="player setpos (getmarkerpos ""suck""); player moveingunner pod; closedialog 0;";[/b]
	x=0.3;
	y=0.32;
	w=0.05;
	h=0.0266666666666667;
};

class myMessage:RscText
{
	idc=-1;
	text="Pick your position";
	x=0.3;
	y=0.24;
	w=0.116666666666667;
	h=0.0533333333333333;
};

class myBackground:RscBackground
{
	idc=-1;
	x=0.283333333333333;
	y=0.213333333333333;
	w=0.15;
	h=0.213333333333333;
};

class myFrame:RscBgFrame
{
	idc=-1;
	x=0.283333333333333;
	y=0.213333333333333;
	w=0.15;
	h=0.213333333333333;
};
};

pos.sqs:

;Generated by Morten's ArmA Dialog Designer
;Please leave this text here, if you wish
;to support my work on this program.
;Thank you!
~1
_ok = createDialog "myPositionPicker"
exit;

Then each vehicle the plane1 and pod have:

this addAction ["Change Position", "pos.sqs"];

And the standard desc.ent:

//Generated by Morten's ArmA Dialog Designer

//Please leave this text here, if you wish

//to support my work on this program.

//Thank you!

#define CT_STATIC 0

#define CT_BUTTON 1

#define CT_EDIT 2

#define CT_SLIDER 3

#define CT_COMBO 4

#define CT_LISTBOX 5

#define CT_TOOLBOX 6

#define CT_CHECKBOXES 7

#define CT_PROGRESS 8

#define CT_HTML 9

#define CT_STATIC_SKEW 10

#define CT_ACTIVETEXT 11

#define CT_TREE 12

#define CT_STRUCTURED_TEXT 13

#define CT_CONTEXT_MENU 14

#define CT_CONTROLS_GROUP 15

#define CT_XKEYDESC 40

#define CT_XBUTTON 41

#define CT_XLISTBOX 42

#define CT_XSLIDER 43

#define CT_XCOMBO 44

#define CT_ANIMATED_TEXTURE 45

#define CT_OBJECT 80

#define CT_OBJECT_ZOOM 81

#define CT_OBJECT_CONTAINER 82

#define CT_OBJECT_CONT_ANIM 83

#define CT_LINEBREAK 98

#define CT_USER 99

#define CT_MAP 100

#define CT_MAP_MAIN 101

#define ST_POS 0x0F

#define ST_HPOS 0x03

#define ST_VPOS 0x0C

#define ST_LEFT 0x00

#define ST_RIGHT 0x01

#define ST_CENTER 0x02

#define ST_DOWN 0x04

#define ST_UP 0x08

#define ST_VCENTER 0x0c

#define ST_TYPE 0xF0

#define ST_SINGLE 0

#define ST_MULTI 16

#define ST_TITLE_BAR 32

#define ST_PICTURE 48

#define ST_FRAME 64

#define ST_BACKGROUND 80

#define ST_GROUP_BOX 96

#define ST_GROUP_BOX2 112

#define ST_HUD_BACKGROUND 128

#define ST_TILE_PICTURE 144

#define ST_WITH_RECT 160

#define ST_LINE 176

#define ST_SHADOW 0x100

#define ST_NO_RECT 0x200

#define ST_KEEP_ASPECT_RATIO 0x800

#define ST_TITLE ST_TITLE_BAR + ST_CENTER

#define SL_DIR 0x400

#define SL_VERT 0

#define SL_HORZ 0x400

#define SL_TEXTURES 0x10

#define LB_TEXTURES 0x10

#define LB_MULTI 0x20

#define FontM "TahomaB"

#define FontHTML "TahomaB"

class RscText

{

type=CT_STATIC;

idc=-1;

style=ST_LEFT;

colorBackground[]={0, 0, 0, 0};

colorText[]={1, 1, 1, 1};

font=FontM;

sizeEx=0.02;

text="";

};

class RscBgFrame

{

type=CT_STATIC;

idc=-1;

style=ST_FRAME;

colorBackground[]={0.4, 0.4, 0.4, 0.75};

colorText[]={0, 0, 0, 1};

font=FontM;

SizeEX=0.025;

text="";

};

class RscBackground

{

colorBackground[]={0.4, 0.4, 0.4, 0.75};

text="";

type=CT_STATIC;

idc=-1;

style=ST_LEFT;

colorText[]={1, 1, 1, 1};

font=FontM;

sizeEx=0.04;

};

class RscPicture

{

type=CT_STATIC;

idc=-1;

style=ST_PICTURE;

colorBackground[]={0, 0, 0, 0};

colorText[]={1, 1, 1, 1};

font=FontM;

sizeEx=0.02;

text="";

};

class RscButton

{

type=CT_BUTTON;

idc=-1;

style=ST_CENTER;

colorText[]={0, 0, 0, 1};

font=FontHTML;

sizeEx=0.025;

soundPush[]={"", 0.2, 1};

soundClick[]={"ui\ui_ok", 0.2, 1};

soundEscape[]={"ui\ui_cc", 0.2, 1};

default=false;

text="";

action="";

colorActive[]={0, 0, 0, 0};

colorDisabled[]={0, 0, 0, 0.1};

colorBackground[]={0,0,0,0.3};

colorBackgroundActive[]={0,0,0,0.4};

colorBackgroundDisabled[]={0,0,0,0.3};

colorFocused[]={0.84,1,0.55,1};

colorShadow[]={1, 1, 1, 0.1};

colorBorder[]={0, 0, 0, 0.1};

offsetX=0;

offsetY=0;

offsetPressedX=0;

offsetPressedY=0;

borderSize=0;

soundEnter[]={"", 0.15, 1};

};

class RscButton2:RscButton

{

x=-1.0;

y=-1.0;

idc=-1;

w=0.01;

h=0.01;

default=true;

};

class RscEdit

{

type=CT_EDIT;

idc=-1;

style=ST_LEFT;

font=FontHTML;

sizeEx=0.02;

colorText[]={0, 0, 0, 1};

colorSelection[]={0.5, 0.5, 0.5, 1};

autocomplete=false;

text="";

};

class RscLB_C

{

style=ST_LEFT;

idc=-1;

colorSelect[]={0.4, 0.4, 0.4, 1};

colorSelectBackground[]={0.2, 0.2, 0.2, 1};

colorText[]={0.2, 0.2, 0.2, 1};

colorBackground[]={0.4, 0.4, 0.4, 1};

font=FontHTML;

sizeEx=0.025;

rowHeight=0.04;

};

class RscListBox:RscLB_C

{

soundSelect[]={"", 0.1, 1};

type=CT_LISTBOX;

};

class RscCombo: RscLB_C

{

type=CT_COMBO;

wholeHeight=0.3;

soundSelect[]={"", 0.15, 1};

soundExpand[]={"", 0.15, 1};

soundCollapse[]={"", 0.15, 1};

};

class RscSliderH

{

access=0;

type=CT_SLIDER;

idc=-1;

sizeEx=0.025;

style=1024;

color[]={0.2, 0.2, 0.2, 1};

colorActive[]={1, 1, 1, 1};

};

class RscSliderV

{

access=0;

type=CT_SLIDER;

idc=-1;

sizeEx=0.025;

style=0;

color[]={0.2, 0.2, 0.2, 1};

colorActive[]={1, 1, 1, 1};

};

#include "myPositionPicker.hpp"

You'll definately want to read up on the SQF Syntax changes. :)

Edited by kylania

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  

×