This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how do i make files

Help for those learning Tcl or writing their own scripts.
Post Reply
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

how do i make files

Post by monie089 »

im trying to make a script when someone does
!add <game> <code>
it writes
the persons name and code and the game they added
like
[$nick]
<game>
<code>
like that
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

That sould do it I hope:

Code: Select all

set gamefile "scripts/game.txt"
if {![file exists $gamefile]} {
   catch {close [open $gamefile w]}
}
bind pub - !add pub:add
proc pub:add {nick uhost hand chan arg} {
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
 if {$game != "" && $code != ""} {
  set fd [open $::gamefile r+]
    while {![eof $fd]} {
     lappend list [gets $fd]
    }
    if {[lindex $list end] == ""} {
      set list [lreplace $list end end]
    }
     lappend list "\[$nick\] <$game> <$code>"
     seek $fd 0
     puts -nonewline $fd [join $list \n]
     close $fd
 } else {
   putserv "PRIVMSG $nick :Usage: !add <game> <code>"
 }
}
Last edited by darton on Sun Aug 13, 2006 5:46 pm, edited 2 times in total.
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

Thanks
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

Code: Select all

##########################################################
#Friendcodes IRC script written by monie                 #
#email monie <xg.monie089@gmail.com>                     #
#monie @ Friendcodes #NintendoXG,#IRCsupport,#Friendcodes#
##########################################################
bind pub -|- !friendcodes pub:friendcodes

proc pub:friendcodes {nickname hostname handle channel arguments } {
putquick "PRIVMSG $nickname :$nickname Welcome ShadowBot Wifi Central"
putquick "PRIVMSG $nickname :$nickname,To use WiFi Central"
putquick "PRIVMSG $nickname :Games currently supported are"
putquick "PRIVMSG $nickname :MKDS,MPH,LM,THAS,DSAIR,StarFox"
putquick "PRIVMSG $nickname :Type !add <game> <code> "
putquick "PRIVMSG $nickname :To find a friendcode type"
putquick "PRIVMSG $nickname :!find <nick>"
putquick "PRIVMSG $nickname :To Delete Your code type"
putquick "PRIVMSG $nickname :!del <game>"
putquick "PRIVMSG $nickname :Scripted by MÔnie"
}
set gamefile "scripts/game.txt"
if {![file exists $gamefile]} {
   catch {close [open $gamefile w]}
}
bind pub - !add pub:add
proc pub:add {nick uhost hand chan arg} {
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
 if {$game && $code != ""} {
  set fd [open $::gamefile r+]
      while {![eof $fd]} {
         lappend list [gets $fd]         
      }   
   lappend list "[$nick] <$game> <$code>"
    puts -nonewline $fd [join $list \n]
    close $fd   
 } else {
    putserv "PRIVMSG $chan :Usage: !add <game> <code>"
 }
}



putlog "Monies custom Friendcodes script loaded"
thats what i have so far but how do i make it find someones name and displays there code, also how do i do !del if someone wants to delete there code
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Moved to: Scripting Help
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

Code: Select all

##########################################################
#Friendcodes IRC script written by monie                 #
#email monie <xg.monie089@gmail.com>                     #
#monie @ Friendcodes #NintendoXG,#IRCsupport,#Friendcodes#
##########################################################
bind pub -|- !friendcodes pub:friendcodes

proc pub:friendcodes {nickname hostname handle channel arguments } {
putquick "PRIVMSG $nickname :$nickname Welcome ShadowBot Wifi Central"
putquick "PRIVMSG $nickname :$nickname,To use WiFi Central"
putquick "PRIVMSG $nickname :Games currently supported are"
putquick "PRIVMSG $nickname :MKDS,MPH,LM,THAS,acww"
putquick "PRIVMSG $nickname :Type !add <game> <code> "
putquick "PRIVMSG $nickname :To find a friendcode type"
putquick "PRIVMSG $nickname :!find <nick>"
putquick "PRIVMSG $nickname :To Delete Your code type"
putquick "PRIVMSG $nickname :!del <game>"
putquick "PRIVMSG $nickname :Scripted by MÔnie"
}
set gamefile "scripts/game.txt"

if {![file exists $gamefile]} {
   catch {close [open $gamefile w]}
}

bind pub - !add pub:add
proc pub:add { nick uhost hand chan arg} {
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game && code != ""} {
set fd open $::mphfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
lappend list "[$nick] $game $code"
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nickname :Usage: !add <game> <code>"
}
}

bind pub - !find pub:find
proc pub:find {nick uhost hand chan arg} {
}




putlog "Monies custom Friendcodes script loaded"
thats the code but the add part doesnt work and for the find part how do i make it do
notice nickname $nicks code are
notice nickname mph:23232323
notice $nickname mkds:232343234
notice $nickname thas:232324323
notice $nickname acww:24334 name:blah town:blah
EDITED
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

i edited that can anyone help
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

Now it should work. I deleted some mistakes.

Code: Select all

set gamefile "scripts/game.txt"
if {![file exists $gamefile]} {
   catch {close [open $gamefile w]}
}
bind pub - !add pub:add
proc pub:add {nick uhost hand chan arg} {
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
 if {$game != "" && $code != ""} {
  set fd [open $::gamefile r+]
    while {![eof $fd]} {
     lappend list [gets $fd]
    }
    if {[lindex $list end] == ""} {
      set list [lreplace $list end end]
    }
     lappend list "\[$nick\] <$game> <$code>"
     seek $fd 0
     puts -nonewline $fd [join $list \n]
     close $fd
 } else {
   putserv "PRIVMSG $nick :Usage: !add <game> <code>"
 }
} 

bind pub - !find find:nick
proc find:nick {nick uhost hand chan arg} {
global gamefile
set name [lindex [split $arg] 0]
 if {$name != ""} {
  set fd [open $::gamefile r]
    while {![eof $fd]} {
     lappend list [gets $fd]
    }
    close $fd
    if {[set le [lsearch -glob $list "*$name*"]] != -1} {
     set line [lindex $list $le]
     set code [string map {< "" > ""} [lindex $line 2]]
     putserv "NOTICE $nick :The code $code belongs to $name."
    } else {
     putserv "NOTICE $nick :Name not found."
    }
 } else {
   putserv "PRIVMSG $nick :Usage: !find <nick>"
 } 
}
Last edited by darton on Fri Aug 11, 2006 11:40 am, edited 2 times in total.
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

everything works but the find it keeps saying name not found
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

Forgot to replace a word.
I've edited my post. Copy it again and it will work. I also improved the !add script.
m
monie089
Halfop
Posts: 76
Joined: Sat Jul 29, 2006 11:13 pm

Post by monie089 »

Thanks it worked nw thanks for helping me im still learning
Post Reply