| View previous topic :: View next topic |
| Author |
Message |
monie089 Halfop
Joined: 29 Jul 2006 Posts: 76
|
Posted: Wed Aug 09, 2006 5:27 pm Post subject: how do i make files |
|
|
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 |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Wed Aug 09, 2006 5:36 pm Post subject: |
|
|
That sould do it I hope:
| Code: | 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 |
|
| Back to top |
|
 |
monie089 Halfop
Joined: 29 Jul 2006 Posts: 76
|
Posted: Wed Aug 09, 2006 6:14 pm Post subject: |
|
|
| Thanks |
|
| Back to top |
|
 |
monie089 Halfop
Joined: 29 Jul 2006 Posts: 76
|
Posted: Wed Aug 09, 2006 6:53 pm Post subject: |
|
|
| Code: |
##########################################################
#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 |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Wed Aug 09, 2006 10:13 pm Post subject: |
|
|
Moved to: Scripting Help _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
monie089 Halfop
Joined: 29 Jul 2006 Posts: 76
|
Posted: Thu Aug 10, 2006 2:27 pm Post subject: |
|
|
| Code: |
##########################################################
#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 |
|
| Back to top |
|
 |
monie089 Halfop
Joined: 29 Jul 2006 Posts: 76
|
Posted: Thu Aug 10, 2006 8:57 pm Post subject: |
|
|
| i edited that can anyone help |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Fri Aug 11, 2006 6:59 am Post subject: |
|
|
Now it should work. I deleted some mistakes.
| Code: | 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 |
|
| Back to top |
|
 |
monie089 Halfop
Joined: 29 Jul 2006 Posts: 76
|
Posted: Fri Aug 11, 2006 8:24 am Post subject: |
|
|
| everything works but the find it keeps saying name not found |
|
| Back to top |
|
 |
darton Op
Joined: 21 Jan 2006 Posts: 155
|
Posted: Fri Aug 11, 2006 10:54 am Post subject: |
|
|
Forgot to replace a word.
I've edited my post. Copy it again and it will work. I also improved the !add script. |
|
| Back to top |
|
 |
monie089 Halfop
Joined: 29 Jul 2006 Posts: 76
|
Posted: Fri Aug 11, 2006 11:48 am Post subject: |
|
|
| Thanks it worked nw thanks for helping me im still learning |
|
| Back to top |
|
 |
|