PtokaX forum

Archive => Archived 5.1 boards => Request for scripts => Topic started by: Xyxyxao on 27 November, 2006, 11:13:28

Title: Scriptc convert to new ptokax
Post by: Xyxyxao on 27 November, 2006, 11:13:28
I need to rewrite this script to work in new ptokax
it is a script used for tellig jokes from txt file
it says randoms jokes from the file



commands["vtip"] = function(user, arg)
   f = openfile("wmBot/modules/vtipy/vtipy.txt", "r")
   if f then
      count = 1
      line = read(f)
      while line do
         if strsub(line, 1, 1) == "~" then
            count = count + 1
         end
         line = read(f)
      end
      index = random(1, count)
      seek(f, "set", 0)
      i = 1
      cur = "     "
      line = read(f)
      while line do
         if strsub(line, 1, 1) == "~" then
            if i == index then
               break
            end
            i = i + 1
            cur = "     "
         else
            cur = cur.."\013\010     "..line
         end
         line = read(f)
      end
      closefile(f)
      chat(cur)
--      pm(user, cur)
   end
end

example of txt file :

Koncentrace
Vite, kde bylo nejvice alkoholiku?
Na Titaniku! Potopili lod, jen aby si lokli.
~
V pivu je vitaminu malo, proto ho musime pit hodne!
~


pleas, can someone help me ??
Title: Re: Scriptc convert to new ptokax
Post by: Xyxyxao on 01 December, 2006, 18:43:12
thanks for help, but i need to generate jokes from the file, i dont need to show them all.
random choice of jokes