Jump to content
Sign in to follow this  
eagledude4

Event Handlers not working

Recommended Posts

When I enter the vehicle as a pilot, the headgear is not assigned to my player.

class ED_MH9 : B_Heli_Light_01_F {
scope = public;
vehicleClass = "ED_Vehicles";
displayName = "MH-9 Hummingbird (Blue)";
hiddenSelectionsTextures[] = {"ED_Skins\skin_blue_co.paa"};
class eventhandlers {
	init = "this addEventHandler [""GetIn"", {_this execVM ""ED_Vehicles\civilian\air\mh-9\scripts\getin.sqf""}]; this addEventHandler [""GetOut"", {_this execVM ""ED_Vehicles\civilian\air\mh-9\scripts\getout.sqf""}];";
   };
};

getin.sqf:

systemchat "TEST";

if (_this select 1 == "driver") then {
_pilot = _this select 2;
removeHeadgear _pilot;
_pilot addHeadgear "ED_pilotheadset";
};

The scripts are in this directory: "ED_Vehicles\civilian\air\mh-9\scripts"

I used the exact scripts in my mission and it worked fine, but I decided to move the scripts over to the addon instead.

Edited by eagledude4

Share this post


Link to post
Share on other sites

Try a \ before the addon name

Like

{_this execVM ""\ED_Vehicles\civilian\air\mh-9\scripts\getin.sqf

Share this post


Link to post
Share on other sites

I'll give it a try, and if it works, I'll be scratching my head. I've never used the first backslash for any of my texture or model paths.

EDIT: Didn't seem to work =/

Could it be because of the "-" in the path?

init = "this addEventHandler [""GetIn"", {_this execVM ""\ED_Vehicles\civilian\air\[color="#FF0000"]mh-9[/color]\scripts\getin.sqf""}]; this addEventHandler [""GetOut"", {_this execVM ""\ED_Vehicles\civilian\air\[color="#FF0000"]mh-9[/color]\scripts\getout.sqf""}];";

Edited by eagledude4

Share this post


Link to post
Share on other sites

EDIT sorry, scrub this post .... thinking ...

Edited by [APS]Gnat

Share this post


Link to post
Share on other sites

So in the editor its "this" and in the config.cpp its "_this"?

Edited by eagledude4

Share this post


Link to post
Share on other sites

yes i believe so or in editor can be _this inside Brackets because you cant have local variable in global space

Share this post


Link to post
Share on other sites

class eventhandlers {
           init = "_this addEventHandler [""GetIn"", {_this execVM ""\ED_Vehicles\civilian\air\mh-9\scripts\getin.sqf""}]; _this addEventHandler [""GetOut"", {_this execVM ""\ED_Vehicles\civilian\air\mh-9\scripts\getout.sqf""}];";
       };

Still isn't working :(

Edited by eagledude4

Share this post


Link to post
Share on other sites

First i dont have Arma3 loaded so sorry for guss work .

A : Are you sure Getin and Getout handlers are present in A3 Beta ?

B : usually an ID is given for exmple MyGetin = _this addeventhandler blah blah

C: are you sure that _this execvm is the correct parameter to send , what is the sequence obviously when getin is activated does it send the vehicle the person or everything above and is that erroring the script thats recieving it ?

sometimes (_this select 0) or th first identity of the handler is all thats required to b sent .

it could also be something more simple like you said with the Path , but the Arma.rpt is usually telling full story

i would probably try

class eventhandlers {

getin = " {_this execVM ""\ED_Vehicles\civilian\air\mh-9\scripts\getin.sqf""};";

getout = "{_this execVM ""\ED_Vehicles\civilian\air\mh-9\scripts\getout.sqf""};";

};

the above is not correct in syntax soorry once again but you get ide i hope

Edited by Thromp

Share this post


Link to post
Share on other sites

I placed down the mh9 in the editor and applied the eventhandlers and everything works that way. This is the init line found in the mission.sqm:

init="this addEventHandler [""GetIn"", {_this execVM ""ED_Vehicles\a3\airmh-9\scripts\getin.sqf""}];   this addEventHandler [""GetOut"", {_this execVM ""ED_Vehicles\a3\airmh-9\scripts\getout.sqf""}];";

However, when I use the same code for the vehicle class, it doesn't work. I can't find anything about it in the RPT either.

http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers#GetIn

So if there are no errors, and the same code works through the editor, is it safe to assume that this is a bug with the beta?

Edited by eagledude4

Share this post


Link to post
Share on other sites

drop a hint in the sqf if you havent already

HintSilent " its in the script"

if its not firing then it would seem there maybe an error in the Beta as you say

Share this post


Link to post
Share on other sites

Afaik, you dont need the Double " . Im Not at home so i cant Test it, might therefore be mistaken.

Share this post


Link to post
Share on other sites

@Thromp: I have a systemChat notification in the sqf, that's how I found out it worked in the editor.

@Mantis: You actually do need the double quotes.

Share this post


Link to post
Share on other sites

If the beta isnt broke it maybe its just not picking up your init or the class is being overridden because of inheritance

Try adding the handler in an init.sqf and put a sleep there to delay the activation. If you dont need any delays you could also precompile your getin sqf and use call

Share this post


Link to post
Share on other sites

I just found this in my rpt:

Error in expression <_this addEventHandler ["GetIn", {_this execVM >
 Error position: <addEventHandler ["GetIn", {_this execVM >
 Error addeventhandler: Type Array, expected Object

Share this post


Link to post
Share on other sites

this works here ok just tested this try in config.cpp

class EventHandlers
	{
	  getin = " _this execvm ""hello.sqf""	";
	};

sqf =

Hint Format ["%1,%2 %3", _this select 0,_this select 1,_this select 2];

returns correct

Vehicle , Position ,Person entering

as per

   
   vehicle: Object - Vehicle the event handler is assigned to
   position: String - Can be either "driver", "gunner", "commander" or "cargo"
   unit: Object - Unit that entered the vehicle 

Share this post


Link to post
Share on other sites

Thanks, Thromp. I think I understand how to use the event handlers in the event handlers class now.

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  

×