mIRC Homepage
Posted By: spirit_cro help request - 04/03/07 12:49 PM
Hello sorry for disturbing everyone and making you read my post. No matter how hard i try read about mirc scripting it wont sink it. Im getting too old frown Im trying to make a script so i type a command and some text after the command and it stores it to a ini file in a sequence. for example:

!Add boy hit by a car: link to article here
!add girl hit by a car: link to article here

in the ini file it would store like this:

(1) boy hit by a car: link to article here
(2) girl hit by a car: link to article here

and then it keeps going as you add more. I just want it so people can type a command like !latestnews and it will post it to them. This is so difficult so im not expecting much help but anything would be appreciated. Thank you everyone.
Posted By: genius_at_work Re: help request - 04/03/07 05:25 PM
I think this is what you are looking for:

Code:
on *:TEXT:!addnews *:*:{
  var %limit = 8
  ;
  write news.txt $2-
  while ($lines(news.txt) > %limit) { write -dl1 news.txt }
  .notice $nick Added news item
}

on *:TEXT:!shownews:*:{
  .notice $nick News Headlines (oldest items first)
  .play -n $nick news.txt 500
}


Usage:
!addnews news item here
!shownews

To change the number of items that are maintained, change the limit number on line 2 (var %limit = 8).

-genius_at_work
Posted By: spirit_cro Re: help request - 04/03/07 09:05 PM
thanks very much, for me to understand is better can u just explain to me why its %limt = 8 and write -dl1 news.txt . Thanks very much
Posted By: Trixar_za Re: help request - 04/03/07 09:22 PM
Well, by the look of the code:

%limit=8 is how much news can be saved to the file, so the bigger the number, the more news items you can have in the file and will be shown to the user.

write -dl1 news.txt, writes to the the file news.txt and deletes the first line of (the very oldest) news when it gets new news added.
Posted By: truguce Re: help request - 05/03/07 04:57 AM
This line right here is saying, if the amount of lines in the news.txt file is greater than the variable %limit(in this case 8 lines) delete the first line of the file.

while ($lines(news.txt) > %limit)
Posted By: spirit_cro Re: help request - 05/03/07 05:07 AM
im trying to make it store in order by the newest post.

1. text here
2. text here

so when i !addnews text

that goes to 1.

when i do it again

1. goes to 2.
and the new one goes to 1.
my head hurts frown
Posted By: Riamus2 Re: help request - 05/03/07 02:19 PM
Using genius_at_work's code:

Code:
on *:TEXT:!addnews *:*:{
  var %limit = 8
  ;
  write -il1 news.txt $2-
  while ($lines(news.txt) > %limit) { write -dl $lines(news.txt) news.txt }
  .notice $nick Added news item
}

on *:TEXT:!shownews:*:{
  .notice $nick News Headlines (oldest items first)
  .play -n $nick news.txt 500
}
© mIRC Discussion Forums