HELP! - Syntax-Error
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

HELP! - Syntax-Error

Started by B@B?, 06 January, 2004, 14:42:13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

B@B?

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?
THE DAY AFTER...  

...is >>>>>>>> NOW!




Btw:
Plz excuse my english...
It?s not the best, i?m sure...but it?s funny...isn?t it?

B@B?

#1
So what???

Nobody knows?...
THE DAY AFTER...  

...is >>>>>>>> NOW!




Btw:
Plz excuse my english...
It?s not the best, i?m sure...but it?s funny...isn?t it?

NightLitch

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...
//NL

B@B?

#3
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!... ;(
THE DAY AFTER...  

...is >>>>>>>> NOW!




Btw:
Plz excuse my english...
It?s not the best, i?m sure...but it?s funny...isn?t it?

B@B?

#4
Hey...Profs!

Must i buy... ?(  an reply?

Nobody can help me fix it out???  (hohoho!)

Nice Gents... :rolleyes:

OK...anyway:

Thx @ NightLitch 4 attemping... ;)
THE DAY AFTER...  

...is >>>>>>>> NOW!




Btw:
Plz excuse my english...
It?s not the best, i?m sure...but it?s funny...isn?t it?

Intel

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...:)
Punnakku

plop

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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

B@B?

#7
Thx @ all !

This prob is settled since yesterday...

It was an Path-Prob!  ;)
THE DAY AFTER...  

...is >>>>>>>> NOW!




Btw:
Plz excuse my english...
It?s not the best, i?m sure...but it?s funny...isn?t it?

SMF spam blocked by CleanTalk