read gamelog from scripts.dll [message #205903] |
Wed, 28 June 2006 16:07 |
|
sycar
Messages: 144 Registered: February 2006 Location: Reading, UK
Karma: 0
|
Recruit |
|
|
i know its possible im just not sure how so if someone could point me in the right direction or give me some example code that would be great!
but how can i get the scripts.dll to read the gamelogs, basically i want to create my own custom commands in scripts.dll so you get the idea.
Cheers buffymaniack
|
|
|
Re: read gamelog from scripts.dll [message #205917 is a reply to message #205903] |
Wed, 28 June 2006 16:54 |
|
theplague
Messages: 261 Registered: May 2004
Karma: 0
|
Recruit |
|
|
well, heres a clue, you gotta do it line, by line. As in, everytime you read it, you gotta load the whole file, then set the position you wanna read from.
long last_line = 0;
ifstream gamelog("example_gamelog_name.txt"); // gamelog names do change, your gonna have to generate the correct names
if (gamelog.is_open()) {
std::string line;
gamelog.seekg (last_line, ios::beg); // puts it back to the last read position
while (!gamelog.eof()) { // reads until the end of file is reached
getline(gamelog,line); // saves a line into a string 'line' to do with as you wish
}
gamelog.seekg(0, ios::end); // sets the pointer to the last point in the file
last_line = gamelog.tellg(); // saves the last point into the variable 'last_line'
} else {
printf("Error occured, gamelog unreadable.\n");
}
and all this could be within a function and called every X time period, or whenever checking of new lines is needed.
[Updated on: Wed, 28 June 2006 16:55] Report message to a moderator
|
|
|
Re: read gamelog from scripts.dll [message #205919 is a reply to message #205903] |
Wed, 28 June 2006 17:11 |
|
Whitedragon
Messages: 832 Registered: February 2003 Location: California
Karma: 1
|
Colonel |
|
|
Reading gamelog from scripts.dll is pointless. All the information that is in gamelog is available through various scripts.dll functions that your stuff can also use.
Black-Cell.net
Network Administrator (2003 - )
DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )
Dragonade, Renegade's first server side modification
Lead coder (2005 - )
|
|
|
|
|
|
|
Re: read gamelog from scripts.dll [message #206059 is a reply to message #205903] |
Thu, 29 June 2006 16:12 |
|
For 2.9, I am going to add a hook that will get called everytime something is written to the console. Maybe you could use that to get your "renlog" parsing.
Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
|
|
|
|
Re: read gamelog from scripts.dll [message #206181 is a reply to message #205903] |
Fri, 30 June 2006 18:40 |
|
theplague
Messages: 261 Registered: May 2004
Karma: 0
|
Recruit |
|
|
wd, i made a mistake about the page's but player leave is in the renlog. page is in the bhs logs, which is still a log.
what confuses me is if bhs.dll can get pages, why can't it be made into a hook? or is there a deeper reason?
ChathookAddChatHook(hook); /* add this someplace at the execution of the scripts,
like in dllmain's section where it loads the bhs.dll functions
and stuff. or even when ObjectHookClass's start is called*/
const char *WideCharToChar(const wchar_t *wcs); // this is in engine.h/.cpp so no need to redo the whole body
void hook(int id, int type, const wchar_t *msg) {
// type 0 = normal chat
// type 1 = team chat
if (type == 2) return; // don't want ppage's to show as chat
std::string text = WideCharToChar(msg);
// phrase the message
}
[Updated on: Fri, 30 June 2006 18:46] Report message to a moderator
|
|
|
Re: read gamelog from scripts.dll [message #206207 is a reply to message #205903] |
Sat, 01 July 2006 03:08 |
|
sycar
Messages: 144 Registered: February 2006 Location: Reading, UK
Karma: 0
|
Recruit |
|
|
ok thanks for that, i found that the ssaow already claims the right to the chat hook, and from bhs.txt says only one hook can be in use at one time, so i guess I'll have to embed it inside the ssaow chat hook.
unless anyone knows different?
thanks buffymaniack
|
|
|