saamziel Posted February 23, 2010 Share Posted February 23, 2010 im trying to make a auto healing weapon but i cant get it to work can anyone tell what im doing wrong thanks mucho scn timerTestScript float fEndTime Begin OnEquip ; Initialisation set fEndTime to getSecondsPassed - 1; 1 seconds from now ... if getSecondsPassed > fEndTime; The timer has finished If player.GetWeaponHealthPerc < 99; do stuff player.ModWeaponHealthPerc 5 set fEndtime to 1 endif endif End Link to comment Share on other sites More sharing options...
GrandsonOfSam Posted February 23, 2010 Share Posted February 23, 2010 Here's some solutions, although I haven't tested them myself ingame. If you really want to use a timer, just for the sake of using one:scn timerTestScript float fEndTime Begin GameMode;Begin OnEquip runs ONLY once thru the script, unless you use Label and Goto from FOSE. GameMode runs untill you unequip it. set fEndTime to 1 if fEndTime > 0 set fEndTime to fEndTime - GetSecondsPassed elseif player.GetWeaponHealthPerc < 99 player.ModWeaponHealthPerc 1;No need for higher percent as it will be at 100 after a few seconds wait anyway. set fEndtime to 1 endif End This is how I would do it personally:scn timerTestScript Begin GameMode;This is somewhat simpler way to do it, and does it realtime. if player.GetWeaponHealthPerc < 99 player.ModWeaponHealthPerc 1 endif End If you want to make an "indestructible" weapon, you can also just edit the weapon's health to 50000 or something. I hope that helps :) Link to comment Share on other sites More sharing options...
rjhelms84 Posted February 23, 2010 Share Posted February 23, 2010 This script only runs once, when you first equip the weapon. There is no loop to it, if you know what I mean. It has to begin on gamemode in order to recheck itself continuously, because gamemode is a condition that occurs constantly, whereas onequip is just a condition that occurs for a moment. Does that make sense? Here's an example of a timer I used: scn myscriptname short taskfloat MITtimer Begin onactivate player If task == 0 playmagiceffectvisuals glowingonegloweffect Set Task to 1 Set M1Timer to 3 Endifend Begin GameMode If (Task) If M1Timer > 0 Set M1Timer to M1Timer - GetSecondsPassed Else stopmagiceffectvisuals glowingonegloweffect myDoorRef.activate player Set task to 0 endif Endifend I'm not an expert scripter myself. Someone helped me as well. Hope this helps. Rob Link to comment Share on other sites More sharing options...
rjhelms84 Posted February 23, 2010 Share Posted February 23, 2010 You can't just begin on gamemode though, like that other guy's script suggests. You have to start with onequip, or your script will apply to every weapon you hold. Link to comment Share on other sites More sharing options...
rjhelms84 Posted February 23, 2010 Share Posted February 23, 2010 Try this: scn timerTestScript float fEndTime Begin OnEquip ; Initialisation set fEndTime to getSecondsPassed - 1; 1 seconds from now end Begin GameMode if getSecondsPassed > fEndTime; The timer has finished If player.GetWeaponHealthPerc < 99; do stuff player.ModWeaponHealthPerc 5 set fEndtime to 1 endif endif End Link to comment Share on other sites More sharing options...
GrandsonOfSam Posted February 23, 2010 Share Posted February 23, 2010 Sorry, like rjhelms84 corrected, you need the OnEquip section, as the script itself doesn't check what the item it is. My example will (as noted) end up healing all weapons in your inventory. That is the reason I use FOSE myself, as with it the control on everything is way easier to maintain. Link to comment Share on other sites More sharing options...
saamziel Posted February 24, 2010 Author Share Posted February 24, 2010 hi thanks you both helped so much on helping me understand timers it works perfectly thanks again Link to comment Share on other sites More sharing options...
Recommended Posts