Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Retard Quetion

 
Post new topic   Reply to topic Printable version
 View previous topic  Powerball Post :: Post Reading .ini files  View next topic  
Author Message
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Mon Mar 01, 2004 1:37 am    Post subject: Retard Quetion Reply to topic Reply with quote

Code: Show/Hide

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
View users profile Send private message Add User to Ignore List Send email AIM Address
Dr Brain
Flip-flopping like a wind surfer


Age:39
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Mon Mar 01, 2004 9:24 am    Post subject: Reply to topic Reply with quote

*cough*MySQL*cough*
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Mar 01, 2004 6:45 pm    Post subject: Reply to topic Reply with quote

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
View users profile Send private message Add User to Ignore List Visit posters website
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Mon Mar 01, 2004 6:54 pm    Post subject: Reply to topic Reply with quote

<3
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 25 page(s) served in previous 5 minutes.

phpBB Created this page in 0.447994 seconds : 29 queries executed (94.4%): GZIP compression disabled