Jump to content
Sign in to follow this  
major_upset

Message to show via addeventhandler

Recommended Posts

Ok first off, I've searched the forums with no luck.

I have a mission where the player is in a tank, and I'm after is that every time the tank is hit (but not killed) a message shows. e.g. We've been hit! so as to appear that the crew is freaking out.

I've tried

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init="this addeventhandler [{hit} , {_this exec {crewmessage.sqs}}]";

and

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">init="unitname addeventhandler [{hit} , {_this exec {crewmessage.sqs}}]";

Both in the unit’s init field of the tank and in a trigger.

By the way

The tank is set on the map as empty, with the crew put in it via the movein command. Is this where I’m going wrong?

Also can I make the messages show randomly. E.g. we’ve been hit! or What the hell? if so how? advanced scripting is lost on me. sad_o.gif

Any help would be great. Sorry if this dosn't make any sence.

Share this post


Link to post
Share on other sites

Make sure your tank is empty , and in the init line of that empty tank put :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler [{hit} , {[this] exec {crewmessage.sqs}}]

Then the crewmessage.sqs should be

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

? alive commander _tnk : commander _tnk sidechat "We have been hit !"; exit

? alive gunner _tnk : gunner _tnk sidechat "We have been hit !"; exit

? alive driver _tnk : driver _tnk sidechat "We have been hit !"; exit

exit

this way , when the tank commander is alive, only him will say "We have been hit !"

If there is no tank commander, or if he is dead, it will be the gunner that will say it

If there is only a driver, or if both tank commander and gunner are dead, only the driver will say it.

If none is alive in the tank, none will say anything wink_o.gif

Share this post


Link to post
Share on other sites

Errm... I've just tried it, no luck. OFP comes up with...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">false driver |#|':_tnk error unknown operator  _tnk

I've tried removing all the _tnk entrys with no change. sad_o.gif

I've noticed that the <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler [{hit} , {[this] exec {crewmessage.sqs}}] seems to be unpredictable, the vanila units work but not the addons I'm using. sad_o.gif

Share this post


Link to post
Share on other sites

If you have the eventhandler and the script wrote exactly as i typed them, it works.

So check the synthax of what you typed, as you have done it wrong.

EDIT :

as you added this :

Quote[/b] ]I've noticed that the

Code Sample

this addeventhandler [{hit} , {[this] exec {crewmessage.sqs}}]

seems to be unpredictable, the vanila units work but not the addons I'm using.

It is changing everything, i bet the tank addon you are using have their own eventhandler built in their own config.

And in that case there is unfortunately nothing you can do unless you modify the tank config yourself : built-in eventhandler will ALWAYS produce problems with mission scripting and if you have mission eventhandlers, the vehicles own eventhandlers will just kill such scripts.

That's why i always prefered to use tank that comes without eventhandlers in my missions, as the ones that have their own eventhandlers in their config always get lots of problems with mission scripting.

Share this post


Link to post
Share on other sites
Quote[/b] ]And in that case there is unfortunately nothing you can do unless you modify the tank config yourself : built-in eventhandler will ALWAYS produce problems with mission scripting and if you have mission eventhandlers, the vehicles own eventhandlers will just kill such scripts.

Damn thought that was the case sad_o.gif oh well, I can live with out it, targets over text any day. biggrin_o.gif Thanks for the help anyway.

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  

×