mIRC Homepage
Posted By: icybergie On Text Sending Random Files In A Folder - 20/07/04 09:13 AM
How do i write a on text script whereby on text i will send a random file in a specific folder?
Posted By: Venoman Re: On Text Sending Random Files In A Folder - 20/07/04 10:30 AM
Code:
on *:text:[color:red]texthere[/color]:[color:red]#[/color]: {
  var %num = $rand(1,[color:red]20[/color])
  var %file = $+(",$findfile("[color:red]c:\path\to\folder\[/color]",*.*,%num),")
  dcc send $nick %file
}


You need to replace the parts in red:
for texthere, replace that with the key word you want to respond to.
for #, right now it means it responds to the texthere text in any channel window. You can change it to ? for PM windows, or #blah for a specific channel, et cetera. See /help on text for more info.
20 should be the total number of files you have in the folder, and c:\path\to\folder\ should point to the actual folder you're using. I haven't tested this, but no reason it shouldn't work.

-Venoman
Thank you.
there seems to be a problem..

* /dcc: insufficient parameters (line 4, script3.ini)

variable %file is not set automatically
Posted By: Venoman Re: On Text Sending Random Files In A Folder - 20/07/04 12:30 PM
you'll get that error sometimes if you replaced the number 20 with a number higher than the total # of files in the folder. Also make sure you specify the whole path to the folder correctly.

-Venoman

  • on *:text:texthere:#: {
    var %num = $rand(1,$findfile([color:red]c:\path\to\folder,*.*,0)[/color])
    var %file = $+(",$findfile(c:\path\to\folder\,*.*,%num),")
    dcc send $nick %file
    }


Change the parts in red.
Posted By: Venoman Re: On Text Sending Random Files In A Folder - 20/07/04 05:51 PM
ah, knew there was a way to list the total # of files in a folder, just couldn't think of it smile

-Venoman
i still get the invalid parameters, this is how it looks after i have changed everything.

Code:
 on *:text:@[JP]Rina-Uchiyama:#abcd:{ 
  var %num = $rand(1,$findfile(C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama,*.*,0)) 
  var %file = $+(",$findfile(C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama,*.*,%num),") 
  dcc send $nick %file
}  
Not exactly, sure why your getting invalid parameters.. try adding some checks:

On *:text:@trigger*:[color:red]#Channel
:{
var %dir = [color:red]C:\directory here\

if (!$isdir(%dir)) { echo -a ERROR: Folder doesnt exist. }
else {
var %num = $rand(1,$findfile(%dir,*.*,0))
var %file = $+(",$findfile(%dir,*.*,%num),")
if (!$isfile(%file)) { echo -a ERROR: File doesnt exist. }
else { dcc send $nick %file }
}
}
[/color]

Eamonn.
File doesnt exist. =\
Werid, try typing it from a command line:

//echo -> $findfile(C:\DIR\,*,$rand(1,$findfile(C:\DIR\,*,0)))

Replacing, C:\DIR\

Eamonn.
echo results.

-> C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama\032.jpg
upz
Posted By: Iori Re: On Text Sending Random Files In A Folder - 22/07/04 09:20 AM
Problem may be that the file (or a dir in the path) has two consecutive spaces.
they are all picture files. none of them has any spaces =\~

As for the folder, there are only 1 space
Posted By: Venoman Re: On Text Sending Random Files In A Folder - 25/07/04 04:51 PM
no no no. always ALWAYS enclose paths to files and folders in quotes. I suppose I should have done that in my example, so that's my fault. your path has spaces, which won't actually return the full path when put to use, unless you put it in quotes.

Code:
on *:text:@[JP]Rina-Uchiyama:#abcd:{ 
  var %num = $rand(1,$findfile("C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama",*.*,0)) 
  var %file = $+(",$findfile("C:\Documents and Settings\FaBiAn\My Documents\My Pictures\Rina Uchiyama",*.*,%num),") 
  dcc send $nick %file
}


there ya go.

-Venoman
© mIRC Discussion Forums