 |
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Mon Mar 01, 2004 1:37 am Post subject: Retard Quetion |
 |
|
|
|
Uint16 botInfo::FindFile(char *name)
{
Uint16 Rank=0;
Uint16 Lines=0;
char FromFile[40];
bool Success=false;
ifstream infile("Ranks.bank",ios::in);
while(infile.good())
{
infile.getline(FromFile,20,':');
Lines++;
if(CMPSTR(FromFile,name))
{
ofstream outfile("temp2.txt",ios::app);
if(outfile.good())
{
Success=true;
infile.getline(FromFile,10);
Rank=getInteger(FromFile,10);
infile.seekg(0,ios::beg);
if(infile.eof())
{infile.clear();}
while(infile.good())
{
infile.getline(FromFile,40);
Lines--;
if(Lines!=0)
{
if(FromFile[0]!='\0')
{outfile << FromFile << endl;}
}
}
}
outfile.close();
break;
}
else
{infile.ignore(256,'\n');}
}
infile.close();
if(Success)
{
_unlink("Ranks.bank");
rename("temp2.txt","Ranks.bank");
}
return Rank;
}
|
Ok I made a rank bot for a ctf game for DS and this is one of the functions. The idea was to not have to load the entire file into a linkedlist or keep a linklist full of people that arnt online at the time. oh, shit, my cat just farted on me...ok anyway. The job of the function is to just read a file, and once it finds the player's name in the file, it will delete that player's name out of the file and the return the player's rank #. The problem is that I dont know of any ways to delete lines out of a file. So i copy the file over to another file and skip over the part i dont want. Then rename the file/delete the old one.
I dont know if this is the best way to go about this, Im just looking for the best way to do it.
After the player leaves the arena, the player's name is added back into the file along with thier rank and then deleted from linklist.
Edit: removed comments from code. they were making it unreadable |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Mon Mar 01, 2004 9:24 am Post subject: |
 |
|
|
|
*cough*MySQL*cough* _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Mon Mar 01, 2004 6:45 pm Post subject: |
 |
|
|
|
Yep, methinks Brain's got it pinned.
What you're trying to do is a bit too ungainly doing it with just text. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Mon Mar 01, 2004 6:54 pm Post subject: |
 |
|
|
|
<3 |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 416 page(s) served in previous 5 minutes.
|