Hello, got a request here, need a script that can search inside a txt file and show the hits on what it found in pm.
The txt file will look like this:
http://www.gamespot.com/AVP.htm Alien Versus Predator
http://www.gamespot.com/Beatles.htm Beatles, action
http://www.gamespot.com/victory.htm Victory challenge
something like that it will look like inside the text file.
Then the script can handle like: !search Alien
And a pm pops up with this:
http://www.gamespot.com/AVP.htm Alien Versus Predator
Found 1 match.
I thought there was a script for lua4 before, because i requested it before. But cant find it anywhere.
So i hope someone can make this script for me.
Got 404 errors, but if you post a textfile for real, it is easy to make. :)
here is a text file:
http://dcmods.mine.nu/games.txt
anyone?
function Search(curUser,aFile,aString)
local f,e = io.open(aFile,"games.txt")
local message = "\r\n---===Search Results===---\r\n"
while 1 do
local line = f:read("*l")
if line == nil then break
elseif string.find(line,aString) then
message = message..line.."\r\n"
end
end
f:close(f)
curUser.SendData("SearchBot",message)
return 1
end
thats what i got so far.
can anyone help me make it complete?
for line in f:lines() do
if string.find(line,"wanna look 4 this",1,true) then
-- found
end
that didnt make so much sence to me :))
i hope someone can make it complete with a command too.
like +search ****
and pops up some search hits.