MtB Posted September 16, 2012 Share Posted September 16, 2012 Hello,I need help on getting a time bomb script to work. The script activates when the bomb is dropped. A message window opens which gives you the option of setting the bomb in 15 second increments up to one minute. The problem I appear to have is that the timer doesn't seem to work. I've tried various formats of the script but nothing works. Here's the script in it's current form... ScriptName aaTimedExplosive01Script Short DoOnceShort ButtonShort StageFloat fTimer Begin OnDropIf DoOnce == 0ShowMessage aaSetBombTimerMSG ; How long do you want to set the timer for? 15, 30, 45, 60, Do NothingSet DoOnce to 1EndIfEnd Begin GameModeSet Button to GetButtonPressedIf ( DoOnce == 1 )If (Button == 0) set fTimer to 15Set Stage to 1EndIfEndIf ElseIf (Button == 1) If ( DoOnce == 1 )set fTimer to 30Set Stage to 1EndIf ElseIf (Button == 2) If ( DoOnce == 1 )set fTimer to 45Set Stage to 1EndIf ElseIf (Button == 3) If ( DoOnce == 1 )set fTimer to 60Set Stage to 1EndIf ElseIf (Button == 4) ;No Action;Do NothingEndIfEnd Begin OnDropif ( Stage == 1 ) && fTimer >= 1set fTimer to fTimer - GetSecondsPassedif fTimer == 0PlaceAtMe MineFragExplosion ;aaTimedExplosive01REFaaTimedExplosive01REF.DisableEndIfEndIfEnd Any help would be appreciated. Link to comment Share on other sites More sharing options...
Ladez Posted September 18, 2012 Share Posted September 18, 2012 First of all, please use code tags when posting code in the forums, and make sure it is indented. I had to copy this into my text editor and indent it myself to make any sense of it at all. It requires minimal effort, and heightens your chance at getting a response as it is much easier to read. Your gamemode block is a mess. There were some misplaced EndIf statements, and you only need to check for DoOnce one time. Also, the check for the button press on Do Nothing is superfluous, since it... does nothing.The timer will not work in an OnDrop block, since that only runs once when the items is dropped. You also have two OnDrop blocks, which I don't know if is possible, but it makes for a confusing script. I placed the timer section in the GameMode block where it should be.What is aaTimedExplosive01REF and why are you disabling it and not the bomb? Is it a reference that you placed somewhere? If so how do you make sure that it is at the place where the bomb explodes? Instead why don't you just call Disable directly, which will disable the item that you dropped, the item that the script is bound to.Also, you're calling Disable when it explodes, but you should also call MarkForDelete on it to make sure that it's actually deleted from the game and not just hidden. Disabled objects will continue running their scripts.I've restructured the script a bit. I really don't know if it works, it might need a bit more work, but it's late. Here it is, indented and in code tags. Much nicer to read isn't it? ScriptName aaTimedExplosive01Script Short DoOnce Short Button Short Stage Float fTimer Begin OnDrop If DoOnce == 0 ShowMessage aaSetBombTimerMSG ; How long do you want to set the timer for? 15, 30, 45, 60, Do Nothing Set DoOnce to 1 EndIf End Begin GameMode Set Button to GetButtonPressed If ( DoOnce == 1 ) If (Button == 0) set fTimer to 15 Set Stage to 1 ElseIf (Button == 1) set fTimer to 30 Set Stage to 1 ElseIf (Button == 2) set fTimer to 45 Set Stage to 1 ElseIf (Button == 3) set fTimer to 60 Set Stage to 1 EndIf EndIf if ( Stage == 1 ) && fTimer >= 1 set fTimer to fTimer - GetSecondsPassed if fTimer == 0 PlaceAtMe MineFragExplosion ;aaTimedExplosive01REF Disable MarkForDelete EndIf EndIf End Link to comment Share on other sites More sharing options...
freddy_farnsworth Posted September 20, 2012 Share Posted September 20, 2012 This is from Rez, he ran into that problem, and fixed it in the subway mod should be examples in there. ""If i remember right activators only cycle thru the code once.. no loops or timers, would have to call a effect in that code with its own script."" So the script has to be on the Effect. freddy Link to comment Share on other sites More sharing options...
GrindedStone Posted September 23, 2012 Share Posted September 23, 2012 How is this even useful in the first place? Link to comment Share on other sites More sharing options...
Recommended Posts