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
C++:text, numbered output.

 
Post new topic   Reply to topic Printable version
 View previous topic  Can't connect to MYSQL server (using u... Post :: Post logicbot  View next topic  
Author Message
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Thu Jun 22, 2006 10:45 pm    Post subject: C++:text, numbered output. Reply to topic Reply with quote

I am working on sending out numbers along with the output on a mervbot plugin.

A file looks like this:
BDwinsAlt:event:Agurus
BDwinsAlt:sne:Agurus

I have everything setup and all except numbering the output as it goes.
Since it searches for SNE and EVENT I have two if statements. I need it to number something like

1. 250 bounty + prox (given by Agurus)
2. 500 bounty + prox (given by Agurus)

It is called by a text file in a prizes folder. Each player has their own file name. I need it to be able to identify a line by it's line number in the text file. I also need it to delete that line when they get the prize. Example: !prizeme 2, would delete line 2. All help is appreicated. I need to have this done by Saturday for Agurus.

Also I will be working on a 7 day experation date. So I need help writing time to a string and reading it to see if its past 7 days and erasing it if it is.


Last edited by BDwinsAlt on Fri Jun 23, 2006 7:43 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Fri Jun 23, 2006 6:21 am    Post subject: Reply to topic Reply with quote

If you load each line into an array, then the array index will match the line number. You would have to resize the array as you go or limit the number of prizes that can be stored.

Also for a timestamp, use something like time(NULL), that will return a number in seconds, no point writing it out as something like "Thursday 31st February 2005" and then trying to read that back in later.


Edit: typo.


Last edited by Smong on Fri Jun 23, 2006 7:03 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Fri Jun 23, 2006 12:16 pm    Post subject: Reply to topic Reply with quote

Thanks Smong. I'll give it a try.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Fri Jun 23, 2006 12:51 pm    Post subject: Reply to topic Reply with quote

Hmm I seem to still be having some trouble. Can you give me a basic example please? I'm usually writing in Java so this is a turn around for me.

Edit: My code is
Code: Show/Hide

               int a = 0;
               for(int a = 0; a < 10; a++)
               {
               if(player == pname)
               {
                  /////////////////////////
                  if(prize == "SNE" || prize == "sne" || prize == "Sne")
                  {
                     sendPrivate(p, int (a) + " 500 bounty + 2prox ");   
                  }
                  if(prize == "EVENT" || prize == "event" || prize == "Event")
                  {
                     sendPrivate(p, int (a) + " 250 bounty + prox");
                  }
                  }
               }


I get this...
Code: Show/Hide

BDwinsAlt> !listprize
   BDTEST1>  250 bounty + prox
   BDTEST1> 250 bounty + prox
   BDTEST1> 50 bounty + prox
   BDTEST1> 0 bounty + prox
   BDTEST1>  bounty + prox
   BDTEST1> bounty + prox
   BDTEST1> ounty + prox
   BDTEST1> unty + prox
   BDTEST1> nty + prox
   BDTEST1> ty + prox
   BDTEST1>  500 bounty + 2prox
   BDTEST1> 500 bounty + 2prox
   BDTEST1> 00 bounty + 2prox
   BDTEST1> 0 bounty + 2prox
   BDTEST1>  bounty + 2prox
   BDTEST1> bounty + 2prox
   BDTEST1> ounty + 2prox
   BDTEST1> unty + 2prox
   BDTEST1> nty + 2prox
   BDTEST1> ty + 2prox
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Fri Jun 23, 2006 10:24 pm    Post subject: Reply to topic Reply with quote

You could try formatting your string with sprintf, it would be something like (don't quote me on this because im just going off the top of my head)
Code: Show/Hide
sprintf(buf, "%d. 500 bounty + 2prox", a);
//where buf is the char* it will be located

_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Fri Jun 23, 2006 10:41 pm    Post subject: Reply to topic Reply with quote

BDwinsAlt wrote:
Hmm I seem to still be having some trouble. Can you give me a basic example please? I'm usually writing in Java so this is a turn around for me.

Based upon your output, it seems that if you add an integer to your string variable, it 'skips' ahead that many characters. Thus, 0 + "cat" = "cat", 2 + "cat" = "t"
Back to top
View users profile Send private message Add User to Ignore List Send email
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Sat Jun 24, 2006 1:15 am    Post subject: Reply to topic Reply with quote

Code: Show/Hide

char * buffer;
               if(player == pname)
               {
                  /////////////////////////
                                 int a = 1;
                  if(prize == "SNE" || prize == "sne" || prize == "Sne")
                  {
                  sprintf(buffer, "%d. 500 bounty + 2prox", a);
                  a=a+1;
                     sendPrivate(p, buffer);
                  }
                  if(prize == "EVENT" || prize == "event" || prize == "Event")
                  {
                  sprintf(buffer, "%d. 500 bounty + 2prox", a);
                  a=a+1;
                     sendPrivate(p, buffer);
                  }
               }



Results....
Code: Show/Hide

Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox
Catid.Bot> 1. 500 bounty + 2prox


It listed over and over because I added the same prize over and over.
Also, it will only show SNE, the sprintf won't allow event to some into play. How can I make this work accross two if statements.

Again, I am new to c++ bare with me.

It's like the first time int a is used it becomes static.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Muskrat
Server Help Squatter


Age:38
Joined: Aug 24 2004
Posts: 829
Location: Swamp
Offline

PostPosted: Sat Jun 24, 2006 1:47 am    Post subject: Reply to topic Reply with quote

Your int a = 1; needs to be relocated outside of the command-handling portion so it will keep the value correctly. You're just setting a to 1 each time it gets called.

I can't really understand what way you're trying to apply these prizes, but playertags might be handy(Mervbot, right?). You should probably not try storing data in a file yet. Or look at other plugins which already do similar things.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
BDwinsAlt
Agurus's Posse


Age:34
Gender:Gender:Male
Joined: Jun 16 2003
Posts: 1145
Location: Alabama
Offline

PostPosted: Sat Jun 24, 2006 2:31 am    Post subject: Reply to topic Reply with quote

I love you! You rock! It works! Using d1 and musk code together. You guys rock. Thanks. Now ill make it del lines and use time limits. Eck
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
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: 199 page(s) served in previous 5 minutes.

phpBB Created this page in 0.949322 seconds : 33 queries executed (97.1%): GZIP compression disabled