SGTbayk47 Posted July 14, 2016 Share Posted July 14, 2016 Hi all, I currently have a script, but I wan't certain parts of the script to only run after a certain number of seconds. The script begins when the player enters a trigger, and is running up until the player has the leg crippled (Player.DamageAV LeftMobilityCondition 100). However after this, the script seems to stop, and the players controls aren't enabled again. If anyone knows the cause of this, and how to fix it, it would be appreciated. Also any general advice on how to 'clean up' the script, since I don't have much scripting experience I might be using longwinded methods etc. (Though keep in mind I don't want to have NVSE as a requirement) Here is the script: SCN TVNellisBoxCarEntranceScript Float Timer Short DoOnce Short Entered Begin OnTriggerEnter Player If Entered == 0 Set Entered to 1 Endif End Begin Gamemode If Entered == 1 If Timer < 5 Set Timer to Timer + GetSecondsPassed If DoOnce == 0 DisablePlayerControls 1 1 1 1 0 1 1 Imod TVNellisBoxCarEntrance01Imod Playsound TVNellisBoxcarEntrance01Sound Set DoOnce to 1 Endif Elseif Timer >= 5 && Timer < 11 Set Timer to Timer + GetSecondsPassed If DoOnce == 1 Player.Moveto TVNellisCaveBoxCarEntranceMarkerREF TVNellisBoxcarEntranceREF.MarkForDelete TVNellisBoxcarEntranceDoorREF.MarkForDelete TVNellisBoxCarSunkenREF.Enable Imod TVNellisBoxCarEntrance02Imod Playsound TVNellisBoxcarEntrance02Sound Player.DamageAV LeftMobilityCondition 100 Set DoOnce to 2 Endif Elseif Timer >= 11 Set Timer to Timer + GetSecondsPassed If DoOnce == 2 EnablePlayerControls TVNellisBoxCarEntranceTriggerREF.Disable TVNellisBoxCarEntranceTriggerREF.MarkForDelete Set DoOnce to 3 Set Entered to 2 Endif Endif Endif End Thanks in advance, BayK. Link to comment Share on other sites More sharing options...
SGTbayk47 Posted July 14, 2016 Author Share Posted July 14, 2016 Just a heads up, I have solved the problem now, but didn't actually find the problem with this script itself. I simply split the script up into two scripts with two triggers, and that has worked. Link to comment Share on other sites More sharing options...
rickerhk Posted July 15, 2016 Share Posted July 15, 2016 Looks like it should work unless the player.moveto is to another (internal) cell, or far away to another external cell. If that were the case, the last section would not run since the object is no longer loaded. Object scripts don't run unless the player is in the loaded cell with it. A quest script would work for that case. Link to comment Share on other sites More sharing options...
SGTbayk47 Posted July 15, 2016 Author Share Posted July 15, 2016 Ah, that makes sense. Thanks for the reply, I'll remember that in the future. Link to comment Share on other sites More sharing options...
SGTbayk47 Posted July 18, 2016 Author Share Posted July 18, 2016 I'm having problems once again, with another timer script. Here's the script: SCN TVPartsTableTriggerScript Float Timer Short DoOnce Begin OnTriggerEnter Player If TVQuestM02a.PlaceParts == 0 && GetObjectiveDisplayed TVQuestM02a 15 == 1 Set TVQuestM02a.PlaceParts to 1 Endif End Begin Gamemode If TVQuestM02a.PlaceParts == 1 If Timer == 0 Set Timer to Timer + GetSecondsPassed If DoOnce == 0 DisablePlayerControls Imod FadeToBlackAndBackQuickISFX Set DoOnce to 1 Endif Elseif Timer >= 2 || Timer < 4 Set Timer to Timer + GetSecondsPassed If DoOnce == 1 Player.removeitem TVPartVertiMisc 1 1 TVBossHideoutPartVertiREF.Enable Set DoOnce to 2 Endif Else If DoOnce == 2 EnablePlayerControls SetObjectiveCompleted TVQuestM02a 15 1 SetObjectiveCompleted TVQuestM01 13 1 SetObjectiveDisplayed TVQuestM01 14 1 SetStage TVQuestM02a 20 Set DoOnce to 3 Endif Endif Endif End Begin OnTriggerLeave Player If TVQuestM02a.PlaceParts == 1 && GetQuestCompleted TVQuestM02a == 1 Set TVQuestM02a.PlaceParts to 2 Endif End Yet again, it seems that the final part of the script wont run. As the script is now, the players controls are disable and the fade in/out begins. Then, the static item is enable whilst the screen is black and the misc item is removed. But after that, nothing. The screen simply fades back in, but the player is left with the controls still disabled, and the objectives aren't updated. If someone knows what is causing this problem and how to fix it it would be of great help. Once again, thanks in advance. BayK. Link to comment Share on other sites More sharing options...
Ladez Posted July 18, 2016 Share Posted July 18, 2016 Far as I can tell, your problem is on this line: Elseif Timer >= 2 || Timer < 4 You're using an OR operator, so this statement will always evaluate to true, preventing the next block from executing. Change it to AND (&&). However, this will make your script stop working after the first iteration unless you replace this: If Timer == 0 with this: If Timer < 2 Link to comment Share on other sites More sharing options...
SGTbayk47 Posted July 19, 2016 Author Share Posted July 19, 2016 Thanks for the help, that worked perfectly. :) Link to comment Share on other sites More sharing options...
Recommended Posts