vizex1 Posted August 23, 2019 Share Posted August 23, 2019 Int Percentage = 0 Int MyTimerID = 123 ; Whatever number works, is just to keep track of the timer you want to start/cancel Function StartMyTimer() Percentage = 0; Set the percentage to 0 Debug.Notification("0%") Debug.Trace("0%") CancelTimerGameTime(MyTimerID); Cancel previous timer, if any. StartTimerGameTime(0.1, MyTimerID); Start a timer. EndFunction Event OnTimerGameTime(int aiTimerID) If aiTimerID == MyTimerID; if this is my timer (not necessary since this script only has 1 timer, but its a good practice). Percentage += 50; sum 50 to percentage Debug.Notification(Percentage + "%") Debug.Trace(Percentage + "%") If Percentage < 100; if percentage is less than 100 start the timer again StartTimerGameTime(0.1, MyTimerID) If Percentage == 100 AttachMod(Mod1) EndIf EndIf EndIf EndEvent ^^^This is the script DieFem wrote for me.It's attached to an armor.I added a line to the bottom: If Percentage == 100 AttachMod(Mod1) But for some reason the mod doesn't get attached. Any idea why? The mod does attach on another event in the same script so I think I might be writing it wrong. But I don't know the proper way to write it. Link to comment Share on other sites More sharing options...
SKKmods Posted August 23, 2019 Share Posted August 23, 2019 Assuming your Attachmod function works, you have the if statments nested so the 100% will never resolve This If Percentage < 100; if percentage is less than 100 start the timer again StartTimerGameTime(0.1, MyTimerID) If Percentage == 100 AttachMod(Mod1) EndIf EndIf Should be this and shows why indenting logic is useful: If Percentage < 100; if percentage is less than 100 start the timer again StartTimerGameTime(0.1, MyTimerID) EndIf If Percentage == 100 AttachMod(Mod1) EndIf ... or ... If Percentage < 100; if percentage is less than 100 start the timer again StartTimerGameTime(0.1, MyTimerID) Else ;the percentage must be 100 AttachMod(Mod1) EndIf Link to comment Share on other sites More sharing options...
vizex1 Posted August 23, 2019 Author Share Posted August 23, 2019 (edited) Thanks again SKK50! That was what I needed! Works perfectly now! :smile: Edited August 23, 2019 by vizex1 Link to comment Share on other sites More sharing options...
Recommended Posts