Author |
Message |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Jun 17, 2004 5:08 am Post subject: 8ball - build 2 |
 |
|
|
|
Was going through my old plugin files, and found this and updated it...
Added Support for sayings to be read from an INI file.
Commands added in build 2:
!reloadsayings - reloads the INI file.
Have fun. _________________ Performance is often the art of cheating carefully. - James Gosling
8ball build2
8ball.b2.zip - 21.96 KB
File downloaded or viewed 19 time(s)
|
|
Back to top |
|
 |
SuSE Me measures good

Joined: Dec 02 2002 Posts: 2307 Offline
|
Posted: Thu Jun 17, 2004 5:14 am Post subject: |
 |
|
|
|
OMFG <SPURT>
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Jun 17, 2004 5:14 am Post subject: |
 |
|
|
|
$$
|
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Thu Jun 17, 2004 11:12 am Post subject: |
 |
|
|
|
Where's the source code?
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Thu Jun 17, 2004 3:04 pm Post subject: |
 |
|
|
|
got command 8ball->
random numner n = (0-numersponses-1)
sendPrivate(p,resonses[n]);
there's your source
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Jun 17, 2004 8:00 pm Post subject: |
 |
|
|
|
I think that source will always negatively index the array, dude. _________________ 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: Thu Jun 17, 2004 8:52 pm Post subject: |
 |
|
|
|
lol 0 - numberofresponces -1
yah that will be real nice negative result
better would probably be
int range=numberofresponces+1;
responces[int(range * rand()/(RAND_MAX + 1.0));];
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Thu Jun 17, 2004 9:40 pm Post subject: |
 |
|
|
|
If anyone really needs the src, they can email or PM me; but...
int temp = rand()%max_resp;
and it's seeded on the first !8ball request...
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Thu Jun 17, 2004 11:11 pm Post subject: |
 |
|
|
|
I'd recommend seeding ahead of time and throwing away one rand(), because I've noticed mysterious duplicates on the first rand() called from a similar seed.
|
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Fri Jun 18, 2004 2:20 pm Post subject: |
 |
|
|
|
if there are 0 responces, rand()%0 will crash the program
yah and seed rand() in spawn.h
srand(static_cast<unsigned>(time(0)));
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Fri Jun 18, 2004 10:00 pm Post subject: |
 |
|
|
|
max_resp is hard-coded to 9 responces. If a responce is blank in the INI it uses the programs' default.
and is seeded w/ the current time... when the first !8ball is done.
w/ src.
8ball.b2.zip - 28.78 KB
File downloaded or viewed 12 time(s)
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Jun 18, 2004 10:48 pm Post subject: |
 |
|
|
|
Quote: | 0 - numberofresponces -1
yah that will be real nice negative result |
it was meant as a "to" rather than a minus... like if i say I have 5-10 minutes to get to the store I don't mean I have negative 5 minutes.
so 0 to numberofresponces-1
|
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Sat Jun 19, 2004 12:16 pm Post subject: |
 |
|
|
|
static_cast is totally unnecessary. A time_t is a perfectly good argument for srand()
|
|
Back to top |
|
 |
CypherJF I gargle nitroglycerin

Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sat Jun 19, 2004 9:00 pm Post subject: |
 |
|
|
|
$$
|
|
Back to top |
|
 |
|