Server Help

Bot Questions - 8ball - build 2

CypherJF - 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.
SuSE - Thu Jun 17, 2004 5:14 am
Post subject:
OMFG <SPURT>
CypherJF - Thu Jun 17, 2004 5:14 am
Post subject:
$$
50% Packetloss - Thu Jun 17, 2004 11:12 am
Post subject:
Where's the source code?
Bak - 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
Cyan~Fire - Thu Jun 17, 2004 8:00 pm
Post subject:
I think that source will always negatively index the array, dude.
50% Packetloss - 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));];
CypherJF - 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...
Cyan~Fire - 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.
50% Packetloss - 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)));
CypherJF - 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.
Bak - 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
Cyan~Fire - Sat Jun 19, 2004 12:16 pm
Post subject:
static_cast is totally unnecessary. A time_t is a perfectly good argument for srand()
CypherJF - Sat Jun 19, 2004 9:00 pm
Post subject:
$$
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group