Jump to content
Sign in to follow this  
quakergamer

Problem with addeventhandler

Recommended Posts

Hello,

I execute on a soldier a script called SoldierInit.sqs. Here is what I doesnt work:

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

_soldier = _this select 0

...

#SoldierIsPlayer

_soldier removeAllEventHandlers "init"

_soldier addEventHandler ["fired",{"[_this select 0, _this select 1, _this select 2, _this select 3] exec ""\OPGWC_FX\ChupChup\WeaponJamRiffle.sqs"", [_this select 0, _this select 1] exec ""\OPGWC_FX\WeaponFX\backblast_detection.sqs"""}]

_soldier addEventHandler ["hit",{"[_this select 0] exec ""\OFPEC_Blood\blood_squirt.sqs"""}]

goto "Exit"

...

There are NO errors in-game but the problem is that NONE of those scripts get executed when fired, hit ,etc...

So I'm asking you guys if you know how to fix this!

Share this post


Link to post
Share on other sites

You're mixing something up here: In all OFP scripts you can replace quotes (") with braces ({,}). If you write your execution part in braces, everything inside will be executed.

So<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_soldier addEventHandler ["init", {"blabla..."}]will execute nothing than ... a string!

Instead you have to write f.i.<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_soldier addEventHandler ["init", {[this,that] exec "myscript.sqs"}]What do we notice here? You can use single quotes, since you wrote the command in braces.

You can also use quotes instead of the braces, but then all the quotes inside the command had to be double quotes like in the cpp, and that would be complicated

wink_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  

×