| View previous topic :: View next topic |
| Author |
Message |
Mas Voice
Joined: 04 Feb 2016 Posts: 2
|
Posted: Thu Feb 04, 2016 5:16 pm Post subject: Deleting a specific thing in an output file |
|
|
Hello ... I have a score file in which there are two things when its output it seems like this
teamname,points
example
Gladiators,5000 Titanic,3000 Clusters,2000
at months end it reset whole file and i just want to delete the scores and reset it to 0 as below
Gladiators,0 Titanic,0 Clusters,0
#MANUALLY reset current Team Member scores & Team Scores for month MANUALLY
proc tgresetscores {nick host hand text} {
global tgteambyname tgteamscore tgscoresbyname tgteamscoretotal
global tgtscf tgteamscore
if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} {
if {[file exists member.scores]&&[file size member.scores]>2} {
set _sfile [open member.scores w]
puts $_sfile ""
close $_sfile
set tgteamscore ""
set tgteamscoretotal 0
}
#THIS IS THE 2ND PART WHICH IS RESETTING WHOLE FILE WE JUST NEED TO DELETE THE SCORE NOT THE TEAM
if {[file exists $tgtscf]&&[file size $tgtscf]>2} {
set _sfile [open $tgtscf w]
puts $_sfile ""
close $_sfile
set tgteamscore ""
set tgteamscoretotal 0
}
tggamemsg "[tgcolrset]===== Score table & Stats reset by $nick! ====="
}
}
[/code]
Last edited by Mas on Thu Mar 03, 2016 5:00 pm; edited 1 time in total |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Feb 16, 2016 9:36 pm Post subject: |
|
|
| Code: |
proc tgresetscores {nick host hand text} {
global tgteambyname tgteamscore tgscoresbyname tgteamscoretotal
global tgtscf tgteamscore
if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} {
if {[file exists member.scores]&&[file size member.scores]>2} {
set _sfile [open member.scores w]
puts $_sfile ""
close $_sfile
### remove 2 lines here ###
}
#THIS IS THE 2ND PART WHICH WE JUST NEED TO DELETE THE SCORE NOT THE TEAM
set tlist [array names tgteamscore]
foreach team $tlist {
set tgteamscore($team) 0
}
tgsavescores
set tgteamscoretotal [llength $tlist]
tggamemsg "[tgcolrset]===== Score table & Stats reset by $nick! ====="
}
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Mas Voice
Joined: 04 Feb 2016 Posts: 2
|
Posted: Tue Feb 16, 2016 9:50 pm Post subject: Thank you very mich Spike^^ |
|
|
| Thank you very much Spike^^ bro you are a life saver really your code worked like a charm ... thanks once again.... |
|
| Back to top |
|
 |
|