mIRC Home    About    Download    Register    News    Help

Print Thread
#172033 04/03/07 12:49 PM
S
spirit_cro
spirit_cro
S
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.

#172043 04/03/07 05:25 PM
Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
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

S
spirit_cro
spirit_cro
S
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

#172053 04/03/07 09:22 PM
T
Trixar_za
Trixar_za
T
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.

Last edited by Trixar_za; 04/03/07 09:24 PM.
#172082 05/03/07 04:57 AM
T
truguce
truguce
T
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)

#172083 05/03/07 05:07 AM
S
spirit_cro
spirit_cro
S
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

Last edited by spirit_cro; 05/03/07 05:26 AM.
#172096 05/03/07 02:19 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
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
}


Link Copied to Clipboard