|
Joined: Dec 2006
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2006
Posts: 5 |
Hi Im sure some of you have seen the !latest scripts that are around on irc channels, anyone know how the ones with the numbers at the beginning of each line and the time added at the end of each line work? Sort of like this
1)some text here added 2hrs 45mins 17secs ago 2)some different text added 3hrs 12mins 38secs ago and so on
I really have no clue how this works so cant even paste any script at all, if anyone is feeling generous and wants to give some code examples that would be great Thanks in advance, just in case
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
Fjord artisan
Joined: Apr 2006
Posts: 400 |
ok, i was going to wait longer to see if someone had heard of something like that. Honestly, i have never heard of a script like that, is it possible if you could give some examples of how the script works? maybe a quote or two?
-Kurdish_Assass1n
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Well, it depends on how you store the data. Here's a simple example if you store the data in a text file using: //write filename.txt text $ctime
on *:text:!latest:#: {
if (!$isfile(filename.txt)) { msg $chan No data available. | return }
.play -a playlatest $chan filename.txt 1500
}
alias -l playlatest {
inc %latest.cnt
msg $1 %latest.cnt $+ $chr(41) $gettok($2-,1- $calc($gettok($2-,0,32) - 1),32) $duration($calc($ctime - $gettok($2-,0,32)))
if (%latest.cnt >= $lines(filename.txt)) { unset %latest.cnt }
}
That should work fine. Just remember that you need to use that command to write the data to the text file. If you manually enter the information into the text file, you need to find out what $ctime is and not just type $ctime there. To find out what it is, you can type //echo -a $ctime
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2006
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2006
Posts: 5 |
Hi Riamus2 Thank you for taking the time to reply and for the script example, However there seems to be some problems with it, again i have no idea why as i didnt know how it was going to work in the first place. Here is what i did to get it to add text to the latest.txt file on *:text:*:#mychan: { if !latest == $1 { if $nick isop #mychan { if .add == $2 { .write latest.txt $3- $ctime halt } alias -l playlatest { inc %latest.cnt notice $nick %latest.cnt $+ $chr(41) $gettok($2-,1- $calc($gettok($2-,0,32) - 1),32) $duration($calc($ctime - $gettok($2-,0,32))) if (%latest.cnt >= $lines(latest.txt)) { unset %latest.cnt } } .play -a playlatest $nick latest.txt 1500 } } I changed the msg $1 in your code to notice $nick as it came up with the error 'no such nick !latest' If i use !latest .add test1 and then open the latest.txt file it shows test1 1167171691 But if i then type !latest i get 1) 1929wks 5days 22hrs 24mins 13secs If i add more to latest.txt such as !latest .add test2 and !latest .add test3 etc. it also adds them to the text file but when i type !latest again i get the first entry as before with none of the text that was added (test1, test2 and test3) followed by Unknown command: PLAYLATEST in the status window of the client that is running the script Any clue what is going wrong? Thanks again for your time
|
|
|
|
Joined: Oct 2003
Posts: 313
Fjord artisan
|
Fjord artisan
Joined: Oct 2003
Posts: 313 |
on *:text:*:#mychan: {
if !latest == $1 {
if $nick isop #mychan {
if .add == $2 {
.write latest.txt $3- $ctime
halt
}
alias -l playlatest {
inc %latest.cnt
notice $nick %latest.cnt $+ $chr(41) $gettok($2-,1- $calc($gettok($2-,0,32) - 1),32) $duration($calc($ctime - $gettok($2-,0,32)))
if (%latest.cnt >= $lines(latest.txt)) { unset %latest.cnt }
}
.play -a playlatest $nick latest.txt 1500
}
}
With the code tags and some proper indentation you can (I hope) see where the problem is.... (note that the braces don't match up) I also don't see anywhere where you actually call the alias (that you haven't actually created...<hint>) playlatest...
Sais
|
|
|
|
Joined: Dec 2006
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2006
Posts: 5 |
Yep i can see the benefit of proper indentation, but i think i should have left the original code example alone as i seem to have caused more problems. No matter, my complete lack of scripting skills is at fault so your reply (apart from showing me proper indentation) was wasted. But thanks for taking the time all the same
Update: Actually the code example doesn't work. I tried it as is and manually entered the text along with doing //echo -a $ctime to get the time of the entry and although it does add the numbers to the start of each line it still outputs like this
1) test1 1929wks 6days 3hrs 22mins 32secs 2) test2 1929wks 6days 3hrs 22mins 33secs 3) test3 1929wks 6days 3hrs 22mins 35secs 4) test4 1929wks 6days 3hrs 22mins 36secs
Why it has 1929wks etc i have no idea, also the entries were added several minutes apart but shows only a second or two difference in the output.
Last edited by doh123; 27/12/06 03:32 AM.
|
|
|
|
Joined: Oct 2003
Posts: 313
Fjord artisan
|
Fjord artisan
Joined: Oct 2003
Posts: 313 |
$duration($ctime) is around that figure, so presumably you're not subtracting the correct value from it.
Sais
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Well, you had some problems with how you set it up.
on *:text:*:#mychan: {
if (!latest == $1) {
if (.add == $2) {
if ($nick isop #mychan) {
.write latest.txt $3- $ctime
}
}
else {
.play -a playlatest $nick latest.txt 1500
}
}
}
alias -l playlatest {
inc %latest.cnt
notice $1 %latest.cnt $+ $chr(41) $gettok($2-,1- $calc($gettok($2-,0,32) - 1),32) $duration($calc($ctime - $gettok($2-,0,32)))
if (%latest.cnt >= $lines(latest.txt)) { unset %latest.cnt }
}
That will work. You can change it back to msg if you want to. You *have* to leave it at $1 in the alias.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2006
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2006
Posts: 5 |
Well thanks again for the rewrite of my messed up code. I don't know what is going on here but I copied your code and ran it (yes I did unload the previous script and even rebooted the comp) but the output is exactly the same as before.
1) test1 1929wks 6days 3hrs 22mins 32secs 2) test2 1929wks 6days 3hrs 22mins 33secs 3) test3 1929wks 6days 3hrs 22mins 35secs 4) test4 1929wks 6days 3hrs 22mins 36secs
Again the enties were added at several min intervals, but again show as being only 1 or 2 secs apart and, as you can see, with the 1929wks etc also. Man I am confused
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Sorry. My fault. I forgot something. Here you are:
on *:text:*:#mychan: {
if (!latest == $1) {
if (.add == $2) {
if ($nick isop #mychan) {
.write latest.txt $3- $ctime
}
}
else {
.play -a playlatest $nick latest.txt 1500
}
}
}
alias -l playlatest {
inc %latest.cnt
notice $1 %latest.cnt $+ $chr(41) $gettok($2-,1- $calc($gettok($2-,0,32) - 1),32) $duration($calc($ctime - $gettok($2-,$gettok($2-,0,32),32)))
if (%latest.cnt >= $lines(latest.txt)) { unset %latest.cnt }
}
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2006
Posts: 5
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Dec 2006
Posts: 5 |
That works, no need to apologise, I am thankful for the time you have given to it Thank you again Riamus2
|
|
|
|
|