PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: QuikThinker on 03 July, 2004, 18:57:49

Title: Basic script with txt file
Post by: QuikThinker on 03 July, 2004, 18:57:49
Hey guys,  Just after a small script (I would imagine) that me & ma OPs can edit so users can display the OPs current fave tunes?

So when a user ran the command !faves 4 instance it would show all the OPs current 5 fave tunes. And another basic command 4 each OP 2 be able 2 just update his/her 5 faves as & when then wish.

Thanx in advance,
Quik.
Title:
Post by: QuikThinker on 04 July, 2004, 00:15:41
Come on guys this should be a walk in the park 4 u!  :D
Title:
Post by: Herodes on 04 July, 2004, 01:25:37
If I have this clear enough, u could use plop's texter (http://board.univ-angers.fr/thread.php?threadid=1576&boardid=12&styleid=1) ...
Title:
Post by: QuikThinker on 04 July, 2004, 02:09:45
I just tried texter2 & cannot get it 2 work no matter wat! I beg sum1 look at it please?? lol
All I need is the 1 command too, all the rest is surplus.

-- texter bot by plop
-- modified 2 show only 6 files,
-- thx 2 chilla for the faster routine for opening the files
-- shows text files from a folder named text.


Bot = "?PHH?"

FDFolder = "text"

cmd1 = "+faves"
file1 = "faves.txt"

cmd2 = "+ad"
file2 = "ad.txt"

cmd3 = "+help"
file3 = "help.txt"

cmd4 = "+masterhelp"
file4 = "masterhelp.txt"

cmd5 = "+viphelp"
file5 = "viphelp.txt"

cmd6 = "+hubinfo"
file6 = "hubinfo.txt"


function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   if( strsub(data, 1, 1) == "<" ) then
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if cmd == cmd2 then
         showtext(user, file2)
         return 1
      elseif cmd == cmd1 and user.iProfile ==1 then
         showtext(user, file1)
         return 1
      elseif cmd == cmd3 and (user.iProfile ==3 or user.iProfile ==-1) then
         showtext(user, file3)
         return 1
      elseif cmd == cmd4 and user.iProfile ==0 then
         showtext(user, file4)
         return 1
      elseif cmd == cmd5 and user.iProfile ==2 then
         showtext(user, file5)
         return 1
      elseif cmd == cmd6 and user.iProfile ==0 then
         showtextmain(user, file6)
         return 1
      end
   elseif(strsub(data, 1, 4) == "$To:") then
      s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+%S(%w+)")
      if cmd == cmd2 then
         showtext(user, file2)
         return 1
      elseif cmd == cmd1 and user.iProfile ==1 then
         showtext(user, file1)
         return 1
      elseif cmd == cmd3 and (user.iProfile ==3 or user.iProfile ==-1) then
         showtext(user, file3)
         return 1
      elseif cmd == cmd4 and user.iProfile ==0 then
         showtext(user, file4)
         return 1
      elseif cmd == cmd5 and user.iProfile ==2 then
         showtext(user, file5)
         return 1
      elseif cmd == cmd6 and user.iProfile ==0 then
         showtextmain(user, file6)
         return 1
      end
   end
end

function showtext(user, file)
local handle = openfile(FDFolder.."/"..file..".txt", "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
user:SendPM(Bot, "\r\n"..contents.."\r\n|")
end

function showtextmain(user, file)
local handle = openfile(FDFolder.."/"..file..".txt", "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
SendToAll(Bot, "\r\n"..contents.."\r\n|")
end
Title:
Post by: plop on 04 July, 2004, 05:00:08
a texter bot won't help here if i get it right.
you want a bot where ever op has a top5 of tunes.
my texter can only show files, not modify them.

plop
Title:
Post by: QuikThinker on 04 July, 2004, 13:36:06
Yea I decided that'll do tho coz I can get all the OPs 2 tell me their current top5 & I can edit the txt file maself. But I cant even get texter2 script 2 do that at the mo :s
Title:
Post by: plop on 04 July, 2004, 16:14:58
QuoteOriginally posted by QuikThinker
Yea I decided that'll do tho coz I can get all the OPs 2 tell me their current top5 & I can edit the txt file maself. But I cant even get texter2 script 2 do that at the mo :s
try version 4.x, that is a lot easyer 2 config.
just stuff all the txt files into the text folder, but remember that the filename is gone be the command.

plop
Title:
Post by: QuikThinker on 04 July, 2004, 17:31:17
OK so now i've tried texter 4.5 & STILL cant get it 2 fuckin work :@ It creates the levels file but dun do nuttin else.

I dun even need suttin this complicated just a simple fuckin script that displays sum info from a txt file in main chat when a user runs a command. Thats all! lol
Title:
Post by: plop on 04 July, 2004, 19:33:33
QuoteOriginally posted by QuikThinker
OK so now i've tried texter 4.5 & STILL cant get it 2 fuckin work :@ It creates the levels file but dun do nuttin else.

I dun even need suttin this complicated just a simple fuckin script that displays sum info from a txt file in main chat when a user runs a command. Thats all! lol
then you need version 1. lol
no !help or config on that, just a folder with files which every1 can view.

plop
Title:
Post by: QuikThinker on 04 July, 2004, 20:49:04
lol Plop that was all I needed, it does the trick perfectly! Thanx!

Quik.
Title:
Post by: QuikThinker on 05 July, 2004, 00:46:51
The script is perfect & does EXACTLY wat I want except now I got one more problem.....

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 24 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 24 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 24 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 24 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 24 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 24 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']
Title:
Post by: plop on 05 July, 2004, 01:31:53
a updated version is on my site.
should be fixed now.

plop
Title:
Post by: QuikThinker on 05 July, 2004, 14:09:20
Testin now fingers crossed! :D
Title:
Post by: QuikThinker on 05 July, 2004, 22:23:22
Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 18 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 18 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 18 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Syntax error: attempt to concat global `cmd' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 18 [file `C:\WINDOWS\DESKTOP\[PHH]\scripts\Texter.lua']

Nearly :(