Jump to content
Sign in to follow this  
Skul

"Fired" eventhandler for hand grenades

Recommended Posts

I've searched, but couldn't find anything. If I've missed a topic which solves this, please point me in the right direction. Thanks. smile_o.gif

Okay, I need to know how to make a script run when the player throws a hand grenade and/or when the grenade explodes. I've managed to use the fired eventhandler work for when the player fires his rifle, but not when a grenade is thrown, or explodes.

I've got this in a trigger:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addEventHandler ["fired",{if ((_this select 1) == "AK74") then {[] exec "firedweap.sqs"}}]

Which works fine.

I've tried the same in another trigger:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addEventHandler ["fired",{if ((_this select 1) == "handgrenade") then {[] exec "firedweap.sqs"}}]

Which doesn't work at all. Can grenades be detected?

[Gareth Gates must die]

Share this post


Link to post
Share on other sites

you could looped count the amount of handgrenades and if one is missing fire your desired action. I´m quite sure though that the eventhandler should work with nades also...

Share this post


Link to post
Share on other sites

Just sidechat _this on your fired EH, that will display all the information you need.

Share this post


Link to post
Share on other sites

I have your solution , you must not use "handgrenade" , the correct code to detect a grenade being launched by a soldier , in your situation is

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addEventHandler ["fired",{if ((_this select 1) == "throw") then {[] exec "firedweap.sqs"}}]

When you are in doubt of what to use in this case, use ni your soldier init to know the exact name to put

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler ["Fired",{hint format ["%1",_this select 1]}]

I found this "what is the name of the fired weapon" code in the ME FAQ pinned up there , long time ago so i can't point you to the exact page.

Share this post


Link to post
Share on other sites

Thanks for the responses, guys! smile_o.gificon14.gif

Why can't anything in OFP editing be obvious? biggrin_o.gif

[Gareth Gates must die]

Share this post


Link to post
Share on other sites
I have your solution , you must not use "handgrenade" , the correct code to detect a grenade being launched by a soldier , in your situation is

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">player addEventHandler ["fired",{if ((_this select 1) == "throw") then {[] exec "firedweap.sqs"}}]

When you are in doubt of what to use in this case, use ni your soldier init to know the exact name to put

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler ["Fired",{hint format ["%1",_this select 1]}]

I found this "what is the name of the fired weapon" code in the ME FAQ pinned up there , long time ago so i can't point you to the exact page.

I give directions and you give free rides, shame. biggrin_o.gif

wink_o.gif

Share this post


Link to post
Share on other sites

he he . tounge_o.gif

Next time i will try to make the answer available through a riddle using a mix of latin and ancient greek.

biggrin_o.gif

Share this post


Link to post
Share on other sites

Thanks Sanctuary. That saves us days of searching and errors trying to figure it out. One sample is worth 20,000 pages of directions written by people who fully understand the subject. tounge_o.gif Espically when all we wanted was a Rope, a Tyre and a Tree while we were were young enough to have fun on a swing. ROFLMAO

Share this post


Link to post
Share on other sites

Is there also a script for adding magazines when a mag is empty? Like counting the bullets the player has fired?

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  

×