Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 52 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: "Feeding" the server external information?
maxdreamland
General Member
Since: Aug 25, 2007
Posts: 3
Last: Sep 6, 2007
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Aug. 25, 2007 10:21 am
Hi,

for our LAN server I created a small statistics tool that analyzes the server logs and creates a couple of statistics from it. An example can be found at http://cod.mkoehler.de/

Part of the statistics is a so called ELO value for each player. The ELO value originated from the game of chess and is a way of quantizing a players "playing strength". If you are interested in the details please check out "ELO" on wikipedia, they have a good article about it.

To give the players an understanding of how their ELO value changes over time while they are playing (and not just seeing it after the session in the online statistics) i wrote a small AWK script that computes the current ELO value for each player while the server writes its logfile (server log is written unbuffered so there is no delay). Then the AWK script sends a "say" command via the RCON interface to the server, each time an ELO value changes.

So basically each time you kill someone you get a message that tells you your current ELO and how it changed because of the last kill.

I'm pretty pleased with this whole setup. the only thing that bothers me is the way the information is presented to the players with the "say" command.

I would rather try to create a custome HUD extension that just displays the current ELO at any given time. Just like your ammo display for example.

By looking through the gsc files of the AWE mod we are playing, I already got a good understanding of how i could create the HUD display. But what i don't get is how i can communicate the information "Player X's ELO is now Y" from outside the server into the server, so that a GSC script could access it.

I was thinking maybe the AWK script could set a variable via the RCON interface (is that even possible?)...maybe something like
Code:
set elo["playername"] 1132
and then the gsc script could read from that array the current ELO values.

But i haven't figured out if that would work and how the syntax for such a thing would be.

I think a came pretty far (never did any COD modding before) but now i reached the point where i feel i could use some help :-)

any ideas?

regards
Max
Share |
OLD_MAN_WITH_GUN
General Member
Since: May 13, 2006
Posts: 754
Last: Jan 23, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Saturday, Aug. 25, 2007 10:56 am
You can try it that way.
http://www.iwnation.com/Forums/index.php?showtopic=26230
Share |
maxdreamland
General Member
Since: Aug 25, 2007
Posts: 3
Last: Sep 6, 2007
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Saturday, Aug. 25, 2007 01:39 pm
That's actually very good advice, thanks a lot!

I did think about computing the ELO inside the server before, instead of computing it outside via the server log and AWK script.

But i didn't think it was possible to read/write files from a gsc script. And i would need that to persist a players ELO inbetween sessions.

So thats a very nice surprise that gsc scripts do have in fact file handling features.

Thanks again!

regards
Max
Share |
Rampage-WYD-
General Member
Since: Aug 30, 2007
Posts: 2
Last: Sep 2, 2007
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Sunday, Sep. 2, 2007 06:45 am
I have created a 2142 Stats system, that reads a log file that is created when the game begins, etc. Here is some of the code, if you want to try to convert it for COD2:

Code:
logfile = None
fileName = ""

def enable():
	global fileName
	global logfile
	global startTime

	if logfile and not logfile.closed:
		print "Logging already enabled"
		return 
		
	host.registerGameStatusHandler(onGameStatusChanged)
	
	currentDate = datetime.datetime.today()
	dateString = ""
	dateString = time.strftime("%y%m%d_%H%M", currentDate.timetuple())

	if dateString != "":
		fileName = "C:/Directory_Here/Logs/" + bf2.gameLogic.getMapName() + "_" + dateString + "_faLog.txt"
	else:
		fileName = C:/Directory_Here/Logs/" + bf2.gameLogic.getMapName() + "_faLog.txt"
	
	print "log file: ", fileName

	try:
		logfile = file (fileName, 'w')
	except Exception:
		if g_debug: print "Couldnt open logfile: ", fileName
		return
	
	startTime = int(date())
	timeString = str(startTime)
	startDate = time.strftime("%Y.%m.%d,%H:%M", currentDate.timetuple())
	
# DEFINE WORLD SIZE

	worldSize = bf2.gameLogic.getWorldSize();
	wsformat = str(fpformat.fix(worldSize[0], 3)) + "," + str(fpformat.fix(worldSize[1], 3))

# DEFINE TEAMS

	team1 = str(bf2.gameLogic.getTeamName(1))
	team2 = str(bf2.gameLogic.getTeamName(2))
	logfile.write("INIT LevelName=" + bf2.gameLogic.getMapName() + " StartTime=" + timeString + " StartDate=" + startDate + " Filename=" + fileName + " WorldSize=" + wsformat + " Team1=" + team1 + " Team2=" + team2 + " GameMode=" + host.ss_getParam('gameMode') + "\n")

	logfile.flush()



That is just a tiny piece of what the logger looks like for my 2142 stats system. Also, here some code from a perl file that I also created for 2142 Stats:

Code:

# READ COMMAND FOR INIT

if ($command eq "INIT")
			{
				#FORMAT: INIT LevelName=dalian_plant StartTime=14476 StartDate=2005.06.25,04:23 Filename=mods/bf2/Logs/dalian_plant_050625_0423_faLog.txt WorldSize=2048.000,2048.000

				$map_stats{"levelname"} = $v{"LevelName"};
				# Fix 0.20: We must ignore StartTime because sometimes on some servers the values are plain nonsense

				#$map_stats{"starttime"} = $v{"StartTime"};
				$map_stats{"startdate"} = $v{"StartDate"};
				$map_stats{"worldsize"} = $v{"WorldSize"};
				
				# Worldsize is correct, but fragalizer scales x and y coordinated to -512 to 512

				($map_stats{"scale_x"},$map_stats{"scale_y"}) = ($v{"WorldSize"} =~ /(.*),(.*)/);
				$map_stats{"scale_x"} /= 512;
				$map_stats{"scale_y"} /= 512;




So, basically all you would need to do, is find a way to make COD 2 log a file like this, with some sort of script (I used Python), and then make a program to read them, such as a .pl file (Perl file).
Share |
OLD_MAN_WITH_GUN
General Member
Since: May 13, 2006
Posts: 754
Last: Jan 23, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Sep. 2, 2007 09:23 pm
Rampage-WYD- writes...
Quote:
I have created a 2142 Stats system, that reads a log file that is created when the game begins, etc. Here is some of the code, if you want to try to convert it for COD2:
He didn't search for a stats system (he has one).
He searched a way to bring back pieces of the stats back into the game. [wink]
Share |
KillTheEnemy
General Member
Since: Aug 20, 2007
Posts: 1
Last: Sep 5, 2007
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Sep. 5, 2007 07:55 pm
Perhaps you could use the fopen and fread commands to read it from a file that the stats program writes? For further reference I would look at Ned's POC Dvar Replacement Module.

Original POC for DRM (by Nedgerblasky)
http://www.iwnation.com/Forums/index.php?showtopic=26432&hl=dvar+replacement+module

Extended POC for DRM (extension by mjhammer)
http://www.iwnation.com/Forums/index.php?showtopic=26572
Share |
maxdreamland
General Member
Since: Aug 25, 2007
Posts: 3
Last: Sep 6, 2007
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Thursday, Sep. 6, 2007 04:47 am
Yes, in "essence" thats what the article (that Oldman linked, see above) is all about. fopen/fclose did the trick for me. Thanks again!

regards
Max
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»