Advertisement
Sharlikran

Fixer Script

May 9th, 2016
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Scriptname WorkshopCategoryFixer extends Quest
  2.  
  3. Formlist property WorkshopMenuMain auto const
  4.  
  5. bool locked = false
  6.  
  7. Event OnQuestInit()
  8. RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerLoadGame")
  9. removeAllNoneValues()
  10. Debug.notification("none values removed")
  11. EndEvent
  12.  
  13. Event Actor.OnPlayerLoadGame(Actor actorref)
  14. removeAllNoneValues()
  15. Debug.notification("none values removed")
  16. EndEvent
  17.  
  18. Function removeAllNoneValues()
  19. ;in case the player saves and reloads the save before the first function is finished
  20. ;this cant be done in removeNoneValuesFromFlst, because that function calls itself recoursively
  21. if (!locked)
  22. locked = true
  23. removeNoneValuesFromFlst(WorkshopMenuMain)
  24. locked = false
  25. endif
  26. EndFunction
  27.  
  28. Function removeNoneValuesFromFlst(Formlist flst)
  29. ;Create a copy of the formlist
  30. Formlist temp = flst
  31. ;Remove all forms that are added by any script
  32. flst.revert()
  33. ;Add all none forms to the flst again
  34. int i = 0
  35. while (i < temp.getSize() )
  36. Form f = temp.getAt(i)
  37. if (f)
  38. ;The form is not none and not yet in the flst. Add it again.
  39. flst.addForm(f)
  40. if (f as Formlist)
  41. ;wait a short time to reduce script lag
  42. ;Utility.wait(0.5)
  43. ;The form is a formlist itself, so do the same with it
  44. removeNoneValuesFromFlst(f as Formlist)
  45. endif
  46. endif
  47. i += 1
  48. endwhile
  49. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement