mIRC Home    About    Download    Register    News    Help

Print Thread
#172033 04/03/07 12:49 PM
Joined: Dec 2005
Posts: 22
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2005
Posts: 22
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.

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

Joined: Dec 2005
Posts: 22
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2005
Posts: 22
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

spirit_cro #172053 04/03/07 09:22 PM
Joined: Feb 2007
Posts: 75
T
Babel fish
Offline
Babel fish
T
Joined: Feb 2007
Posts: 75
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.

GigIRC Network Admin
irc.gigirc.com
Trixar_za #172082 05/03/07 04:57 AM
Joined: Oct 2005
Posts: 91
T
Babel fish
Offline
Babel fish
T
Joined: Oct 2005
Posts: 91
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)

truguce #172083 05/03/07 05:07 AM
Joined: Dec 2005
Posts: 22
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Dec 2005
Posts: 22
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.
spirit_cro #172096 05/03/07 02:19 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
}


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard