Jump to content
Sign in to follow this  
hellfish6

Eventhandlers

Recommended Posts

Yo

I'm working on the NAFP soldiers and I want to get three seperate inits running via EHs. I know how to call up one EH just fine, but with multiples I'm getting a bit lost.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers {

Init = [_this select 0] exec "\nafinf\scripts\init.sqs"; [_this select 0,1] exec "\nafinf\scripts\rocamcrank.sqs"; [_this,"NAFFal","NAFfalmag"] exec "\NAFEvents\onPlayerInit.sqs";

hit = if (player == _this select 0) then {_this call NAFfuncHit};

killed = if (player == _this select 0) then {_this exec "\NAFEvents\onPlayerDeathBlack.sqs"};

fired = if (NAFWeaponFXinit) then {_this call NAFfuncFiredEH};

};

OFP comes up with the following error message when I try to run it:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">'nafinf\config.cpp/cgfVehicles/nafinfsoldierGB/EventHandlers.': "" encountered instead of '='

Any ideas?

Share this post


Link to post
Share on other sites

Heres an example of a proper EH <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init = "[1,0,_this] exec ""\weapon\foldier\script.sqs"";";

Share this post


Link to post
Share on other sites

Still getting the problem. The config works fine when I take out the other two inits, leaving only the first, but not when all three are in there.

My current init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers {

Init = "[_this select 0] exec ""\nafinf\scripts\init.sqs"";";

"[_this select 0,1] exec ""\nafinf\scripts\rocamcrank.sqs"";"; "[_this,"NAFFal","NAFfalmag"] exec ""\NAFEvents\onPlayerInit.sqs"";";

hit = if (player == _this select 0) then {_this call NAFfuncHit};

killed = if (player == _this select 0) then {_this exec "\NAFEvents\onPlayerDeathBlack.sqs"};

fired = if (NAFWeaponFXinit) then {_this call NAFfuncFiredEH};

};

Share this post


Link to post
Share on other sites

I think its because the whole init eventHandler needs to be in quotes. Basically, when you get to the single set of quote marks at the end of the first part of the init EH, OFP interprets that as you being done with that EH, esp. with the semicolon there.

<I think> it ought to look more like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class EventHandlers

{

    Init = "[_this select 0] exec ""\nafinf\scripts\init.sqs""; [_this select 0,1] exec ""\nafinf\scripts\rocamcrank.sqs""; [_this,""NAFFal"",""NAFfalmag""] exec ""\NAFEvents\onPlayerInit.sqs"";"

    hit = "if (player == _this select 0) then {_this call NAFfuncHit}";    

    killed = "if (player == _this select 0) then {_this exec ""\NAFEvents\onPlayerDeathBlack.sqs""}";  

    fired = "if (NAFWeaponFXinit) then {_this call NAFfuncFiredEH}";

};

or, using curled braces instead of quotes:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

class EventHandlers

{

    Init = "[_this select 0] exec {\nafinf\scripts\init.sqs}; [_this select 0,1] exec {\nafinf\scripts\rocamcrank.sqs}; [_this,{NAFFal},{NAFfalmag}] exec {\NAFEvents\onPlayerInit.sqs};"

    hit = "if (player == _this select 0) then {_this call NAFfuncHit}";    

    killed = "if (player == _this select 0) then {_this exec {\NAFEvents\onPlayerDeathBlack.sqs}}";  

    fired = "if (NAFWeaponFXinit) then {_this call NAFfuncFiredEH}";

};

Good luck with it smile_o.gif

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers

{

   Init = "[_this select 0] exec ""\nafinf\scripts\init.sqs""; [_this select 0,1] exec ""\nafinf\scripts\rocamcrank.sqs""; [_this,""NAFFal"",""NAFfalmag""] exec ""\NAFEvents\onPlayerInit.sqs"";"

by putting ; inside the last quote wouldn't that thro up an err?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">exec ""\NAFEvents\onPlayerInit.sqs"" ";

that's how I thought it would be.

Share this post


Link to post
Share on other sites

Scud -

No, the extra ; is just treated as a blank line. I often use it

to separate the double-double quotes, and the end of the

init string.

Share this post


Link to post
Share on other sites

I corrected the last sample of MSMS a bit, that should be working:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class EventHandlers

{

init = "[_this select 0] exec {\nafinf\scripts\init.sqs}; [_this select 0,1] exec {\nafinf\scripts\rocamcrank.sqs}; [_this,{NAFFal},{NAFfalmag}] exec {\NAFEvents\onPlayerInit.sqs}";

hit = "if (player == _this select 0) then {_this call NAFfuncHit}";

killed = "if (player == _this select 0) then {_this exec {\NAFEvents\onPlayerDeathBlack.sqs}}";

fired = "if (NAFWeaponFXinit) then {_this call NAFfuncFiredEH}";

};

I also recommend the method with the curled brakes. The last command inside the string doesn't have to have a semicolon in the end, but each eventhandler has to! (there was an error with the init line.

So

init = "command; command; command;"

is corrected to

init = "command; command; command";

Share this post


Link to post
Share on other sites

Haha, thanks hardrock, you're right, I did overlook that. Knowing the way I code, if it was my mistake as I was working, I'd probably wind up spending an hour or so trying all sorts of crazy crap before finding it too tounge_o.gif

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  

×