///BEGIN PRE-LOAD SCRIPT LAUNCHER///if(!$PreLoadScriptsRun){ %mask = "Add-Ons/*/preload.cs"; for(%file = findFirstFile(%mask); %file !$= ""; %file = findNextFile(%mask)) %fileList = setField(%fileList, getFieldCount(%fileList), %file); %fileCount = getFieldCount(%fileList); for(%fileIndex = 0; %fileIndex < %fileCount; %fileIndex ++) { %file = getField(%fileList, %fileIndex); %path = filePath(%file); %dirName = getSubStr(%path, strPos(%path, "/") + 1, strLen(%path)); if(strPos(%dirName, "/") == -1) { echo("\n\c4Pre-Loading Add-On:" SPC %dirName); exec(%file); } } $PreLoadScriptsRun = true; $Pref::PreLoadScriptLauncherInstalled = true;}///END PRE-LOAD SCRIPT LAUNCHER///
Aha - it isn't an add-on. However, as the code you would call addPreloadScript with is part of an add-on, this means it starts working the second time you start your game with the add-on enabled.
You should just make it write to main.cs a script which executes all "add-ons/*/preLoad.cs" or something, similar to how server.cs and client.cs are executed.