

Jetfire
Members-
Posts
159 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Events
Everything posted by Jetfire
-
Lua script: record player's a2a kills/deaths to HTML file
Jetfire replied to Jetfire's topic in Lock On: Flaming Cliffs 1 & 2
Thanks, sounds great MrWolf! -
Details of v1.1 Flaming Cliffs *Updated- 25/11/04*
Jetfire replied to Shepski's topic in Lock On: Flaming Cliffs 1 & 2
Umm... you can already tell if your missiles hit the target, you just have to check your score before you fire, and afterwards, see if it goes up lol these new "player killed player" won't change much... score increments should be delayed by maybe 30 seconds or so (or if end of game increment immediately) so that we can't "watch the score to see if we hit"... -
Lua script: record player's a2a kills/deaths to HTML file
Jetfire replied to Jetfire's topic in Lock On: Flaming Cliffs 1 & 2
Dmut, I haven't spoken to the devs about this. I was talking to GGTharos and about his request to fix the log file so it shows all debrief data, then I thought I'd post this since it's a start towards processing game stats. But yeah, you're right, it would be alot easier if Lock On gave us the score rather than parsing it. Ice, next time you run a mission then a debrief, could you post your Error.log file (not errors.log)? This will show any Lua errors. -
Lua script: record player's a2a kills/deaths to HTML file
Jetfire replied to Jetfire's topic in Lock On: Flaming Cliffs 1 & 2
Also, in \Config\Network\Config.lua, make sure stats is enable... so it should look like this in the file: stats { enable = true; file = "Temp/mp_log.txt"; };[/code] -
For Lock On V1.02 servers: After a mission has finished, and the debrief screen comes up, this script will record all player's kills and deaths and add them to a HTML file containing all past player's kills/deaths. It will also record all IP connections. Sorry I couldn't host this in a zip file, I am currently having problems logging onto my webpage. INSTRUCTIONS First, backup Config\Export\Export.lua. Then, in export.lua, you need to add this line near the top g_startTime = os.date( "start: \t%I:%M %p<br>"); Then, scroll down in Export.lua and, in function LuaExportStop(), add these 2 lines ( make sure you add them after function LuaExportStop() and before the next end: dofile( "Config/Export/logFlight.lua" ); LogFlight(); So, your LuaExportStop() might look like this: function LuaExportStop() -- Works once just after mission stop. -- Close files and/or connections here. -- For example: -- 1) File -- io.close() -- 2) Socket --if c then --s, e = c:send( "\t> quit\n" ) -- to close the listener socket --c:close() --end dofile( "Config/Export/logFlight.lua" ); LogFlight(); end Now, make a file called logFlight.lua in your Config\Export\ Folder and paste this code into it: dofile( "Config/Export/fileOps.lua" ); -------------------------------------------------------------------------------- function CalcScores() local currPlayer = ""; local plane = ""; local playerList = {}; local playerCount = 0; local i = 1; local currPIndex = 0; local temp = io.input(); local inFile = io.open( "./Temp/mp_log.txt", "r" ); io.input( inFile ); if ( inFile ) then io.write( "<font color=\"#000000\"><br><b>Points</b><br>" ); io.write( "<center><table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"80%\">" ); io.write( "<tr><td width=\"16%\"><font face=\"Verdana\" size=\"2\">Plane</font></td> "); io.write( " <td width=\"26%\"><font face=\"Verdana\" size=\"2\">Player</font></td> "); io.write( " <td width=\"13%\"><font face=\"Verdana\" size=\"2\">Kills</font></td> "); io.write( " <td width=\"14%\"><font face=\"Verdana\" size=\"2\">Deaths</font></td> "); io.write( "</tr> "); --io.write( "<font face=\"Courier New\" size=\"2\">" ); data = io.read( "*line" ); while ( data ~= NIL ) do -- read the line and look for players -- look for first player strIndex, strIndex2 = string.find( data, "\"" ); if ( strIndex ~= NIL ) then currPlayer = string.sub( data, strIndex + 1 ); strIndex = string.find( currPlayer, "\"" ); strIndex2 = string.find( currPlayer, ")" ) - 1; plane = string.sub( currPlayer, strIndex + 2, strIndex2 ); currPlayer = string.sub( currPlayer, 0, strIndex - 1 ); -- is the player already in the list? i = 1; while ( i < playerCount and currPlayer ~= playerList[ i ][ "name" ] ) do i = i + 1; end if ( i <= playerCount and currPlayer == playerList[ i ][ "name" ] ) then currPIndex = i; else -- add this player playerCount = playerCount + 1; playerList[ playerCount ] = {}; playerList[ playerCount ][ "name" ] = currPlayer; playerList[ playerCount ][ "plane" ] = plane; playerList[ playerCount ][ "kills" ] = 0; playerList[ playerCount ][ "deaths" ] = 0; playerList[ playerCount ][ "ejected" ] = 0; currPIndex = playerCount; end -- this is to catch an ejection and recovery before the plane crashed -- crash usually follows an eject if ( string.find( data, "crash" ) == NIL and playerList[ currPIndex ][ "ejected" ] == 1 ) then playerList[ currPIndex ][ "deaths" ] = playerList[ currPIndex ][ "deaths" ] + 1; playerList[ currPIndex ][ "ejected" ] = 0; end -- find if this is a kill or crash if ( string.find( data, "kill" ) ~= NIL ) then playerList[ currPIndex ][ "kills" ] = playerList[ currPIndex ][ "kills" ] + 1; elseif ( string.find( data, "eject" ) ~= NIL ) then playerList[ currPIndex ][ "ejected" ] = 1; elseif ( string.find( data, "crash" ) ~= NIL ) then playerList[ currPIndex ][ "deaths" ] = playerList[ currPIndex ][ "deaths" ] + 1; if ( playerList[ currPIndex ][ "ejected" ] == 1 ) then playerList[ currPIndex ][ "ejected" ] = 0; end end end data = io.read( "*line" ); end for i = 1, playerCount do io.write( "<tr><td width=\"16%\"><font face=\"Verdana\" color=\"#ff0000\" size=\"2\">" ); io.write( "<img border=\"0\" src=\"img/" ); io.write( playerList[ i ][ "plane" ] ); io.write( ".jpg\"></td><td width=\"26%\"><font color=\"#0000ff\"><b>" ); io.write( playerList[ i ][ "name" ] ); io.write( "</b></td><td width=\"13%\"><font color=\"#ff0000\"><b>" ); io.write( "<p align=\"center\"><b>" ); io.write( playerList[ i ][ "kills" ] ); io.write( "</b></td><td width=\"14%\"><p align=\"center\"><font color=\"#ff0000\"><b>" ); io.write( playerList[ i ][ "deaths" ] ); io.write( "</font></b></td></tr>" ); end io.write( "</table>" ); io.write( "</center>" ); end io.input():close(); -- close current file io.input( temp ); end -------------------------------------------------------------------------------- function LogFlight() local inFileBuf; local inFileBuf2; local data; local strIndex = 0; local strIndex2 = 0; local clientCount = 0; local inFile = io.open( "./Temp/AsyncNet.log", "r" ); local outFile; local temp1 = io.input() -- save current file local temp2 = io.output() -- save current file io.input( inFile ); if ( inFile ) then outFile = io.open( "./Temp/lastFlight.html", "w" ) io.output( outFile ); --io.write( "<html><head><title>Lock On: Modern Air Combat Stats</title></head><body>" ); io.write( "<br><hr><p align=\"right\"><font face=\"Verdana\" size=\"2\" color=\"#000000\">" ); io.write( os.date( "date: \t%a, %b %d %Y <br>" ) ); if ( g_startTime ~= NIL ) then io.write( g_startTime ); end io.write( os.date( "end: \t%I:%M %p<br>") ); io.write( "</p>" ); data = io.read( "*line" ); while ( data ~= NIL ) do -- read the line and look for connection strIndex, strIndex2 = string.find( data, "accepting connection from " ); if ( strIndex ~= NIL ) then io.write( string.format( "%s<br>", string.sub( data, strIndex2 + 1, 100 ) ) ); if ( clientCount == 0 ) then io.write( "<br><b>IP Connections<font color=\"#0000FF\"></b><br>" ); end clientCount = clientCount + 1; end data = io.read( "*line" ); end end io.input():close() -- close current file io.input( temp1 ); -- no clients so let's get out if ( clientCount == 0 ) then io.output():close(); -- close current file io.output( temp2 ); return; end CalcScores(); temp1 = io.input(); inFile = io.open( "./Temp/mp_log.txt", "r" ); io.input( inFile ); if ( inFile ) then io.write( "<font color=\"#000000\"><br><b>Debrief</b><br>" ); io.write( "<font face=\"Courier New\" size=\"2\">" ); data = io.read( "*line" ); while ( data ~= NIL ) do -- read the line and look for connection --strIndex, strIndex2 = string.find( data, "accepting connection from " ); --if ( strIndex ~= NIL ) then -- io.write( string.format( "%s\n", string.sub( data, strIndex2 + 1, 100 ) ) ); --end io.write( string.format( "\t %s<br>", data ) ); data = io.read( "*line" ); end end io.write( "<br>" ); io.input():close(); -- close current file io.input( temp1 ); io.output():close(); -- close current file io.output( temp2 ); inFileBuf = OpenFile( "./Temp/lastFlight.html" ); inFileBuf2 = OpenFile( "./Temp/logFile.html" ); WriteToFile( "./Temp/logFile.html", inFileBuf ); AppendToFile( "./Temp/logFile.html", inFileBuf2 ); end And! That's not it... make another file in the same folder called fileOps.lua and paste this code into the file: -- reads in a file, storing each line in an array -- buffer[ 1 ] is always reserved for line count function OpenFile( fileName ) local buffer = {}; local i = 2; local temp = io.input(); local inFile = io.open( fileName, "r" ); io.input( inFile ); if ( inFile ) then buffer[ 1 ] = 2; buffer[ i ]= io.read( "*line" ); while ( buffer[ i ] ~= NIL ) do i = i + 1; buffer[ i ] = io.read( "*line" ); end end io.input():close(); -- close current file io.input( temp ); return buffer; end -------------------------------------------------------------------------------- -- reads the next line from the buffer function ReadLine( buffer ) if ( buffer[ buffer[ 1 ] + 1 ] ~= NIL ) then buffer[ 1 ] = buffer[ 1 ] + 1; return buffer[ buffer[ 1 ] - 1 ]; else return NIL end end -------------------------------------------------------------------------------- -- writes a previously made buffer to a file -- openParam is "w" for write, "a" for append function WriteBufferToFile( fileName, buffer, openParam ) local i = 2; local temp = io.output(); local outFile = io.open( fileName, openParam ); io.output( outFile ); if ( outFile ) then while ( buffer[ i ] ~= NIL ) do io.write( buffer[ i ] ); io.write( "\n" ); i = i + 1; end end io.output():close(); -- close current file io.output( temp ); end -------------------------------------------------------------------------------- function AppendToFile( fileName, buffer ) WriteBufferToFile( fileName, buffer, "a" ); end -------------------------------------------------------------------------------- function WriteToFile( fileName, buffer ) WriteBufferToFile( fileName, buffer, "w" ); end -------------------------------------------------------------------------------- You're done! In terms of performance, this shouldn't cause any fps loss for the first mission hosted, because it will only run after the first debrief. The logfile will be \Temp\LogFile.html.
-
hi all, To the devs: since Lockon has Lua script support, would it be possible to have mission triggers ( for example, USFlight1 destroyed so USFlight2 takes off ) with Lua scripts? We could have the "mission1.mis" file, and maybe an option in Lockon to have triggers, and it would make a "mission1.lua" file. In the file, we could have functions like function LoMissionTime( minutes ) end function LoFlightDestroyed( string ) if ( string == "USFlight1" ) then LoFlightSpawn( "USFlight2" ); end end -- and so on This is just an idea, I really don't think we'd see this in 1.1, but it would be nice in later versions.[/code]
-
Did my sig work? Doh, just read how we want "text only".