snkman 351 Posted August 19, 2007 Hey guy's, well i need to add an eventhandler "Fired" only to vehicles of the class "Tank". So far i always made it with: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (GL2Plus_SoundFX) then {{_x AddEventHandler ["Fired", { _a = _this select 0; // Check if FX should be used if (GL2Plus_ShellEffect && _a isKindOf "Tank") then { // Check if group player is big enough, if yes Shell Effects are activated if ("Tank" countType _this > 0) then {call (GL2PlusInternal select 4) exec "GL2Plus\GL2Plus_Effects\Ammo_Range\Shell_Fired.sqs"} }; // Check if FX should be used if (GL2Plus_ShellEffect && _a isKindOf "Tank") then { // Check if group player is big enough, if yes Shell Effects are activated if ("Tank" countType _this > 0) then {_this exec "GL2Plus\GL2Plus_Effects\Tank_Shock\Shock.sqs"}}}]} } forEach vehicles; But the "forEach vehicles" will add the Event handler to all vehicles at the map and i think i can save some resources by only adding it to a specific class. ( In this case "Tank" ) So someone with a idea how i could do that? Share this post Link to post Share on other sites
dr_eyeball 16 Posted August 19, 2007 Just add [if (_x isKindOf "Tank")] inside the forEach loop. Then you can probably delete the [_a isKindOf "Tank"] later. I think that's all you wanted. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (GL2Plus_SoundFX) then { { if (_x isKindOf "Tank") then { _x AddEventHandler ["Fired", { _a = _this select 0; // Check if FX should be used if (GL2Plus_ShellEffect && _a isKindOf "Tank") then { // Check if group player is big enough, if yes Shell Effects are activated if ("Tank" countType _this > 0) then {call (GL2PlusInternal select 4) exec "GL2Plus\GL2Plus_Effects\Ammo_Range\Shell_Fired.sqs"} }; // Check if FX should be used if (GL2Plus_ShellEffect && _a isKindOf "Tank") then { // Check if group player is big enough, if yes Shell Effects are activated if ("Tank" countType _this > 0) then {_this exec "GL2Plus\GL2Plus_Effects\Tank_Shock\Shock.sqs"} } }] } } forEach vehicles; }; Share this post Link to post Share on other sites
snkman 351 Posted August 19, 2007 Thank you very much Dr_Eyeball i will try it. EDIT: Working! Share this post Link to post Share on other sites