Author |
Message |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Thu Jun 22, 2006 10:45 pm Post subject: C++:text, numbered output. |
 |
|
|
|
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 |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Fri Jun 23, 2006 6:21 am Post subject: |
 |
|
|
|
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 |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Fri Jun 23, 2006 12:16 pm Post subject: |
 |
|
|
|
Thanks Smong. I'll give it a try. |
|
Back to top |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Fri Jun 23, 2006 12:51 pm Post subject: |
 |
|
|
|
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
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...
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 |
|
 |
D1st0rt Miss Directed Wannabe

Age:37 Gender: Joined: Aug 31 2003 Posts: 2247 Location: Blacksburg, VA Offline
|
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
Posted: Fri Jun 23, 2006 10:41 pm Post subject: |
 |
|
|
|
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 |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Sat Jun 24, 2006 1:15 am Post subject: |
 |
|
|
|
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....
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 |
|
 |
Muskrat Server Help Squatter

Age:38 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Sat Jun 24, 2006 1:47 am Post subject: |
 |
|
|
|
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 |
|
 |
BDwinsAlt Agurus's Posse

Age:34 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Sat Jun 24, 2006 2:31 am Post subject: |
 |
|
|
|
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 |
|
 |
|