Needs an if $exists for the file on load event.
I only put enough file writes to demonstrate.
Eliminated set/global variables.
Eliminated _jibb alias.
Simplified while loops.
Changed !commands so !8ball* could
be used in on TEXT event filter.
on *:TEXT:!8ball*:#: {
var %i 1,%x,%f $scriptdir8ball.txt
if $1 == !8balladd {
if $nick(#,$nick,~&@) {
if $2 {
while $read(%f,%i) {
if $2- == $v1 { %x = 1 }
inc %i
}
if %x { msg # $+(,",$2-,",) has already been added. }
else { write %f $2- | msg # $+(,",$2-,",) has been added to the reply list. }
}
else { msg # No Reply Was Stated. }
}
else { msg # access denied }
}
elseif $1 == !8balldel {
if $nick(#,$nick,~&@) {
if $2 {
while $read(%f,%i) {
if $2- == $v1 { %x = %i }
inc %i
}
if %x { write -dl $+ %x %f | msg # $+(,",$2-,",) has been deleted. }
else { msg # No Matching Entries Found }
}
else { msg # Please Enter Something To Delete. }
}
else { msg # access denied }
}
elseif $1 == !8ball {
if $2 {
if $me isin $2- {
goto $r(1,4)
:1 | msg # $nick if you dont stop picking on $me I'm gonna kick you in the nutz! | halt
:2 | msg # I'm sorry $nick he's not here right now can I help you? | halt
:3 | msg # Flattery will get you nowhere $nick $+ . | halt
:4 | msg # $nick $+ , I'll lick you for 50 cents.
}
else { msg # $read(%f) }
}
else { msg # Please Enter A Question Silly }
}
}
on *:LOAD: {
echo -a JibbaNet 8ball v1.0 Loaded
var %f $scriptdir8ball.txt
if !$exists(%f) {
echo -a Default Replies written to: %f
%f = write %f
%f Ask again later
%f Not a chance
%f As I see it, yes
%f Cannot predict now
%f Don't count on it
%f It is certain
}
}