Hi Men... :D
First; excuse my bad english... :))
Maybe YOU! can help?
I got this Error-Message in the Hub-Soft PTOKAX 0.326/TD4:
Syntax Error: attempt to index local `curUser' (a nil value)
I think, this is based by an Path-Prob within the Trivia-Script, i think...
So, what can i do to fix it?
The Script can?t save the scores automaticly?
The Score-File is stored in the Main-Game-Path:
C:\Hub\Scripts\Scores.dat
(The others are available there too...)
Manually- i can save!... ?(
Because of the limit: Here?s an cut... :P
(Sorry, translated to German Language, but you know about the real, i believe... ;)
******************************************
(the head)
-- TriviaBot Version 2.2
-- Changes by B@B?
-- Version 2.2
BotName = "Triviala"
ScriptVersion = "v2.2"
BotVersion = BotName.." "..ScriptVersion
strTrivScoreFile = "Scores.dat"
-- Diese Dat wird ben?tigt
strDefTrivFile = "Trivia.dat"
strQFile = "Questions.dat"
strTrivFile = strDefTrivFile
-- 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
-- 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 = "'"..StartTrigg.."' = Start, '"..StopTrigg.."' = Stopp, '"..JoinTrigg.."' = Teilnahme '"..PartTrigg.."' = Verlassen!"
strStart = "TriviaBot "..ScriptVersion.." gestartet! "..strBanner
strStopp = "TriviaBot "..ScriptVersion.." gestoppt! "..strBanner
(the middle)
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
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,"Punktest?nde gesichert")
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,"Punktest?nde geladen")
closefile(handle)
end
end
(the 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\nTop "..x.." Trivia Scores in diesem 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
******************************************
THX!!! 4 now... ;)
[D@]B@B?
So what???
Nobody knows?...
Am too lazy explaining what I did but it should be fixed:
-- TriviaBot Version 2.2
-- Changes by B@B?
-- Version 2.2
BotName = "Triviala"
ScriptVersion = "v2.2"
BotVersion = BotName.." "..ScriptVersion
strTrivScoreFile = "Scores.dat"
-- Diese Dat wird ben?tigt
strDefTrivFile = "Trivia.dat"
strQFile = "Questions.dat"
strTrivFile = strDefTrivFile
-- 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
-- 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 = "'"..StartTrigg.."' = Start, '"..StopTrigg.."' = Stopp, '"..JoinTrigg.."' = Teilnahme '"..PartTrigg.."' = Verlassen!"
strStart = "TriviaBot "..ScriptVersion.." gestartet! "..strBanner
strStopp = "TriviaBot "..ScriptVersion.." gestoppt! "..strBanner
(the middle)
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
end
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,"Punktest?nde gesichert")
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,"Punktest?nde geladen")
closefile(handle)
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[b] end
sort(index, func)
x = x or 10 if x > index.n then x = index.n end
local result = "\r\nTop "..x.." Trivia Scores in diesem 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[i]].."\t\t"..index[i] end
msg = result
SendToPlayers(msg)
end
you can check it with yours then you maybe see what was wrong...
Thank you very very much;
I saw, what you did...2 ends more in the
"function OnTimer () - area" but:
The same Message came again...
********************************************
I think it MUST! be an Prob with the Path for saving Scores.txt, but i can?t see- where?s the prob... ?(
strTrivScoreFile = "Scores.dat"
...means (i think so), that the file MUST saved in the scriptsfolder...whereever all the other scripts are laying too...so i did. And if i save the scores manually, it do so!
The Questions.dat and the Trivia.dat works fine, too.
Otherwise:
Only automaticly, after every 3rd turn- doesn?t...
boolAutoSaveScores = 1
countSaveTurns = 3
Seems, that the script can?t handle the command for saving the scores in scores.txt- but why? ?(
Maybe someone can tell me about this command:
strTrivFile = strDefTrivFile
I do not understand this one...?
Maye the Mistake is laying there?
I dispair about this damned Message!... ;(
Hey...Profs!
Must i buy... ?( an reply?
Nobody can help me fix it out??? (hohoho!)
Nice Gents... :rolleyes:
OK...anyway:
Thx @ NightLitch 4 attemping... ;)
Well, One Thing I learned Well Here is We should be able to control and be Patient :) Dunno How to Spell correct also dont care but i know u got me :)
another thing is i dont know how to fix these scripts i am slowly learning now...:)
it's also hard 2 fix a script witch isn't complete.
can you place it on webserver somewhere so we can download the whole thing??
with the error report you gave it can be anywhere in the script.
plop
Thx @ all !
This prob is settled since yesterday...
It was an Path-Prob! ;)