; --------------------------------------------- ; ManagementQuestTemplate.psc - by kinggath ; --------------------------------------------- ; Reusage Rights ------------------------------ ; You are free to use this script or portions of it in your own mods, provided you give me credit in your description and maintain this section of comments in any released source code (which includes the IMPORTED SCRIPT CREDIT section to give credit to anyone in the associated Import scripts below. ; ; IMPORTED SCRIPT CREDIT ; N/A ; --------------------------------------------- Scriptname ManagementQuestTemplate extends Quest ; --------------------------------------------- ; Editor Properties --------------------------- ; --------------------------------------------- Group Controllers GlobalVariable Property CurrentVersion Auto Const Mandatory { Holds the current version of the files, used with local property InstalledVersion to determine what changes to apply } EndGroup ; --------------------------------------------- ; Dynamic Properties -------------------------- ; --------------------------------------------- Float Property InstalledVersion = 0.0 Auto Hidden ; Version control ; --------------------------------------------- ; Variables ----------------------------------- ; --------------------------------------------- Actor PlayerRef bool bEditLock = false ; Thread-safety ; --------------------------------------------- ; States -------------------------------------- ; --------------------------------------------- ; --------------------------------------------- ; Events -------------------------------------- ; --------------------------------------------- Event OnQuestInit() ; Grab PlayerRef PlayerRef = Game.GetPlayer() ; Init arrays ; Run maintenance Startup() ; Register for events RegisterForRemoteEvent(PlayerRef, "OnPlayerLoadGame") EndEvent Event Actor.OnPlayerLoadGame(Actor akActorRef) Startup() EndEvent ; --------------------------------------------- ; Event Handler Functions --------------------- ; --------------------------------------------- ; --------------------------------------------- ; Methods ------------------------------------- ; --------------------------------------------- Function Startup() bEditLock = false ; Make sure this never gets stuck permanently if(InstalledVersion < CurrentVersion.GetValue()) if(InstalledVersion > 0) InstallModChanges() else InstalledVersion = CurrentVersion.GetValue() endif endif EndFunction Function InstallModChanges() ; Make changes here - use format if(InstalledVersion < X.X) do something endif ; Once complete, flag our version as up to date InstalledVersion = CurrentVersion.GetValue() EndFunction ; Utility function to wait for edit lock ; Increase wait time while more threads are in here ; Get an edit lock only for non-time-critical functions. int iEditLockCount = 1 Function GetEditLock() iEditLockCount += 1 While (bEditLock) Utility.Wait(0.1 * iEditLockCount) EndWhile bEditLock = true iEditLockCount -= 1 EndFunction