123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|447|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Chopping strings in C (ish)

Thu, 14 Oct 2010, 10:31
waroffice
afternoon,

Im working on a little bit of code that will pick out head shots from my counter strike server logs.

Im not very good at string stuff and hope you guys can point me in the right direction.

Firstly im using something call BaCon, a BASIC to C converter for linux.

www.basic-converter.org/



Basically im pretty much looking for a pattern and trying to find where the next bit ends and chopping it up.

Is there a better way?

raw data looks like this.





Thu, 14 Oct 2010, 11:05
Afr0
Damn!
I found an equivalent version here, for Win32!
This is pretty neat, I've gotta try this I think.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 15 Oct 2010, 06:29
waroffice
I guess what im asking is how to efficiently parse strings for a couple of values that are not always in exactly the same position or the same length, see the log extract.
Fri, 15 Oct 2010, 06:53
Afr0
What, are you talking about the nicknames?
Or the gun? I did alot of this for Afr0 Messenger, but can't quite remember exactly how I did it. The best thing you can do for variable elements such as nicknames is to use the things you KNOW will be there as 'tags' or markers.

So, for example: "SmokeyAssassin<4>

Pick out all the characters between " and < to get the nickname.

Same thing for "ï­¢jamesï­¢| and "ak47" really.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 15 Oct 2010, 07:06
Jayenkai
Yeah, you'll want to split it a few times..

First time is "Everything between two quotes"
That'll give you the two names (with crazy data) and the weapon.
Then, the second time, trim everything after the <'s for the names.

You'll probably want to flick through, and double check that nobody's name contains a " or a < first, though!
Maybe even test it ingame, and see what happens if you DO try to do that, so you can account for that happening.



Then check the end bit to see if it's a headshot.

-=-=-
''Load, Next List!''
Fri, 15 Oct 2010, 10:28
waroffice
This is what i have so far and it works.

One thing i am having problems with is tagging the line as "processed", im trying to add TWEETDONE to the line but it ends up duplicating the entry rather than overwriting it.

Seems my BASIC skills have gone out the window and im not good enough to use C directly


Fri, 15 Oct 2010, 11:17
waroffice
I finally got it working, cheers guys.

twitter.com/#!/cssheadshot