PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: double_b_phantom on 27 June, 2005, 21:35:17

Title: Need Help Whit TriviaBot
Post by: double_b_phantom on 27 June, 2005, 21:35:17
first i say : sorry for my english . :)

ok!that's my problem:i make myself an Romanian(this is a language  :D  ) TriviaBot and i got this error on ptokax 3.3.0 build 17.05 :: Syntax [string "BotName = "[BOT]Trivia"..."]:642: unexpected symbol near `%'

and i don't know why ....

and now....i need help whit this :
----------------CODE-------------------
BotName = "[BOT]Trivia"
ScriptVersion = "v2.2"
BotVersion = BotName.." "..ScriptVersion

-- This file is not needed it will be created if it not exists
strTrivScoreFile = "TriviaScores.dat"

-- This file is needed unless you want to run a Trivia with only two questions ;)
strDefTrivFile = "triviaa.dat"
strTrivFile = strDefTrivFile
strQFile = "Questions.dat"

-- This char will be the global separator? (Make it one that is not used in nicknames nor questions ;)
strGSep = "*"

-- This char is used to mask the unrevealed chars
strCMask = "*"

-- Default startup mode of Trivia!
lngDefMode = 0 -- (0 = game is played in chat!, 1 = game is played in chat but questions only show for players, 2 = game is played in pm with players)
lngMode = lngDefMode

-- Max number of questions to show when a Operator ask to see list Questions 0 = 0, -1 = Disabled
lngMaxShowList = 50

-- Max no of Hints per word, and always hit on a hidden char
lngMaxHints = 5
boolHintAlwaysHitHidden = nil -- (nil = off, 1 = on)

-- How much time before a question end. Time in Trivia is measured in 15 seconds, 1 = 15 seconds, 2 = 30 seconds etc!
-- Rest is how long to rest after a question is solved depening on when the word is solved in the Timer loop it is ?10 secs to the setting!
lngMaxTime = 8 -- (Needs to be a multiple of 4   i.e. 4 / 8 / 12 / 16)
lngRestTime = 1
lngHintTime = lngMaxTime / 4

-- How often should the bot autosave the scores
boolAutoSaveScores = 1 -- (nil = off, 1 = on)
countSaveTurns = 1 -- After how many questions should the scores be saved

-- Should bot reveal the correct answer once time is up?
boolRevealAnswer = 1 -- (nil = off, 1 = on)

-- Should the bot display what guess made the word become a little clearer if played in PM!
boolShowGuessesInPM = 1 -- (nil = off, 1 = on)

-- Should the bot Auto Reveal Hints?
boolAutoHint = 1 -- (nil = off, 1 = on)

-- Should the bot auto login every user on connect ?
boolAutoLogin = 1 -- (nil = off, 1 = on)

-- Do you want users to be able to add questions ? Operators can always add questions.
boolAddQuestion = No -- (nil = No, 1 = Yes)

-- TriggStart is what char the commands should begin with I use ! but you can use # or whatever
TriggStart = ""

-- Theese are the different triggers I've tried to name them so that one easily understand what they do!
-- I include TriggStart and then the word within "" this word is not casesensitive!
JoinTrigg = TriggStart.."Joc"
PartTrigg = TriggStart.."Nujoc"
StartTrigg = TriggStart.."Start"
StopTrigg = TriggStart.."Stop"
WordTrigg = TriggStart.."Word"
QuizTrigg = TriggStart.."curent"
RestartTrigg = TriggStart.."Restart"
PointTrigg = TriggStart.."Puncte"
ScoreTrigg = TriggStart.."Scor"
PlayerTrigg = TriggStart.."Jucatori"
QuestionsTrigg = TriggStart.."Intrebari"
ReloadTrigg = TriggStart.."Reload"
HelpTrigg = TriggStart.."Help"
ExtraHelpTrigg = TriggStart.."Help+"
SaveTrigg = TriggStart.."Salveazascoru"
LoadTrigg = TriggStart.."Load"
ModeTrigg = TriggStart.."Mod"
HintTrigg = TriggStart.."Indiciu"
TopTrigg = TriggStart.."Top10"
AddTrigg = TriggStart.."Adauga"

bcount = 0
scount = 0
sQuestion = "intrebari"
sAnswer = ""
guessArray = {}
lngGuessmax = 0
playerArray = {}
pointArray = {}
lngWord = 0
lngPassed = 0
lngHinted = 0
strWord = ""
strQuestion = "intrebari"
strSolved = ""
strBanner = ""
strStart = "Trivia a fost pornita de catre un Operator!"..strBanner
strStopp = "Trivia a fost oprita de catre un Operator!"..strBanner

function Main()
  frmHub:RegBot(BotName)
  ReloadQuestions()
  setlocale("swe")
  LoadScores()
end

function NewUserConnected(curUser)
  if (boolAutoLogin) then
   if (not (playerArray[curUser.sName])) then
        playerArray[curUser.sName] = 1
  else
     playerArray[curUser.sName] = nil
  end
  end
  --topten(curUser)
end

function OpConnected(curUser)
  if (boolAutoLogin) then
   if (not (playerArray[curUser.sName])) then
        playerArray[curUser.sName] = 1
  else
     playerArray[curUser.sName] = nil
  end
  end
end

function UserDisconnected(curUser)
  playerArray[curUser.sName] = nil
end

function OpDisconnected(curUser)
  playerArray[curUser.sName] = nil
end

function DataArrival(curUser, data)
  local boolPlaydata = nil
  if (strsub(data, 1, 1) == "<") then
    data = strsub(data, 1, (strlen(data) - 1))
    if ((lngMode == 0) or (lngMode == 1)) then
      boolPlaydata = 1
    end
  elseif (strsub(data, 1, 4) == "$To:") then
    data = strsub(data, 1, (strlen(data) - 1))
    local _, _, whoTo = strfind(data,"$To:%s+(%S+)")
    if (whoTo == BotName) then
      data = strsub(data, (15 + strlen(BotName) + strlen(curUser.sName)))
      if (lngMode == 2) then
        boolPlaydata = 1
   local _, _, chat = strfind(data, "%b<>%s(.+)")
   SendChatToOthers(chat, curUser)
      end
    end
  end


  local _, _, firstWord = strfind(data, "%b<>%s+(%S+)")
 
  if (firstWord ~= nil) then
    if ((strlower(firstWord) == strlower(HelpTrigg)) or (strlower(firstWord) == strlower(ExtraHelpTrigg))) then
      showHelp(curUser)
    elseif (strlower(firstWord) == strlower(SaveTrigg)) then
      if (curUser.bOperator) then
        SaveScores(curUser)
      end
    elseif (strlower(firstWord) == strlower(LoadTrigg)) then
      if (curUser.bOperator) then
        LoadScores(curUser)
      end
    elseif (strlower(firstWord) == strlower(TopTrigg)) then
     TopTen(user)
    elseif (strlower(firstWord) == strlower(AddTrigg)) then
      if (boolAddQuestion) then
   s,e,sQuestion,sAnswer = strfind(data, "%b<>%s+%S+%s+(.+)#(.+)")   
     AddQuestion(curUser,sQuestion,sAnswer)
      elseif (curUser.bOperator) then
         s,e,sQuestion,sAnswer = strfind(data, "%b<>%s+%S+%s+(.+)#(.+)")   
     AddQuestion(curUser,sQuestion,sAnswer)
      else
     SendToPlayers("Questions cannot be added by users at this time")
      end
    elseif (strlower(firstWord) == strlower(ModeTrigg)) then
      if (curUser.bOperator) then
        local _, _, ModeDigit = strfind(data, "%b<>%s+%S+%s+(%d+)")
        if (ModeDigit ~= nil) then
          lngMode = tonumber(ModeDigit)
          if (lngMode == 0) then
            SendToPlayers("Game is played in chat")
          elseif (lngMode == 1) then
            SendToPlayers("Game is played in chat but Questions only show for players")
          elseif (lngMode == 2) then
            SendToPlayers("Game is played in PM with Players")
          else
            SendToPlayers("Errorous mode, mode set to default")
            lngMode = lngDefMode
          end
        end
      end
    elseif (strlower(firstWord) == strlower(JoinTrigg)) then
      if (not (playerArray[curUser.sName])) then
        playerArray[curUser.sName] = 1
        SendToPlayers(curUser.sName.." e jucator(e)!")
      else curUser:SendPM(BotName, "Deja ejti jucator(e)...")
      end
    elseif (strlower(firstWord) == strlower(PartTrigg)) then
      if (playerArray[curUser.sName]) then
        SendToPlayers(curUser.sName.." nu mai e jucator(e)!")
        playerArray[curUser.sName] = nil
      end
    elseif (strlower(firstWord) == strlower(RestartTrigg)) then
      if (curUser.bOperator) then
        SendToPlayers("TriviaBot restarted. All points etc are lost!")
        SendToPlayers("If Save is used now it will overwrite the old save!")
        pointArray = {}
        StopQuiz(1)
      end
    elseif ((strlower(firstWord) == strlower(PointTrigg)) and (playerArray[curUser.sName])) then
      if (pointArray[curUser.sName]) then
        SendToPlayers(curUser.sName.." ai "..pointArray[curUser.sName].." puncte!")
      else
        SendToPlayers(curUser.sName.." ai 0 puncte!")
      end
    elseif ((strlower(firstWord) == strlower(HintTrigg)) and (playerArray[curUser.sName])) then
      if ((lngWord ~= 0) and strfind(strSolved, strCMask, 1, plain)) then
        if (lngHinted < lngMaxHints) then
       for nn=1,bcount do
              local lngRepChar = random(1, strlen(strWord))
              while 1 do
                if (boolHintAlwaysHitHidden) then
                  if (strsub(strSolved, lngRepChar, lngRepChar) == strCMask) then
                    break
                  end
                else
                  break
                end
                lngRepChar = random(1, strlen(strWord))
              end
              local strTurn = ""
              for x=1, strlen(strWord) do
                if (x == lngRepChar) then
                 strTurn = strTurn..strsub(strWord, x, x)
                else
                  strTurn = strTurn..strsub(strSolved, x, x)
                end
         end
              strSolved = strTurn
     end
            lngHinted = lngHinted + 1
       lngHintTimeCount = lngHintTimeCount + lngHintTime

         

-Part 1-


That's all .... please ,need it fast !
Thanks a lot !
Title: part 2
Post by: double_b_phantom on 27 June, 2005, 21:37:47
SendToPlayers("Indiciu: "..strSolved)
       acount = ""
         else
            SendToPlayers("Toate indiciile au fost folosite pentru acest cuvant!")
       end
      else
        SendToPlayers("Nu e nevoie de indiciu!")
      end
    elseif ((strlower(firstWord) == strlower(ScoreTrigg)) and (playerArray[curUser.sName])) then
      curUser:SendPM(BotName, "SCORES:")
      curUser:SendPM(BotName, "---------------------------------------------------------")
      for index, value in pointArray do
        curUser:SendPM(BotName, index.."'s points: "..value)
      end
      curUser:SendPM(BotName, "---------------------------------------------------------")
    elseif ((strlower(firstWord) == strlower(PlayerTrigg)) and (playerArray[curUser.sName])) then
      curUser:SendPM(BotName, "PLAYERS:")
      curUser:SendPM(BotName, "---------------------------------------------------------")
      for index, value in playerArray do
        curUser:SendPM(BotName, index)
      end
      curUser:SendPM(BotName, "---------------------------------------------------------")
    elseif (strlower(firstWord) == strlower(QuestionsTrigg)) then
      if (curUser.bOperator) then
        curUser:SendPM(BotName, "TOP "..lngMaxShowList.." QUESTIONS:")
        curUser:SendPM(BotName, "---------------------------------------------------------")
        local lngShowMax = lngMaxShowList
        for index, value in guessArray do
          if (lngShowMax == 0) then
            break
          end
          arrTmp = tokenize(guessArray[index], strGSep)
          strTmp = arrTmp[1]
          curUser:SendPM(BotName, "["..index.."] "..strTmp)
          lngShowMax = lngShowMax - 1
        end
        curUser:SendPM(BotName, "Total # of questions: "..lngGuessmax)
        curUser:SendPM(BotName, "---------------------------------------------------------")
        curUser:SendPM(BotName, " ")
      end
    elseif (strlower(firstWord) == strlower(StartTrigg)) then
      if (curUser.bOperator) then
        if (lngWord == 0) then
          playerArray[curUser.sName] = 1
          SendToAll(BotName, strStart)
          if (lngMode == 2) then
            SendToPlayers(strStart)
          end
          StopQuiz(1)
        else
          SendToAll(BotName, "There is already a game going on type "..JoinTrigg.." to join!")
        end
      else
   curUser:SendPM(BotName, "Doar operatori pot sa porneasca sau sa opreasca Trivia.")
      end
    elseif (strlower(firstWord) == strlower(StopTrigg)) then
      if (curUser.bOperator) then
        HoldQuiz()
        StopQuiz()
        SendToAll(BotName, strStopp)
        if (lngMode == 2) then
          SendToPlayers(strStopp)
        end
      end
    elseif (strlower(firstWord) == strlower(WordTrigg)) then
      if ((lngWord ~= 0) and (playerArray[curUser.sName] == "Player")) then
        SendToPlayers("Current intrebarea e: "..strSolved.." ("..strlen(strSolved)..")")
      end
    elseif (strlower(firstWord) == strlower(QuizTrigg)) then
      if ((lngWord ~= 0) and (playerArray[curUser.sName])) then
        SendToPlayers("Intrebarea e: "..strQuestion)
      end
    elseif (strlower(firstWord) == strlower(ReloadTrigg)) then
      if (curUser.bOperator) then
        local _, _, secondWord = strfind(data, "%b<>%s+%S+%s+(%S+)")
        if (secondWord) then
        handle = openfile(secondWord, "r")
          if (handle) then
            closefile(handle)
            strTrivFile = secondWord
          end
        end
       
        HoldQuiz()
        ReloadQuestions()
      end
    else
   if ((lngWord ~= 0) and (boolPlaydata)) then
        if (playerArray[curUser.sName]) then
          local msg = strsub(data, (4 + strlen(curUser.sName)))
          if (strlen(msg) >= strlen(strWord)) then
            local boolDisc = nil
           
   local strTurn = ""
        if strlower(msg) == strlower(strWord) then
          strTurn = strWord
          boolDisc = 1
        else
          strTurn = strSolved
        end
 
           
            if (boolDisc) then
              strSolved = strTurn
            end
            if (boolDisc) then
              if (strlower(msg) ~= strlower(strWord)) then
                SendToOthers(curUser, msg)
                SendToPlayers("Raspunsul e: "..strSolved)
              end
            end
            if (strlower(msg) == strlower(strWord)) then
              if (not (pointArray[curUser.sName])) then
                pointArray[curUser.sName] = 0
              end
      if lngHinted == 3 then pointArray[curUser.sName] = pointArray[curUser.sName] + 1
      elseif lngHinted == 2 then pointArray[curUser.sName] = pointArray[curUser.sName] + 2
      elseif lngHinted == 1 then pointArray[curUser.sName] = pointArray[curUser.sName] + 3
      else pointArray[curUser.sName] = pointArray[curUser.sName] + 4
      end
              SendToPlayers("Raspunsul a fost: "..strSolved)
              SendToPlayers("Raspunsul a fost rezolvat de: "..curUser.sName)
              SendToPlayers("Urmatoarea intrebare in "..(lngRestTime * 15).." (?15) Secunde")
              lngPassed = lngMaxTime
              SendToPlayers(curUser.sName.."'s points: "..pointArray[curUser.sName])
              HoldQuiz()
            end
          end
        end
      end
    end
  end
end

function HoldQuiz()
  strWord = ""
  strQuestion = ""
  strSolved = ""
end

function StopQuiz(restart)
  lngWord = 0
  lngPassed = 0
  strWord = ""
  strQuestion = ""
  strSolved = ""
  StopTimer()
  if (restart) then
    StartQuiz()
  end
end

function StartQuiz()
  lngWord = random(1, lngGuessmax)
  QWarray = tokenize(guessArray[lngWord], strGSep)
  strQuestion = QWarray[1]
  strWord = QWarray[2]
  strSolved = ""
  for x=1, strlen(strWord) do
    if (strsub(strWord, x, x) == " ") then
      strSolved = strSolved.." "
    else
      strSolved = strSolved..strCMask
    end
  end
  lngPassed = 0
  lngHinted = 0
  lngHintTimeCount = lngHintTime
  if strlen(strWord) < 4 then
   bcount = random(1, 2)
  elseif strlen(strWord) >= 4 and strlen(strWord) <= 9 then
   bcount = random(1, 3)
  elseif strlen(strWord) >= 9 and strlen(strWord) <= 20 then
   bcount = random(2, 4)
  else
   bcount = random(3, 5)
  end
  SetTimer(15000)
  StartTimer()
  SendToPlayers("Intrebare: "..strQuestion)
  SendToPlayers("Raspuns: "..strSolved.." ("..strlen(strSolved)..")")
end
function OnTimer()
  lngPassed = lngPassed + 1
  if (lngPassed == lngMaxTime) then
    scount = scount + 1
    if scount == countSaveTurns then
      local handle = openfile(strTrivScoreFile, "w")
          for index, value in pointArray do
         write(handle,index..strGSep..value.."\r\n")
       end
         closefile(handle)
    scount = 0
    end
    if (boolRevealAnswer) then
      SendToPlayers("Raspunsul a fost '"..strWord.."' shi nu a fost rezolvat!")
    else
      SendToPlayers("Raspunsul nu a fost rezolvat!")
    end
    SendToPlayers("Urmatoarea intrebare in "..(lngRestTime * 15).." Secunde")
    HoldQuiz()
  elseif (lngPassed >= (lngRestTime + lngMaxTime)) then
    StopQuiz(1)
  elseif (lngPassed == lngHintTimeCount) then
    if (boolAutoHint) then
   for nn=1,bcount do
            local lngRepChar = random(1, strlen(strWord))
            while 1 do
              if (boolHintAlwaysHitHidden) then
                if (strsub(strSolved, lngRepChar, lngRepChar) == strCMask) then
                  break
                end
              else
                break
              end
              lngRepChar = random(1, strlen(strWord))
            end
            local strTurn = ""
            for x=1, strlen(strWord) do
              if (x == lngRepChar) then
               strTurn = strTurn..strsub(strWord, x, x)
              else
                strTurn = strTurn..strsub(strSolved, x, x)
              end
       end
            strSolved = strTurn
   end
            lngHinted = lngHinted + 1
       lngHintTimeCount = lngHintTimeCount + lngHintTime
            SendToPlayers("Indiciu: "..strSolved)
   end  
  end
end

function tokenize (inString,token)
  _WORDS = {}
  local matcher = "([^"..token.."]+)"
  gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
  return _WORDS
end

function ReloadQuestions()
  guessArray = {}
  lngGuessmax = 0
  local boolRestart = nil
  if (lngWord ~= 0) then
    SendToPlayers("Reloading questions, game will be shut down!")
    StopQuiz()
    boolRestart = 1
  end
  handle = openfile(strTrivFile, "r")
  if (handle) then
    local line = read(handle)
   
    while line do
      if ((line ~= "") and (strfind(line, strGSep, 1, plain))) then
        tinsert(guessArray, line)
        lngGuessmax = lngGuessmax + 1
      end
      line = read(handle)
    end
  closefile(handle)
  end
  if (lngGuessmax < 1) then
  guessArray = {
    "The finest car there is?"..strGSep.."Honda CRX del Sol",
    "Who brought you this TriviaBot"..strGSep.."Leon a.k.a. Don Leon"
  }
  lngGuessmax = 2
  end
  if (boolRestart) then
    SendToPlayers("Reloaded questions, game will be restarted! Current # of questions: "..lngGuessmax)
    StartQuiz()
  end
  strTrivFile = strDefTrivFile
end

function SaveScores(curUser)
  local handle = openfile(strTrivScoreFile, "w")
  for index, value in pointArray do
    write(handle,index..strGSep..value.."\r\n")
  end
  curUser:SendData(BotName,"Scores saved")
  closefile(handle)
end

function LoadScores(curUser)
  local handle = openfile(strTrivScoreFile, "r")
  if (handle) then
    local line = read(handle)
    while line do
      local arrTmp = tokenize(line, strGSep)
      if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then
        pointArray[arrTmp[1]] = tonumber(arrTmp[2])
      end
      line = read(handle)
    end
  curUser:SendData(BotName,"Scores Loaded")
  closefile(handle)
  end
end

function AddQuestion(curUser, sQuestion, sAnswer)
  local handle = openfile(strQFile, "a")
  write(handle,"Submitted by <"..curUser.sName.."> "..sQuestion..strGSep..sAnswer.."\r\n")
  SendToPlayers(curUser.sName.." a adaugat intrebarea "..sQuestion)
  curUser:SendPM(BotName,curUser.sName.." intrebarea ta a fost acceptata .. iar raspunsul este: "..sAnswer)
  closefile(handle)
end

function SendToPlayers(msg)
  if ((lngMode > 2) or (lngMode < 0)) then
    lngMode = lngDefMode
  end
 
  if (lngMode == 0) then
    SendToAll(BotName, msg)
  elseif (lngMode == 1) then
    for index, value in playerArray do
      SendToNick(index, "<"..BotName.."> "..msg)
    end
  elseif (lngMode == 2) then
    for index, value in playerArray do
      SendPmToNick(index, BotName, msg)
    end
  end
end

function SendToOthers(msg, curUser)
  if ((lngMode == 2) and (boolShowGuessesInPM)) then
    for index, value in playerArray do
      if (index ~= curUser.sName) then
        SendPmToNick(index, BotName, "<"..curUser.sName.."> "..msg)
      end
    end
  end
end

function SendChatToOthers(chat, curUser)
  if (lngMode == 2) then
    for index, value in playerArray do
      if (index ~= curUser.sName) then
   SendToNick(index, "$To: "..index.." From: "..BotName.." $<"..curUser.sName.."> "..chat)
      end
    end
  end
end
Title: part 3
Post by: double_b_phantom on 27 June, 2005, 21:38:44
function showHelp(curUser)
  curUser:SendData(" ")
  curUser:SendData(" "..BotVersion.." Comenzi:")
  curUser:SendData(" ")
  if (lngMode == 0) then
    curUser:SendData("    Trivia e setata sa fie jucata in Chat <>")
  elseif (lngMode == 1) then
    curUser:SendData("    "..BotVersion.." is set to be played in chat (hidden)")
  else
    curUser:SendData("    "..BotVersion.." is set to be played in PM")
  end
  curUser:SendData("    "..HelpTrigg.." - Iti arata toate comenzile")
  curUser:SendData("    "..JoinTrigg.." - Intri in joc")
  curUser:SendData("    "..PartTrigg.." - iesi din joc")
  curUser:SendData("    "..WordTrigg.." - Iti arata prima litera (raspuns)")
  curUser:SendData("    "..QuizTrigg.." - Iti arata intrebarea curenta")
  curUser:SendData("    "..PointTrigg.." - Iti arata punctele tale")
  curUser:SendData("    "..ScoreTrigg.." - Arata scorul")
  curUser:SendData("    "..PlayerTrigg.." - Iti arata toti jucatorii")
  curUser:SendData("    "..HintTrigg.." - Iti da un indiciu de raspuns")
  curUser:SendData("    "..TopTrigg.." - Arata topul clor mai buni jucatori ")
  curUser:SendData("    "..AddTrigg.." - Adaugi o intrebare pt. Trivia. La raspuns trebuie sa pui in fata #")
  curUser:SendData("    EXEMPLU : adauga Cat de repede zboara o pasare?#Nu stiu")
  if (curUser.bOperator) then
    curUser:SendData(" ")
    curUser:SendData("    "..BotVersion.." Comenzi pentru Operatori:")
    curUser:SendData("    "..StopTrigg.." - Opreste botu de Trivia")
    curUser:SendData("    "..RestartTrigg.." - Reseteaza botul si scorurile!")
    curUser:SendData("    "..QuestionsTrigg.." - Arata top intrebari (50)")
    curUser:SendData("    "..ReloadTrigg.." () - Incarca intrebrile din "..strDefTrivFile)
    curUser:SendData("    "..ModeTrigg.." - Pentru a schimba modu de joc (0-2)!")
    curUser:SendData("    "..SaveTrigg.." - Salveaza scoru in "..strTrivScoreFile)
    curUser:SendData("    "..LoadTrigg.." - Pune scorul din "..strTrivScoreFile)
    curUser:SendData("    "..StartTrigg.." -  Daca dai start la Trivia automat esti jucator(operatori)")
    curUser:SendData(" ")
    curUser:SendData("    "..BotVersion.." Moduri:")
    curUser:SendData("    ".."0 = Jocul se joaca in Chat!")
    curUser:SendData("    ".."1 = Jocul se joaca in Chat dar intrebarile se vad doar de JUCATORI")
    curUser:SendData("    ".."2 = Jocul se joaca in PM cu jucatori")
    end                                  
end

function TopTen(user)
   local index = {n=0}
   foreach(pointArray, function(nick, score) tinsert(%index, nick) end)
   local func = function(a, b) return %pointArray[a] > %pointArray end
   sort(index, func)

   x = x or 10
   if x > index.n then x = index.n end
   local result = "\r\n\r\nTop "..x.." Trivia scores in this hub..\r\n Pos\t Score\t\t Nick\t\r\n"
   for i = 1, x do result = result.."\r\n "..i..".\t"..pointArray[index].."\t\t"..index end
   msg = result
   SendToPlayers(msg)
end






------------------------------------END-----------------

Need help ....sorry for this big length
Title: try this part 1
Post by: ?Tr??T_???? on 15 July, 2005, 15:34:35
-- Converted to Lua5 By Jelf 15/03/05

BotName = "Trivia"
ScriptVersion = "v2.2"
BotVersion = BotName.." "..ScriptVersion

-- This file is not needed it will be created if it not exists
strTrivScoreFile = "TriviaScores.dat"

-- This file is needed unless you want to run a Trivia with only two questions ;)
strDefTrivFile = "trivia.dat"
strTrivFile = strDefTrivFile
strQFile = "Questions.dat"

-- This char will be the global separator? (Make it one that is not used in nicknames nor questions ;)
strGSep = "*"

-- This char is used to mask the unrevealed chars
strCMask = "@"

-- Default startup mode of Trivia!
lngDefMode = 1 -- (0 = game is played in chat!, 1 = game is played in chat but questions only show for players, 2 = game is played in pm with players)
lngMode = lngDefMode

-- Max number of questions to show when a Operator ask to see list Questions 0 = 0, -1 = Disabled
lngMaxShowList = 5

-- Max no of Hints per word, and always hit on a hidden char
lngMaxHints = 4
boolHintAlwaysHitHidden = nil -- (nil = off, 1 = on)

-- How much time before a question end. Time in Trivia is measured in 15 seconds, 1 = 15 seconds, 2 = 30 seconds etc!
-- Rest is how long to rest after a question is solved depening on when the word is solved in the Timer loop it is ?15 secs to the setting!
lngMaxTime = 8 -- (Needs to be a multiple of 4   i.e. 4 / 8 / 12 / 16)
lngRestTime = 2
lngHintTime = lngMaxTime / 4

-- How often should the bot autosave the scores
boolAutoSaveScores = 1 -- (nil = off, 1 = on)
countSaveTurns = 3 -- After how many questions should the scores be saved

-- Should bot reveal the correct answer once time is up?
boolRevealAnswer = 1 -- (nil = off, 1 = on)

-- Should the bot display what guess made the word become a little clearer if played in PM!
boolShowGuessesInPM = 1 -- (nil = off, 1 = on)

-- Should the bot Auto Reveal Hints?
boolAutoHint = 1 -- (nil = off, 1 = on)

-- Should the bot auto login every user on connect ?
boolAutoLogin = nil -- (nil = off, 1 = on)

-- Do you want users to be able to add questions ? Operators can always add questions.
boolAddQuestion = 1 -- (nil = No, 1 = Yes)

-- TriggStart is what char the commands should begin with I use ! but you can use # or whatever
TriggStart = ""

-- Theese are the different triggers I've tried to name them so that one easily understand what they do!
-- I include TriggStart and then the word within "" this word is not casesensitive!
JoinTrigg = TriggStart.."tbjoin"
PartTrigg = TriggStart.."tbpart"
StartTrigg = TriggStart.."tbstart"
StopTrigg = TriggStart.."tbstop"
WordTrigg = TriggStart.."tbword"
QuizTrigg = TriggStart.."tbquestion"
RestartTrigg = TriggStart.."tbrestart"
PointTrigg = TriggStart.."tbpoints"
ScoreTrigg = TriggStart.."tbscores"
PlayerTrigg = TriggStart.."tbplayers"
QuestionsTrigg = TriggStart.."tbquestions"
ReloadTrigg = TriggStart.."tbreload"
HelpTrigg = TriggStart.."tbhelp"
ExtraHelpTrigg = TriggStart.."tbhelp+"
SaveTrigg = TriggStart.."tbsavescores"
LoadTrigg = TriggStart.."tbloadscores"
ModeTrigg = TriggStart.."tbmode"
HintTrigg = TriggStart.."tbhintme"
TopTrigg = TriggStart.."tbtopten"
AddTrigg = TriggStart.."tbaddquestion"

bcount = 0
scount = 0
sQuestion = ""
sAnswer = ""
guessArray = {}
lngGuessmax = 0
playerArray = {}
pointArray = {}
lngWord = 0
lngPassed = 0
lngHinted = 0
strWord = ""
strQuestion = ""
strSolved = ""
strBanner = "Type '"..StartTrigg.."' to start Trivia, '"..StopTrigg.."' to stop Trivia, type '"..JoinTrigg.."' to Join and '"..PartTrigg.."' to Part!"
strStart = "TriviaBot "..ScriptVersion.." started! "..strBanner
strStopp = "TriviaBot "..ScriptVersion.." stopped! "..strBanner
----------------------
function Main()
   frmHub:RegBot(BotName)
   ReloadQuestions()
end
------------------------
function NewUserConnected(curUser)
   if (boolAutoLogin) then
      if (not (playerArray[curUser.sName])) then
         playerArray[curUser.sName] = 1
      else
         playerArray[curUser.sName] = nil
      end
   end
end
------------------------------
function OpConnected(curUser)
   if (boolAutoLogin) then
      if (not (playerArray[curUser.sName])) then
         playerArray[curUser.sName] = 1
      else
         playerArray[curUser.sName] = nil
      end
   end
end
--------------------------------
function UserDisconnected(curUser)
   playerArray[curUser.sName] = nil
end
--------------------------------
function OpDisconnected(curUser)
   playerArray[curUser.sName] = nil
end
-------------------------------
function ToArrival(curUser, data)
   ChatArrival(curUser, data)
end
-------------------------------
Title: part 2
Post by: ?Tr??T_???? on 15 July, 2005, 15:35:10
function ChatArrival(curUser, data)
  local boolPlaydata = nil
  if (string.sub(data, 1, 1) == "<") then
    data = string.sub(data, 1, (string.len(data) - 1))
    if ((lngMode == 0) or (lngMode == 1)) then
      boolPlaydata = 1
    end
  elseif (string.sub(data, 1, 4) == "$To:") then
    data = string.sub(data, 1, (string.len(data) - 1))
    local _, _, whoTo = string.find(data,"$To:%s+(%S+)")
    if (whoTo == BotName) then
      data = string.sub(data, (15 + string.len(BotName) + string.len(curUser.sName)))
      if (lngMode == 2) then
        boolPlaydata = 1
   local _, _, chat = string.find(data, "%b<>%s(.+)")
   SendChatToOthers(chat, curUser)
      end
    end
  end


  local _, _, firstWord = string.find(data, "%b<>%s+(%S+)")
 
  if (firstWord ~= nil) then
    if ((string.lower(firstWord) == string.lower(HelpTrigg)) or (string.lower(firstWord) == string.lower(ExtraHelpTrigg))) then
      showHelp(curUser)
    elseif (string.lower(firstWord) == string.lower(SaveTrigg)) then
      if (curUser.bOperator) then
        SaveScores(curUser)
      end
    elseif (string.lower(firstWord) == string.lower(LoadTrigg)) then
      if (curUser.bOperator) then
        LoadScores(curUser)
      end
    elseif (string.lower(firstWord) == string.lower(TopTrigg)) then
     TopTen(user)
    elseif (string.lower(firstWord) == string.lower(AddTrigg)) then
      if (boolAddQuestion) then
   s,e,sQuestion,sAnswer = string.find(data, "%b<>%s+%S+%s+(.+)#(.+)")   
     AddQuestion(curUser,sQuestion,sAnswer)
      elseif (curUser.bOperator) then
         s,e,sQuestion,sAnswer = string.find(data, "%b<>%s+%S+%s+(.+)#(.+)")   
     AddQuestion(curUser,sQuestion,sAnswer)
      else
     SendToPlayers("Questions cannot be added by users at this time")
      end
    elseif (string.lower(firstWord) == string.lower(ModeTrigg)) then
      if (curUser.bOperator) then
        local _, _, ModeDigit = string.find(data, "%b<>%s+%S+%s+(%d+)")
        if (ModeDigit ~= nil) then
          lngMode = tonumber(ModeDigit)
          if (lngMode == 0) then
            SendToPlayers("Game is played in chat")
          elseif (lngMode == 1) then
            SendToPlayers("Game is played in chat but Questions only show for players")
          elseif (lngMode == 2) then
            SendToPlayers("Game is played in PM with Players")
          else
            SendToPlayers("Errorous mode, mode set to default")
            lngMode = lngDefMode
          end
        end
      end
    elseif (string.lower(firstWord) == string.lower(JoinTrigg)) then
      if (not (playerArray[curUser.sName])) then
        playerArray[curUser.sName] = 1
        SendToPlayers(curUser.sName.." is now a player!")
      else curUser:SendPM(BotName, "You are already a player and you didn't know. Possibly because you were autologged in")
      end
    elseif (string.lower(firstWord) == string.lower(PartTrigg)) then
      if (playerArray[curUser.sName]) then
        SendToPlayers(curUser.sName.." is no longer a player!")
        playerArray[curUser.sName] = nil
      end
    elseif (string.lower(firstWord) == string.lower(RestartTrigg)) then
      if (curUser.bOperator) then
        SendToPlayers("TriviaBot restarted. All points etc are lost!")
        SendToPlayers("If Save is used now it will overwrite the old save!")
        pointArray = {}
        StopQuiz(1)
      end
    elseif ((string.lower(firstWord) == string.lower(PointTrigg)) and (playerArray[curUser.sName])) then
      if (pointArray[curUser.sName]) then
        SendToPlayers(curUser.sName.." you have "..pointArray[curUser.sName].." points!")
      else
        SendToPlayers(curUser.sName.." you have 0 points!")
      end
    elseif ((string.lower(firstWord) == string.lower(HintTrigg)) and (playerArray[curUser.sName])) then
      if ((lngWord ~= 0) and string.find(strSolved, strCMask, 1, plain)) then
        if (lngHinted < lngMaxHints) then
       for nn=1,bcount do
              local lngRepChar = math.random(1, string.len(strWord))
              while 1 do
                if (boolHintAlwaysHitHidden) then
                  if (string.sub(strSolved, lngRepChar, lngRepChar) == strCMask) then
                    break
                  end
                else
                  break
                end
                lngRepChar = math.random(1, string.len(strWord))
              end
              local strTurn = ""
              for x=1, string.len(strWord) do
                if (x == lngRepChar) then
                 strTurn = strTurn..string.sub(strWord, x, x)
                else
                  strTurn = strTurn..string.sub(strSolved, x, x)
                end
         end
              strSolved = strTurn
     end
            lngHinted = lngHinted + 1
       lngHintTimeCount = lngHintTimeCount + lngHintTime
            SendToPlayers("Hint: "..strSolved)
       acount = ""
         else
            SendToPlayers("All hints used for this word!")
       end
      else
        SendToPlayers("No hint needed!")
      end
    elseif ((string.lower(firstWord) == string.lower(ScoreTrigg)) and (playerArray[curUser.sName])) then
      curUser:SendPM(BotName, "SCORES:")
      curUser:SendPM(BotName, "---------------------------------------------------------")
      for index, value in pointArray do
        curUser:SendPM(BotName, index.."'s points: "..value)
      end
      curUser:SendPM(BotName, "---------------------------------------------------------")
    elseif ((string.lower(firstWord) == string.lower(PlayerTrigg)) and (playerArray[curUser.sName])) then
      curUser:SendPM(BotName, "PLAYERS:")
      curUser:SendPM(BotName, "---------------------------------------------------------")
      for index, value in playerArray do
        curUser:SendPM(BotName, index)
      end
      curUser:SendPM(BotName, "---------------------------------------------------------")
    elseif (string.lower(firstWord) == string.lower(QuestionsTrigg)) then
      if (curUser.bOperator) then
        curUser:SendPM(BotName, "TOP "..lngMaxShowList.." QUESTIONS:")
        curUser:SendPM(BotName, "---------------------------------------------------------")
        local lngShowMax = lngMaxShowList
        for index, value in guessArray do
          if (lngShowMax == 0) then
            break
          end
          arrTmp = tokenize(guessArray[index], strGSep)
          strTmp = arrTmp[1]
          curUser:SendPM(BotName, "["..index.."] "..strTmp)
          lngShowMax = lngShowMax - 1
        end
        curUser:SendPM(BotName, "Total # of questions: "..lngGuessmax)
        curUser:SendPM(BotName, "---------------------------------------------------------")
        curUser:SendPM(BotName, " ")
      end
    elseif (string.lower(firstWord) == string.lower(StartTrigg)) then
      if (curUser.bOperator) then
        if (lngWord == 0) then
          playerArray[curUser.sName] = 1
          SendToAll(BotName, strStart)
          if (lngMode == 2) then
            SendToPlayers(strStart)
          end
          StopQuiz(1)
        else
          SendToAll(BotName, "There is already a game going on type "..JoinTrigg.." to join!")
        end
      else
   curUser:SendPM(BotName, "Only Operators can start the Trivia because it might be off for a reason.")
      end
    elseif (string.lower(firstWord) == string.lower(StopTrigg)) then
      if (curUser.bOperator) then
        HoldQuiz()
        StopQuiz()
        SendToAll(BotName, strStopp)
        if (lngMode == 2) then
          SendToPlayers(strStopp)
        end
      end
    elseif (string.lower(firstWord) == string.lower(WordTrigg)) then
      if ((lngWord ~= 0) and (playerArray[curUser.sName] == "Player")) then
        SendToPlayers("Current question is: "..strSolved.." ("..string.len(strSolved)..")")
      end
    elseif (string.lower(firstWord) == string.lower(QuizTrigg)) then
      if ((lngWord ~= 0) and (playerArray[curUser.sName])) then
        SendToPlayers("Question is: "..strQuestion)
      end
    elseif (string.lower(firstWord) == string.lower(ReloadTrigg)) then
      if (curUser.bOperator) then
        local _, _, secondWord = string.find(data, "%b<>%s+%S+%s+(%S+)")
        if (secondWord) then
        handle = io.open(secondWord, "r")
          if (handle) then
            handle:close()
            strTrivFile = secondWord
          end
        end
       
        HoldQuiz()
        ReloadQuestions()
      end
    else
   if ((lngWord ~= 0) and (boolPlaydata)) then
        if (playerArray[curUser.sName]) then
          local msg = string.sub(data, (4 + string.len(curUser.sName)))
          if (string.len(msg) >= string.len(strWord)) then
            local boolDisc = nil
           
   local strTurn = ""
        if string.lower(msg) == string.lower(strWord) then
          strTurn = strWord
          boolDisc = 1
        else
          strTurn = strSolved
        end
 
           
            if (boolDisc) then
              strSolved = strTurn
            end
            if (boolDisc) then
              if (string.lower(msg) ~= string.lower(strWord)) then
                SendToOthers(curUser, msg)
                SendToPlayers("Answer is now: "..strSolved)
              end
            end
            if (string.lower(msg) == string.lower(strWord)) then
              if (not (pointArray[curUser.sName])) then
                pointArray[curUser.sName] = 0
              end
      if lngHinted == 3 then pointArray[curUser.sName] = pointArray[curUser.sName] + 1
      elseif lngHinted == 2 then pointArray[curUser.sName] = pointArray[curUser.sName] + 2
      elseif lngHinted == 1 then pointArray[curUser.sName] = pointArray[curUser.sName] + 3
      else pointArray[curUser.sName] = pointArray[curUser.sName] + 4
      end
              SendToPlayers("Answer was: "..strSolved)
              SendToPlayers("Answer was solved by: "..curUser.sName)
              SendToPlayers("Next question in "..(lngRestTime * 15).." (?15) Secs")
              lngPassed = lngMaxTime
              SendToPlayers(curUser.sName.."'s points: "..pointArray[curUser.sName])
              HoldQuiz()
            end
          end
        end
      end
    end
  end
end
--------------------------------
function HoldQuiz()
  strWord = ""
  strQuestion = ""
  strSolved = ""
end

function StopQuiz(restart)
  lngWord = 0
  lngPassed = 0
  strWord = ""
  strQuestion = ""
  strSolved = ""
  StopTimer()
  if (restart) then
    StartQuiz()
  end
end

function StartQuiz()
  lngWord = math.random(1, lngGuessmax)
  QWarray = tokenize(guessArray[lngWord], strGSep)
  strQuestion = QWarray[1]
  strWord = QWarray[2]
  strSolved = ""
  for x=1, string.len(strWord) do
    if (string.sub(strWord, x, x) == " ") then
      strSolved = strSolved.." "
    else
      strSolved = strSolved..strCMask
    end
  end
  lngPassed = 0
  lngHinted = 0
  lngHintTimeCount = lngHintTime
  if string.len(strWord) < 4 then
   bcount = math.random(1, 2)
  elseif string.len(strWord) >= 4 and string.len(strWord) <= 9 then
   bcount = math.random(1, 3)
  elseif string.len(strWord) >= 9 and string.len(strWord) <= 20 then
   bcount = math.random(2, 4)
  else
   bcount = math.random(3, 5)
  end
  SetTimer(15000)
  StartTimer()
  SendToPlayers("Question: "..strQuestion)
  SendToPlayers("Answer: "..strSolved.." ("..string.len(strSolved)..")")
end
-----------------------------------------
Title: part 3
Post by: ?Tr??T_???? on 15 July, 2005, 15:35:43
function OnTimer()

  lngPassed = lngPassed + 1

  if (lngPassed == lngMaxTime) then

    scount = scount + 1

    if scount == countSaveTurns then

   local handle = io.open(strTrivScoreFile, "w+")
    for index, value in pointArray do

      handle:write(index..strGSep..value.."\r\n")

    end

      handle:close()

    scount = 0

    end
    if (boolRevealAnswer) then
      SendToPlayers("Answer was '"..strWord.."' and was not solved!")
    else
      SendToPlayers("Answer was not solved!")
    end
    SendToPlayers("Next question in "..(lngRestTime * 15).." Secs")
    HoldQuiz()
  elseif (lngPassed >= (lngRestTime + lngMaxTime)) then
    StopQuiz(1)
  elseif (lngPassed == lngHintTimeCount) then
    if (boolAutoHint) then
   for nn=1,bcount do
            local lngRepChar = math.random(1, string.len(strWord))
            while 1 do
              if (boolHintAlwaysHitHidden) then
                if (string.sub(strSolved, lngRepChar, lngRepChar) == strCMask) then
                  break
                end
              else
                break
              end
              lngRepChar = math.random(1, string.len(strWord))
            end
            local strTurn = ""
            for x=1, string.len(strWord) do
              if (x == lngRepChar) then
               strTurn = strTurn..string.sub(strWord, x, x)
              else
                strTurn = strTurn..string.sub(strSolved, x, x)
              end
       end
            strSolved = strTurn
   end
            lngHinted = lngHinted + 1
       lngHintTimeCount = lngHintTimeCount + lngHintTime
            SendToPlayers("Hint: "..strSolved)
   end  
  end
end
---------------------------------------
function tokenize (inString,token)
  _WORDS = {}
  local matcher = "([^"..token.."]+)"
  string.gsub(inString, matcher, function (w) table.insert(_WORDS,w) end)
  return _WORDS
end
----------------------------------------
function ReloadQuestions()
  guessArray = {}
  lngGuessmax = 0
  local boolRestart = nil
  if (lngWord ~= 0) then
    SendToPlayers("Reloading questions, game will be shut down!")
    StopQuiz()
    boolRestart = 1
  end
  handle = io.open(strTrivFile, "r")
  if (handle) then
    local line = handle:read()
   
    while line do
      if ((line ~= "") and (string.find(line, strGSep, 1, plain))) then
        table.insert(guessArray, line)
        lngGuessmax = lngGuessmax + 1
      end
      line = handle:read()
    end
  handle:close()
  end
  if (lngGuessmax < 1) then
  guessArray = {
    "The finest car there is?"..strGSep.."Honda CRX del Sol",
    "Who brought you this TriviaBot"..strGSep.."Leon a.k.a. Don Leon"
  }
  lngGuessmax = 2
  end
  if (boolRestart) then
    SendToPlayers("Reloaded questions, game will be restarted! Current # of questions: "..lngGuessmax)
    StartQuiz()
  end
  strTrivFile = strDefTrivFile
end
----------------------------------------
function SaveScores(curUser)

   local handle = io.open(strTrivScoreFile, "w")

      for index, value in pointArray do

         handle:write(index..strGSep..value.."\r\n")

      end

      if curUser then

         curUser:SendData(BotName,"Punktest?nde gesichert!")

      end

      handle:close()

end



function LoadScores(curUser)

local handle = io.open(strTrivScoreFile)

   if (handle) then

      for line in io.lines(strTrivScoreFile) do

         local arrTmp = tokenize(line, strGSep)

         if ((arrTmp[1] ~= nil) and (arrTmp[2] ~= nil)) then

            pointArray[arrTmp[1]] = tonumber(arrTmp[2])

         end

          io.read()

      end

      if curUser then

         curUser:SendData(BotName,"Punktest?nde geladen...")

      end

      io.close()

   end

end
---------------------------------------------------
function OnExit()

      SaveScores()

end
---------------------------------------------------
function AddQuestion(curUser, sQuestion, sAnswer)
  local handle = io.open(strQFile, "a")
  handle:write("Submitted by <"..curUser.sName.."> "..sQuestion..strGSep..sAnswer.."\r\n")
  SendToPlayers(curUser.sName.." Has added the question "..sQuestion)
  curUser:SendPM(BotName,curUser.sName.." you gave the answer as "..sAnswer)
  handle:close()
end
--------------------------------------------
function SendToPlayers(msg)
  if ((lngMode > 2) or (lngMode < 0)) then
    lngMode = lngDefMode
  end
 
  if (lngMode == 0) then
    SendToAll(BotName, msg)
  elseif (lngMode == 1) then
    for index, value in playerArray do
      SendToNick(index, "<"..BotName.."> "..msg)
    end
  elseif (lngMode == 2) then
    for index, value in playerArray do
      SendPmToNick(index, BotName, msg)
    end
  end
end
---------------------------------------------
function SendToOthers(msg, curUser)
  if ((lngMode == 2) and (boolShowGuessesInPM)) then
    for index, value in playerArray do
      if (index ~= curUser.sName) then
        SendPmToNick(index, BotName, "<"..curUser.sName.."> "..msg)
      end
    end
  end
end
-----------------------------------------------
function SendChatToOthers(chat, curUser)
  if (lngMode == 2) then
    for index, value in playerArray do
      if (index ~= curUser.sName) then
   SendToNick(index, "$To: "..index.." From: "..BotName.." $<"..curUser.sName.."> "..chat)
      end
    end
  end
end
--------------------------------------------
function showHelp(curUser)
  curUser:SendData(" ")
  curUser:SendData(" "..BotVersion.." commands:")
  curUser:SendData(" ")
  if (lngMode == 0) then
    curUser:SendData("    "..BotVersion.." is set to be played in chat")
  elseif (lngMode == 1) then
    curUser:SendData("    "..BotVersion.." is set to be played in chat (hidden)")
  else
    curUser:SendData("    "..BotVersion.." is set to be played in PM")
  end
  curUser:SendData("    "..HelpTrigg.." - Displays this help")
  curUser:SendData("    "..JoinTrigg.." - Joins you to Trivia")
  curUser:SendData("    "..PartTrigg.." - Parts you from Trivia")
  curUser:SendData("    "..WordTrigg.." - Shows current word (answer)")
  curUser:SendData("    "..QuizTrigg.." - Shows current question")
  curUser:SendData("    "..PointTrigg.." - Shows your points only")
  curUser:SendData("    "..ScoreTrigg.." - Shows everyones score")
  curUser:SendData("    "..PlayerTrigg.." - Shows all players in current game")
  curUser:SendData("    "..HintTrigg.." - Reveals a char in current word")
  curUser:SendData("    "..TopTrigg.." - Shows top ten scores")
  curUser:SendData("    "..AddTrigg.." - Adds a question to the Trivia Questions File. Type the question, then separate the answer with a #")
  curUser:SendData("    EXAMPLE : tbquestion How fast does a bird fly?#Dont know")
  if (curUser.bOperator) then
    curUser:SendData(" ")
    curUser:SendData("    "..BotVersion.." Operator commands:")
    curUser:SendData("    "..StopTrigg.." - Stops the TriviaBot")
    curUser:SendData("    "..RestartTrigg.." - Restarts the bot, reseting all scores!")
    curUser:SendData("    "..QuestionsTrigg.." - Shows all questions in current game")
    curUser:SendData("    "..ReloadTrigg.." () - Reloads questions from "..strDefTrivFile)
    curUser:SendData("    "..ModeTrigg.." - To change mode of the game (0-2)!")
    curUser:SendData("    "..SaveTrigg.." - Saves scores into "..strTrivScoreFile)
    curUser:SendData("    "..LoadTrigg.." - Loads scores from "..strTrivScoreFile)
    curUser:SendData("    "..StartTrigg.." - Starts the TriviaBot and automatically adds you as a player")
    curUser:SendData(" ")
    curUser:SendData("    "..BotVersion.." Modes:")
    curUser:SendData("    ".."0 = Game is played in chat!")
    curUser:SendData("    ".."1 = Game is played in chat but Questions only show for players")
    curUser:SendData("    ".."2 = Game is played in PM with Players")
  end
end
----------------------------------------------
function TopTen(user)
   local index = {n=0}
   table.foreach(pointArray, function(nick, score) table.insert(index, nick) end)
   local func = function(a, b) return pointArray[a] > pointArray end
   table.sort(index, func)

   x = x or 10 if x > index.n then x = index.n end
   local result = "\r\nTop "..x.." Trivia scores in this hub..\r\n Pos\t Score\t\t Nick\t\r\n"
   for i = 1, x do result = result.."\r\n "..i..".\t"..pointArray[index].."\t\t"..index end
   msg = result
   SendToPlayers(msg)
end
Title: one prob only
Post by: ?Tr??T_???? on 15 July, 2005, 15:38:50
the only prob is that u must save the scores manually and it only can be started by an op but u can try this http://board.univ-angers.fr/thread.php?threadid=4545&boardid=29&sid=aa76c9320fd34af65cbb35c152feb5c2

Regards