Server Help

Bot Questions - ifstream help

Falco_ - Mon Jun 13, 2005 11:28 pm
Post subject: ifstream help
Could someone help me with a top 5 plug. Basically it will record all of the players that have played elim and will search through a file to find the best to worst rec and will display it when you say !top # Does merv support searching through a file and deleting old info? (For example: a name is already in a file, and has its win:loss ratio; i want to change it but del the old info) If there is a better way to do this please tell me because i always code the long way. lol.
CypherJF - Mon Jun 13, 2005 11:54 pm
Post subject:
No merv doesn't support a feature such as this natively. I personally like using INI files because their quick and ez - though they are probably inefficient? But as for you, I'd suggest making your own internal structure - read the data from the file - handling the ordering of the data as you read in each new entry.
Falco_ - Tue Jun 14, 2005 10:32 am
Post subject: ifstream
Quote:
-read the data from the file

so should i do it this way to insert the info?
Code: Show/Hide
//this is for to put the info in the file

ofstream file("topelim.ini", ios::app);
String s;
s += "*arena Game over";
s += " - The Winner is: ";
.....
s += winner->name;
s += " [";
s += wins;
s += "-";
s += losses;
s += "]";

file << winner->name << wins << losses << endl;


If i just keep entering winner->name over and over, it will never replace the old data. Please explain a better way.
Purge - Tue Jun 14, 2005 11:40 am
Post subject:
If you need help making the bot read from a text file such as an INI, refer here.
Bak - Tue Jun 14, 2005 2:57 pm
Post subject: Re: ifstream
Read the data in from the file as you write it out to a temporary file (or a temporary data structure). Update any data you want. Copy the temp file back over the original one (or from the data structure).
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group