All pastes #2056571 Raw Edit

Something

public text v1 · immutable
#2056571 ·published 2011-05-11 04:41 UTC
rendered paste body
var today = new Date();
var pathtobe = "logs/" +"_"+ me.name +"_chickenlog.xml";
//print("ÿc1agor chickenlogger loaded");

// Creating of the chickenlog.xml file whenever a Character joins a game
function CheckLog() {
	// Check if file already exists
	if(!FileTools.exists(pathtobe)) 
		FileTools.writeText(pathtobe, '<?xml version="1.0" encoding="iso-8859-1"?>\n<?xml-stylesheet href="chickenlog.xsl" type="text/xsl"?>\n<chickenlog>\n</chickenlog>' ); 	
}

// Writes chickens to chickenlog.xml via E4X 
// http://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Processing_XML_with_E4X 
// chicken         = chicken Object 

function writeLog( me) { 


  	if(!chicken || !NT_logchickens)
		return true;
	
	var templine = "";
	var content = "";
	var time_now = new Date(); 
	var timestring = time_now.toLocaleFormat("%a %m/%d/%y %H:%M"); 
   //+++++++ start replace() +++++++++ 
   // Replaces new lines with spaces 
   var chickenname = chicken.fname.replace(/\n/g, " "); 
   chickenname = chickenname.replace('\02/g', ""); 
    
   
   // Adds a unique identifier to each chicken 
   var chickenid = time_now.getTime(); 
    
   var chickendesc = chicken.description.replace(/ÿc(.)/g, ""); 
   chickendesc = chickendesc.replace(/\n/g, '|'); 
  
  
	
	
    WriteSqlchickenlog(chicken,_mode,"file "+obj.file+" line "+obj.lineno)
   //chickendesc = ""; 
   // Adds the <chicken></chicken> tag into XML 
   content ='<chicken id="'+chickenid+'" char="'+me.name+'" time="'+timestring+'" from :"+NTAR_Areas[me.area]+'">'+chickendesc+'</chicken>';
   
   // <chicken id="1262070968341" char="bobode" time="Tue 12/29/09 01:16" ></chicken>
 //chickenlog.chicken +=<chicken id={chickenid} char={me.charname} time={timestring} quality={chicken.quality} ethereal={isEthereal} mode={_mode} name={chickenname}>{chickendesc}</chicken>; 
		var filehandle = File.open(pathtobe, 2);
	// Skips XML header lines because they cause errors when creating the E4X object
	var linecount = 0;
	while(!filehandle.eof) {
		templine = filehandle.readLine(); 
		if(!(templine == "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" || templine == "<?xml-stylesheet href=\"chickenlog.xsl\" type=\"text/xsl\"?>" || templine == "<chickenlog>" || templine == "</chickenlog>")) {
			linecount++
			if (linecount == NT_LoggingMaxLines)
				break;
			content += templine;
		}
		
	}
	filehandle.close();
	content='<chickenlog>'+content+'</chickenlog>';
	var chickenlog = new XML(content); 
    // Creates a Time String 
   // Format: http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html 
	
     // Creation of the file output, headers first and then the chickenlog content 

   FileTools.writeText(pathtobe, '<?xml version="1.0" encoding="iso-8859-1"?>\n<?xml-stylesheet href="chickenlog.xsl" type="text/xsl"?>\n' + chickenlog.toXMLString()); 
   return true;
} 
function WriteSqlchickenlog(chicken,mode,nipline){
	var db = new SQLite('inventories.sqlite')	
try{	
	db.execute('CREATE TABLE IF NOT EXISTS "main"."chickenlog" (' +
					'"KeyOwner" TEXT,' + '"TimeStamp" TEXT,' +'"FoundIn" TEXT,' +'"Kept" TEXT,' +'"NipLine" TEXT,' +'"name" TEXT,' +'"x" TEXT,' +'"y" TEXT,' +
					'"type" TEXT,' +'"classId" TEXT,' +	'"mode" TEXT,' +'"act" TEXT,' +	'"gid" TEXT,' +	'"area" TEXT,' +
					'"hp" TEXT,' +'"mp" TEXT,' +'"hpMax" TEXT,' +'"mpMax" TEXT,' +'"stamina" TEXT,' +
					'"staminamax" TEXT,' +'"charlvl" TEXT,' +'"chickencount" TEXT,' +'"owner" TEXT,' +
					'"ownertype" TEXT,' +'"spectype" TEXT,' +'"direction" TEXT,' +'"uniqueid" TEXT,' +
					'"code" TEXT,' +'"prefix" TEXT,' +'"suffix" TEXT,' +'"prefixnum" TEXT,' +'"suffixnum" TEXT,' +
					'"fname" TEXT,' +'"quality" TEXT,' +'"node" TEXT,' +'"location" TEXT,' +'"sizex" TEXT,' +'"sizey" TEXT,' +
					'"chickenType" TEXT,' +'"description" TEXT,' +	'"descrip" TEXT,' +	'"bodylocation" TEXT,' +'"ilvl" TEXT,' +'"lvlreq" TEXT,' +						
					'"runwalk" TEXT,' +'"weaponswitch" TEXT,' +	'"objtype" TEXT,' +	'"islocked" TEXT,' +'"screenX" TEXT,' +'"screenY" TEXT );');
}
catch(error){

}
	var dis2 =""
	var classid ="";
	var dmg =""
	var soc =""
	var def ="";
	var eth =""
	var screenPT = [0,0];	
	var key = me.name +"@"+me.account;
	
		var area = ""
	
		for(var j = 0; j<NTSI_GID_AREA.length ; j++){
			if (NTSI_GID_AREA[j][0] == chicken.gid)
				area =NTAR_Areas[NTSI_GID_AREA[j][1]];		
		}
		if (area =="")
			area = NTAR_Areas[me.area];		
		dis2="";
		var time_now = new Date(); 
	var timestring = time_now.toLocaleFormat("%a %m/%d/%y %H:%M"); 
	


}


CheckLog();