Home » Technical Support » Other » new fds bot, c++ php, perl
Re: new fds bot, c++ php, perl [message #207993 is a reply to message #207285] |
Fri, 14 July 2006 00:35 |
dead6re
Messages: 602 Registered: September 2003
Karma: 0
|
Colonel |
|
|
Most regulators read the information the FDS & and SSAOW from the renlog_<date>.txt because that used to be the only way.
Let all your wishes be granted except one, so you will still have something to strieve for.
|
|
|
|
|
|
Re: new fds bot, c++ php, perl [message #208347 is a reply to message #207285] |
Sun, 16 July 2006 02:33 |
dead6re
Messages: 602 Registered: September 2003
Karma: 0
|
Colonel |
|
|
There are two different methods for reading the renlog file.
BRenBot reads the log file be recording the line number that it is on and runs until the EOF. Then it waits a little while and then continues reading the file from the last line number to the EOF.
The other method is to copy the logfile to your Regulator directory and read the logfile.
Copy -> Read -> Wait for Renlog to get some info -> GoTo Start
Let all your wishes be granted except one, so you will still have something to strieve for.
|
|
|
|
Re: new fds bot, c++ php, perl [message #208397 is a reply to message #207285] |
Sun, 16 July 2006 10:32 |
|
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma: 0
|
General (3 Stars) |
|
|
thx, i never thought of that. at first i was going to read the file over and over untill it changes, but i thought that it will take alot of prosccessing power for and fast loop like that. the way you said is how i will do it, i will post again when i have some luck.
ty dan.
BTW: i will be crediting all the people that have help me on this project in the source file and as a hardcoded auto-anounce.
you really have helped me alot.
EDIT: i will be posting some source soon, maby in 2 weeks. Nightma12 were you really born in 1991? so was i...
[Updated on: Sun, 16 July 2006 12:15] Report message to a moderator
|
|
|
Re: new fds bot, c++ php, perl [message #208554 is a reply to message #207285] |
Mon, 17 July 2006 13:45 |
|
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma: 0
|
General (3 Stars) |
|
|
i have run into another problem, i have programmed my bot so far to get the date, open the file ssaow_<month>-<day>-<year>.txt read it delete it, print it out. it works when i put the file there myself. but not when i put it in the server dir why is this?
here is some code:
bool find_new_text(string &line)
{
string st;
string day, mon, year;
get_date(day, mon, year);
st.assign("ssaow_"+mon+"-"+day+"-"+year+".txt");
ifstream file;
file.open(st.c_str(), ios::in);
char buf[50];
if(file.is_open())
{
file.getline(buf, 50);
line.assign(buf);
file.close();
unlink(st.c_str());
return 1;
}
else
{
return 0;
}
return 0;
}
void pre_parse()
{
string find;
while(1)
{
if(find_new_text(find))
{
parse(find);
find.clear();
}
}
}
void parse(string line)
{
stringstream strs;
int f = 11;
while(f != line.size())
{
strs << line[f++];
}
cout << endl << strs.str();
}
parse() at the moment removes 11 chars from the beggining of the string and prints it.
pre_parse() is the function called;
the debug error i get is:
Debug Assertion Failed
Program: C:\Westwood\RenegadeFDS\Server\bot.exe
File: .\string
Line: 1508
Expression: string subscript out of range
why would it do this if i create the file manually and it works?
|
|
|
|
|
Re: new fds bot, c++ php, perl [message #208585 is a reply to message #208554] |
Mon, 17 July 2006 19:23 |
|
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma: 0
|
General (3 Stars) |
|
|
help-linux wrote on Mon, 17 July 2006 21:45 |
bool find_new_text(string &line)
{
string st;
string day, mon, year;
get_date(day, mon, year);
st.assign("ssaow_"+mon+"-"+day+"-"+year+".txt");
ifstream file;
file.open(st.c_str(), ios::in);
char buf[50];
if(file.is_open())
{
file.getline(buf, 50);
line.assign(buf);
file.close();
if(remove(line.c_str()) == -1)
{
cout << "could not delete"; //Changed this
}
return 1;
}
else
{
return 0;
}
return 0;
}
void pre_parse()
{
string find;
while(1)
{
if(find_new_text(find))
{
parse(find);
find.clear();
}
}
}
void parse(string line)
{
stringstream strs;
int f = 11;
if(!line.enpty()) // added this
{
while(f != line.size())
{
strs << line[f++];
}
}
cout << endl << strs.str();
}
|
it works now, i will be posting code next week i hope!
|
|
|
|
|
|
Re: new fds bot, c++ php, perl [message #208762 is a reply to message #207285] |
Tue, 18 July 2006 23:02 |
|
Cat998
Messages: 1081 Registered: January 2004 Location: Austria, Vienna
Karma: 0
|
General (1 Star) Moderator/Captain |
|
|
It's pretty easy, just create a function in the form
void Chat(int ID, int Type, const wchar_t *wc_msg) {
}
Then you need to tell the hook, to call your function everytime
someone sends a message with
It's the best when you do this in dllmain.cpp for the beginning (isn't nice, but it does what you want).
you maybe do not want to use widecharacter strings (wchar_t), so
you need to convert it to a normal char* string.
char str[256];
wcstombs(str, wc_msg, 256);
printf("Test: %s\n", str);
When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter then "Yes"
Programming is like sex: one mistake and you have to support it for the rest of your life
Want the best answers? Ask the best questions!
"So long, and thanks for all the fish."
[Updated on: Tue, 18 July 2006 23:03] Report message to a moderator
|
|
|
|
|
|
|
Re: new fds bot, c++ php, perl [message #208804 is a reply to message #208803] |
Wed, 19 July 2006 06:04 |
|
Cat998
Messages: 1081 Registered: January 2004 Location: Austria, Vienna
Karma: 0
|
General (1 Star) Moderator/Captain |
|
|
help-linux wrote on Wed, 19 July 2006 14:04 | i use visual c++ 2005 express edition. th whole error is:
all of the errors are on that line
|
It seems you've download an old version of the scripts source.
Download the latest one ( 2.8 )
Also, be sure you have installed the Microsoft SDK which
includes all the windows header files needed to compile it.
Sparkmist wrote on Wed, 19 July 2006 14:55 | But there might an even better way, using scripts.dll.. I dont know because I couldn't call scripts.dll functions with the noob scripting lang I used for my crappy bot
|
It's because it isn't possible to call it from outside
When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter then "Yes"
Programming is like sex: one mistake and you have to support it for the rest of your life
Want the best answers? Ask the best questions!
"So long, and thanks for all the fish."
[Updated on: Wed, 19 July 2006 06:04] Report message to a moderator
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Oct 31 14:59:02 MST 2024
Total time taken to generate the page: 0.02079 seconds
|