function Disease_spawnHelicopter(){ if(isObject(helicopter)) { return; } %bot = new AIPlayer(helicopterBot) { datablock = BlockheadHoleBot; }; %bot.schedule(100, applyPilotAvatar); %filename = $Disease::Map[$Disease::CurrentMap]; %spawnFilename = filePath(%fileName) @ "/helispawns.txt"; if(isFile(%spawnFilename)) { %file = new FileObject(); %file.openforRead(%spawnFilename); %file.close(); %file.delete(); } else { %xy[%xyc = 1] = "0 0"; echo("Couldn't find helicopter spawn file! Spawning helicopter at 0 0."); } %trans = %xy[getRandom(1,%xyc)] SPC 69; %trans = VectorAdd(%trans, "31 31 0"); %heli = new FlyingVehicle(helicopter) { datablock = CityHeliMedVehicle; }; %heli.setNodeColor("ALL", "0.38 0.57 0.49 1.00"); %heli.setTransform(%trans); %heli.mountobject(%bot, 0); %heli.landingTick(); %heli.pushAwayTick(); MessageAll('', "\c0The \c3Helicopter \c0is here! All living survivors must get on it!"); ServerPlay2D(Disease_Sound_note_haunt); schedule(getRandom(1000, 2000), 0, ServerPlay2D, Disease_Sound_note_page);}
%xy[%xyc = 1] = "-19.867 -80.5971";%xy[%xyc++] = "-42.7127 -82.5906";%xy[%xyc++] = "-67.1489 -52.2427";%xy[%xyc++] = "-75.6646 -18.1384";%xy[%xyc++] = "-11.7638 12.18";%xy[%xyc++] = "2.68198 -83.9179";%xy[%xyc++] = "-47.2515 -0.576858";%xy[%xyc++] = "60 -50";%xy[%xyc++] = "15 -30";%xy[%xyc++] = "15 -5";
-19.867 -80.5971-42.7127 -82.5906-67.1489 -52.2427-75.6646 -18.1384-11.7638 12.182.68198 -83.9179-47.2515 -0.57685860 -5015 -3015 -5
%filename = $Disease::Map[$Disease::CurrentMap]; %spawnFilename = filePath(%fileName) @ "/helispawns.txt"; if(isFile(%spawnFilename)) { %file = new FileObject(); %file.openforRead(%spawnFilename); %xyc=0; while(!isEOF(%file)) { %xy[%xyc] = %file.readLine(); %xyc++; } %file.close(); %file.delete(); } else { %xy[%xyc = 1] = "0 0"; echo("Couldn't find helicopter spawn file! Spawning helicopter at 0 0."); }
%filename = $Disease::Map[$Disease::CurrentMap]; %spawnFilename = filePath(%fileName) @ "/helispawns.cs"; if(isFile(%spawnFilename)) { exec(%spawnFileName); } else { %xy[%xyc = 1] = "0 0"; echo("Couldn't find helicopter spawn file! Spawning helicopter at 0 0."); }
OH MY GOD IT WORKSThanks so much. I had to change the .txt to a .cs but that's not any problem at all.Final code:Code: [Select] %filename = $Disease::Map[$Disease::CurrentMap]; %spawnFilename = filePath(%fileName) @ "/helispawns.cs"; if(isFile(%spawnFilename)) { exec(%spawnFileName); } else { %xy[%xyc = 1] = "0 0"; echo("Couldn't find helicopter spawn file! Spawning helicopter at 0 0."); }
Actually best solution is to define them as global variables at the top of the file, that way you don't have the overhead of reading files every time