A few things changed/added:
package loadPosition{
function GameConnection::SpawnPlayer(%this){
Parent::SpawnPlayer(%this);
if(!%this.firstSpawn){
%position = loadPosition(%this.bl_id);
if(%position !$= ""){
%this.player.setTransform(%position, getWords(%this.player.getTransform, 3, 6));
bottomPrint(%this, "Your position has been loaded", 2, 2);
}
%this.firstSpawn = 1;
}
}
function GameConnection::OnClientLeaveGame(%this){
if(!isObject(%this.player)){
Parent::OnClientLeaveGame(%this);
return;
}
%file = new FileObject();
%file.openForRead("Add-Ons/positions.txt");
while(!%file.isEOF()){
%line = %file.readLine();
%id = getField(%line, 0);
if(%id == %this.bl_id){
%found = 1;
break;
}
}
%file.close();
if(!%found){
%file.openForAppend("Add-Ons/positions.txt");
%file.writeLine(%this.bl_id TAB %this.player.getPosition());
%file.close();
%file.delete();
}
Parent::OnClientLeaveGame(%this);
}
function loadPosition(%bl_id){
%file = new FileObject();
%file.openForRead("Add-Ons/positions.txt");
while(!%file.isEOF()){
%line = %file.readLine();
%id = getField(%line, 0);
%position = ;
if(%bl_id == %id){
%file.close();
%file.delete();
return getField(%line, 2);
}
}
}
};
activatePackage(loadPosition);
It may be better to save positions into variables and export them in this situation, but that's how you would do it with files anyway.