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
file reading

 
Post new topic   Reply to topic Printable version
 View previous topic  Bot spawning Post :: Post Damage Packet? Protocol?  View next topic  
Author Message
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Nov 25, 2007 3:54 am    Post subject: file reading Reply to topic Reply with quote

i was looking to write a dll for mervbot.
just a simple staff list from staff.txt...

Code: Show/Hide

void botInfo::gotCommand(Player *p, Command *c)
...
case OP_Player:
      {
         if (c->check("staff"))
         {
            sendPrivate(p, "start");
            char line [256];
            ifstream staff;
            staff.open("staff.txt");
            if (!staff)
            {
               sendPrivate(p, "Error loading staff.txt");
            }
            staff>>line;
            while (!EOF)
            {
               sendPrivate(p, line);
               staff>>line;
               sendPrivate(p, "loop");
            }
            staff.close();
            sendPrivate(p, "end");
         }


i added start, loop, and end for debugging.
so it compiles and loads, but only pms you start and end.
which means its completely ignoring my loop.

also, when i remove staff.txt, theres no error.
which means its ignoring my error too.

what am i missing?
_________________
SSC Distension Owner
SSCU Trench Wars Developer
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Sun Nov 25, 2007 6:46 pm    Post subject: Reply to topic Reply with quote

try
Code: Show/Hide
while (!staff.eof())

_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sun Nov 25, 2007 7:00 pm    Post subject: Reply to topic Reply with quote

if you remove staff.txt it doesn't crash? try making the condition if (!staff.good()) and put the rest of the crap in an else block
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Nov 25, 2007 8:17 pm    Post subject: Reply to topic Reply with quote

for some reason, those dont work =S
mine dont either...

also,
why can i use sendPrivate(p, "loop");
with "loop" and not a string?
using char ignores whitespace in my file...

----

so all that was too complicated and didnt work.
i tried this, and it worked.
Code: Show/Hide
case OP_Player:
      {
         if (c->check("about"))
         {
            sendPrivate(p, "I display the staff list.");
         }
         if (c->check("version"))
         {
            sendPrivate(p, "staff.dll by Cheese");
         }
         if (c->check("staff"))
         {
            ifstream staff;
            staff.open("staff.txt");
            char line [256];
            while (staff.getline(line, 256))
            {
               sendPrivate(p, line);
            }
            staff.close();
         }
      }
however,
Code: Show/Hide
            if (staff.bad())
            {
               sendPrivate(p, "Staff.txt is missing");
            }
didnt.
renaming or deleting the file didnt make anything happen.
i tried staff.bad(), !staff.good(), !staff.exist(), and !staff.
nothing at all
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Mon Nov 26, 2007 5:02 am    Post subject: Reply to topic Reply with quote

What about staff.is_open() ?
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Mon Nov 26, 2007 8:06 am    Post subject: Reply to topic Reply with quote

sendPrivate needs a String, which is one of catid's classes and not built-in. If you look in mervbot source you'll see theres a constructor that takes in a const char* so it can cast it implicitly.

If you want to use a string, try

sendPrivate(p,(String)stringVar.c_str());
Back to top
View users profile Send private message Add User to Ignore List 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: 17 page(s) served in previous 5 minutes.

phpBB Created this page in 0.550080 seconds : 31 queries executed (82.7%): GZIP compression disabled