LordHorusNL 0 Posted October 21, 2005 I need to trigger an event after a weapon has fired more than 3 time, but i cant get this script to work. Anybody knows what i'm missing here? _Tank = _this select 0 _weapon = _this select 1 ;hint format["fired: %1", _weapon] _weaponfired = "Main_Rocket" ?_weapon = _weaponfired: goto "loop" exit _count = 0 #loop _count = _count + 1 ?_count > 3:goto "End" goto "loop" #End _Tank setobjecttexture [47,""] exit Share this post Link to post Share on other sites
bn880 5 Posted October 22, 2005 To get you started; In a conditional statement use '==' not '=' Share this post Link to post Share on other sites
LordHorusNL 0 Posted October 22, 2005 Thanks for the tip but it doesnt really get me where i need to go Also does anybody know if it is possible to get dammage from a specific part of a tank, lets say the turret or tracks? Share this post Link to post Share on other sites
hardrock 1 Posted October 22, 2005 Doesn't work, since the script runs through the loop once without waiting for the two further shots. It looks as if you want to script this for an addon, thus you can't effectively use global variables. Instead I recommend to use a 'dummy animation' : Place a vertex somewhere in your Memory LOD, give it a selection name "dummy", also create two further points named "osa dummy". Create an animation for it in the Animations class of your addon (config.cpp -> CfgVehicles -> ... -> class your_addon -> class Animations) <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class fired { type="rotation"; animPeriod=0.000001; selection="dummy"; axis="osa dummy"; angle0=0; angle1=3.141592; }; Now you need the following function (why? functions are preloaded and work more effectively with fired EHs) fired.sqf <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_u",_"w","_a"]; _u = _this select 0; _w = _this select 1; if(_w=="Main_Rocket") then { _a = (_u animationPhase "fired") + 0.1; _u animate ["fired", _a]; }; if(_a>0.2) then { _u setObjectTexture [47, ""]; _u animate ["fired", 0]; }; In your addon's init script / init eventhandler load the function: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">TAG_TANKPACK_FIRED = loadFile "\Addon\fired.sqf" In your addon's fired eventhandler add the following code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_this call TAG_TANKPACK_FIRED * TAG_TANKPACK_FIRED can be named anyway of course. But I recommend to include your OFPEC tag and the name of your addon in it Share this post Link to post Share on other sites
LordHorusNL 0 Posted October 22, 2005 Nope didnt work, and i did correct this error "">private["_u","_w","_a"];<"" The idea is to just have a script that simulates a reactor overload, so each time a weapon is fired the script adds +1 to the count and when it reaches say "10" the tank explodes or something. I need something that is as basic as it can be. Share this post Link to post Share on other sites
Platoon_Patton 0 Posted October 22, 2005 I need something that is as basic as it can be. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired", {if(((((_this select 0) ammo (_this select 2)) - 1)== 27) and ((_this select 1) == "Main_Rocket")) then {hint "Exec code now"}}] The number 27 assumes the number of shots left after the 3rd shot in a 30 clip magazine... If U have 8 shots U need to use 5. OFFTOPIC: (_this select 0) ammo (_this select 2) returns 30 after u shot 1 time with a M16.While the ammocounter shows 29 ingame  When U are out of ammo it returns 1  Anybody can explain this? Thats why i did ((_this select 0) ammo (_this select 2) - 1) Share this post Link to post Share on other sites