| View previous topic :: View next topic |
| Author |
Message |
jonathan3061 Voice
Joined: 10 Apr 2007 Posts: 2
|
Posted: Tue Apr 10, 2007 1:26 pm Post subject: adding another arg to existing script |
|
|
i currently have this piece of script:
| Code: |
proc war_addmatch {nick uhost handle channel arg} {
global war_privchan war_counter war_authsys botnick war_playernumber war_trigger
set channel [string tolower $channel]
if {$channel==$war_privchan} {
if {(![matchattr $handle V])&&($war_authsys==1)} {
putserv "NOTICE $nick :5You are not authed, use /msg $botnick [string trim $war_trigger]admin <password>"
return 0
}
set check [war_charfilter $arg]
if {$check!=1} {
putserv "NOTICE $nick :5Invalid character: \"$check\". Please do not use such character in any field."
return 0
}
if {([lsearch $arg "team(*"]==-1)||([lsearch $arg "date(*"]==-1)||([lsearch $arg "map(*"]==-1)} {
putserv "NOTICE $nick :5Invalid args, you need to enter at least the team(x), date(hh:mm-dd/mm/yy) and map(x) ( + info(x) or number(x) )"
return 0
}
set startindex [lsearch $arg "date(*"]
set buf [lrange $arg $startindex end]
set infos [string range $buf 5 [expr [string first ")" $buf]-1]]
set errormsg [war_checkdate $infos]
if {$errormsg!=1} {
putserv "NOTICE $nick :$errormsg"
return 0
}
set infos [clock scan "[string range $infos 12 13][string range $infos 9 10][string range $infos 6 7] [string range $infos 0 1][string range $infos 3 4]00"]
set infos [linsert $infos 0 $war_counter]
set startindex [lsearch $arg "team(*"]
set buf [lrange $arg $startindex end]
set team [string range $buf 5 [expr [string first ")" $buf]-1]]
set startindex [lsearch $arg "map(*"]
set buf [lrange $arg $startindex end]
set map [string range $buf 4 [expr [string first ")" $buf]-1]]
set info "nothing"
if {[lsearch $arg "info(*"]>-1} {
set startindex [lsearch $arg "info(*"]
set buf [lrange $arg $startindex end]
set info [string range $buf 5 [expr [string first ")" $buf]-1]]
}
set number $war_playernumber
if {[lsearch $arg "number(*"]>-1} {
set startindex [lsearch $arg "number(*"]
set buf [lrange $arg $startindex end]
set number [string range $buf 7 [expr [string first ")" $buf]-1]]
}
set infos [linsert $infos end $team "n/a" "n/a" $map "n/a" $info $number]
war_insertion $infos
war_savefiles
set infos [war_getinfos $war_counter 2]
incr war_counter
set id [lindex $infos 0]
set hour [lindex $infos 1]
set date [lindex $infos 2]
set team [lindex $infos 3]
set maps [lindex $infos 6]
set info [lindex $infos 8]
set number [lindex $infos 9]
if {$number==$war_playernumber} {
putserv "PRIVMSG $channel : 5New war on $date at $hour against $team . Maps: $maps . Infos: $info ( ID $id )"
} else {
putserv "PRIVMSG $channel : 5New war on $date at $hour against $team . Maps: $maps . Infos: $info . Player number: $number . ( ID $id )"
}
war_automanagement
}
}
|
and i'm trying to add in another $arg , I want it to work the same as $info but I can't get it to work :s. I don't know much of TCL scripting... this is what i've tried so far:
| Code: |
proc war_addmatch {nick uhost handle channel arg} {
global war_privchan war_counter war_authsys botnick war_playernumber war_trigger
set channel [string tolower $channel]
if {$channel==$war_privchan} {
if {(![matchattr $handle V])&&($war_authsys==1)} {
putserv "NOTICE $nick :5You are not authed, use /msg $botnick [string trim $war_trigger]admin <password>"
return 0
}
set check [war_charfilter $arg]
if {$check!=1} {
putserv "NOTICE $nick :5Invalid character: \"$check\". Please do not use such character in any field."
return 0
}
if {([lsearch $arg "team(*"]==-1)||([lsearch $arg "date(*"]==-1)||([lsearch $arg "map(*"]==-1)} {
putserv "NOTICE $nick :5Invalid args, you need to enter at least the team(x), date(hh:mm-dd/mm/yy) and map(x) ( + info(x) or number(x) )"
return 0
}
set startindex [lsearch $arg "date(*"]
set buf [lrange $arg $startindex end]
set infos [string range $buf 5 [expr [string first ")" $buf]-1]]
set errormsg [war_checkdate $infos]
if {$errormsg!=1} {
putserv "NOTICE $nick :$errormsg"
return 0
}
set infos [clock scan "[string range $infos 12 13][string range $infos 9 10][string range $infos 6 7] [string range $infos 0 1][string range $infos 3 4]00"]
set infos [linsert $infos 0 $war_counter]
set startindex [lsearch $arg "team(*"]
set buf [lrange $arg $startindex end]
set team [string range $buf 5 [expr [string first ")" $buf]-1]]
set startindex [lsearch $arg "map(*"]
set buf [lrange $arg $startindex end]
set map [string range $buf 4 [expr [string first ")" $buf]-1]]
set info "nothing"
if {[lsearch $arg "info(*"]>-1} {
set startindex [lsearch $arg "info(*"]
set buf [lrange $arg $startindex end]
set info [string range $buf 5 [expr [string first ")" $buf]-1]]
}
set number $war_playernumber
if {[lsearch $arg "number(*"]>-1} {
set startindex [lsearch $arg "number(*"]
set buf [lrange $arg $startindex end]
set number [string range $buf 7 [expr [string first ")" $buf]-1]]
}
set type "pcw"
if {[lsearch $arg "type(*"]>-1} {
set startindex [lsearch $arg "type(*"]
set buf [lrange $arg $startindex end]
set type [string range $buf 5 [expr [string first ")" $buf]-1]]
}
set infos [linsert $infos end $team "n/a" "n/a" $map "n/a" $info $number $type]
war_insertion $infos
war_savefiles
set infos [war_getinfos $war_counter 2]
incr war_counter
set id [lindex $infos 0]
set hour [lindex $infos 1]
set date [lindex $infos 2]
set team [lindex $infos 3]
set maps [lindex $infos 6]
set info [lindex $infos 8]
set number [lindex $infos 9]
set type [lindex $infos 10]
if {$number==$war_playernumber} {
putserv "PRIVMSG $channel : 5New $type on $date at $hour against $team . Maps: $maps . Infos: $info ( ID $id )"
} else {
putserv "PRIVMSG $channel : 5New $type on $date at $hour against $team . Maps: $maps . Infos: $info . Player number: $number . ( ID $id )"
}
war_automanagement
}
}
|
Can anybody please push me in the right direction and explain me what i'm doing wrong?  |
|
| Back to top |
|
 |
jonathan3061 Voice
Joined: 10 Apr 2007 Posts: 2
|
Posted: Mon Apr 16, 2007 3:55 am Post subject: |
|
|
anyone
 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Apr 16, 2007 5:45 am Post subject: |
|
|
Without knowing how "war_getinfos" is written, it would be pretty hard to know how to help you with your request. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Mon Apr 16, 2007 1:15 pm Post subject: |
|
|
It would also be helpful if you posted a *summary* of what you tried, and what exactly you're trying to test, rather than the entire script, as it's very difficult to see any changes the way you posted. I'm not inclined to save both copies just to 'diff' them to figure out what is different. There's also function calls (such as set check [war_charfilter $arg] ) but you didn't post those functions so it's impossible to tell what is being done..
So, tell us what the content of $args is, and what you're trying to add as a new arg, and what you want as a new test.
In general, you need to use lindex to split $arg into new vars. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|