Archive: Some help needed...


Some help needed...
Rather a lot of help needed really...

I've finished my map-compiler program for Quake2, and I'm now moving onto a new piece of software for the Quake2/D-Day community.

D-Day for Quake2 writes its console data to a log file, showing everything the client (player) has done during his/her's gaming experiance.
Right now, players cannot see their kill count or death count (how many people they have killed or how many times they have died) They can only see figures for the whole teams' kill/death counts.

I am making a program which will read from the log file (qconsole.log) and convert data into readable details.

These would include something like:

Player: "Afrow UK"
"Afrow UK" would be the name entered at the start of the program. The program will then give the details from the players' name.

Kills: "x"
"x" would be the kills count.
In the log, a player killed by "Afrow UK" will be seen as e.g.
Afrow UK was sniped by [OSS]Sgt.Boon
Afrow UK did not survive lits's explosive attack
Afrow UK didn't see lits's handgrenade

Deaths "x"
"x" would be the deaths count.
In the log, a death for "Afrow UK" will be seen as e.g.
(89th)Cpt.Dan was shot down by Afrow UK's rifle
[BR1]Cpt.Kal was gunned down by Afrow UK's submachinegun
[666th]SkullZ didn't see Afrow UK's handgrenade

and so on...

These are the main figures I need to get from a log file, where the log file will pretty much be like the qconsole.txt I have added to this post.

Secondly, I need to get...

1. A list of player names printed on 1 line, seperated by commas (note that a players' name is always found more than one time)
2. A player count number (number of players found listed in the log)
3. A list of maps that the home client has been on printed on 1 line, seperated by commas (person running the program)
This would come from e.g. "Map: gbrdday2"
4. A list of the IP addresses (servers) that the home client has played on printed on 1 line, seperated by commas.
This would come from e.g. "Connecting to ddayuk.dyndns.org:27910..."


Thats basically it for now. Once I can get a main code for creating the list, and count numbers etc, I can get far without help (note I'm only a youngster!)

As soon as I release this program, it will be downloaded by thousands. Since the release of D-Day: Normandy 3.2, the individual Player death/kills count was removed from the HUD, and instead just the overall death/kills count for the whole team was put on instead.

The general program UI is done.
This program will also help server runners, when I get the html bit going...
Data will be put into a nice HTML document, so then admins can upload onto some webspace so everyone can see it.
This will be useful for personal use (players wanting to see their own player count)
Or it can be used for an overall server (listing all players' data)
It will also have a 'live' function, which means that the user can run it while running D-Day, printing live data onto the log window, or even lively updating the html file.

As soon as I get the main code for getting a list of players, and player numbers etc, I can carry on from there hopfully.
However, I'm not the best at stuff (still a youngster!)

Enough of the babbling on now...

Thanks

-Stuart


It'll be easier to help if you specify more specific problems. I am not going to think of an entire script algorithm for this... ;)


I posted this when I was rather tired, and since have thought of pretty much all of the functions needed.
I'll write my own parts (I know what to do) using bits from other functions.
That "Super function task" post I posted a while oga on these forums will help me a lot Thanks :)

I can use StrStr to only have a player name written to the list once (if it is already in the list, then don't add it on!)

It's going to take a lot of work, but it shouldn't be too hard.

Too bad I thought of most of it during lessons at school, and have forgotten a lot of it! I will write notes next time (hope teachers don't notice)

I'm currently getting a lot of support from a lot of fellow D-Day players, who are eagerly awaiting my program :)

-Stuart


Secondly...

Is there a way NSIS can automatically upload files to a website?


There is probably an command-line MS-DOS program out there, but I haven't time to look right now :)


-Stuart


What do you mean? FTP transfer?



ClearErrors
FileOpen $0 "C:\quake2\dday\qconsole.log" r
StrCpy $3 0
loop:
FileRead $0 $2
IfErrors done
StrCmp $2 "[OSS]Lt.AfrowUK" 0 +3
IntOp $3 $3 + 1
StrCmp $2 "[OSS]Lt.AfrowUK$\n$\r" 0 loop
IntOp $3 $3 + 1
Goto loop
done:
DetailPrint "Kills = $3"
WriteINIStr "$EXEDIR\logs\client_log1.log" "Kill Count" "Kills" "${KILLCOUNT}"
FileClose $0


The first bit of code, and I'm already doomed!
It only adds 1 to $3 once, and then finishes.
The log has 5 of "[OSS]Lt.AfrowUK" in it, so it should add 5 to $3.

Whats wrong?

-Stuart

I see one error in there which is that +3 that is supposed to be +2. That shouldn't decrease the count thought, it should increase it... Weird... Try printing some debug info such as $2 != [OSS]Lt.AfrowUK if it's not the same line and == if it's the same line. Maybe that will help you figure out what's wrong.


Yes, I mean FTP.

Ok, I changed that bit to +2 insted of +3, $3 still comes out as 0, when I want it to count up how many times it has found "[OSS]Lt.AfrowUK" in the log.


-Stuart


So, it doesn't seem to find "[OSS]lt.AfrowUK" in the log file anywhere, even though it is repeated in there over 1000 times at least!

I have narrowed the log file down to just having 5 of the "[OSS]lt.AfrowUK" in it, but it still sees none of them.

-Stuart


Ok, I found out what is the problem.

FileRead $0 $2 will get a whole line from the log. In this case, it may be "|EON|MadDuCk was sniped by [OSS]Lt.AfrowUK"
Simply comparing "|EON|MadDuCk was sniped by [OSS]Lt.AfrowUK" to "[OSS]Lt.AfrowUK" will not work.
I will have to use StrStr to search for "[OSS]Lt.AfrowUK" in that string.

Will this work?

-Stuart


Wahoo that works!
Now, the only troube is that if "[OSS]Lt.AfrowUK" is repeated on the same line "e.g. [OSS]Lt.AfrowUK has overflowed, [OSS]Lt.AfrowUK is reconnecting," it will only pick up 1 of the "[OSS]Lt.AfrowUK"

It doesn't matter too much, because (as far as I know) "[OSS]Lt.AfrowUK" doesn't appear more than once on a line anyway!

-Stuart


StrStr will return the string without the part that comes before what you were looking for. You can trim what you've been looking for and then look again in what's left.


You can use the Advanced StrStr to show the string before the second [OSS]Lt.AfrowUK.

[EDIT]OR

You can detect the first [OSS]Lt.AfrowUK (output $0), detect it again without showing the [OSS]Lt.AfrowUK (output $1), and detecting the next [OSS]Lt.AfrowUK in the $1 (output $1).[/EDIT]


Nice script, but right now, parsing the log file (of up to 1mb) takes up to 20 seconds+!

-Stuart