Trivia-Ex-V.0.68 for Lua 5 - Page 2
 

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

Trivia-Ex-V.0.68 for Lua 5

Started by Jelf, 13 March, 2005, 12:07:25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

night_hawk

hi can you change the Trivia Ex v0.65 to lua 5...users in my hub love that verion better cause the new one droped some featchers that they liked please let me know thank you.....

jiten

QuoteOriginally posted by night_hawk
hi can you change the Trivia Ex v0.65 to lua 5...users in my hub love that verion better cause the new one droped some featchers that they liked please let me know thank you.....

Can u post the script somewhere or host it so that I can convert it?

night_hawk

all can can do is send it throw msn, yahoo, icq or aol...if you have one of them leave me your addy i will add you and send it to you that way...it is to large to poast...thank you

jiten

QuoteOriginally posted by night_hawk
all can can do is send it throw msn, yahoo, icq or aol...if you have one of them leave me your addy i will add you and send it to you that way...it is to large to poast...thank you

I got the file from plop's site and I've already converted it to Lua 5.
Grab it here.
Btw, i didn't test it much so it may have some bugs.

Cheers  ;)

PS: That only the .lua file.  U got to have the .txt files.

jiten

#29
QuoteOriginally posted by Lage
Hi. I used to run Trivia Ex v0.65 in my old Ptokax hub, but I'm setting up a new one now with Ptokax 0.3.3.0 build 16.06 so I thought I'd run this script instead.

Now for some reason the trivia tells me the answer is correct before the line where the person actually enters the correct answer is shown. Why is this, and how can it be modified? The way it is now, the trivia bot seems psychic. =)

Try replacing all the "function TrivEx:ParseData(mode,curUser,data)" with this:
function TrivEx:ParseData(mode,curUser,data)

	self._datamode = mode
	data = string.sub(data,1,string.len(data)-1)
	local _,_,sdata = string.find( data, "^%b<>%s(.*)$")
	local _,_,cmd = string.find( data, "^%b<>%s["..self._Sets.prefixes.."](%w+)")
	if cmd then
		cmd = string.lower(cmd)
		if self._Cmds[cmd] then
			self._Cmds[cmd](self,curUser,data)
			return 1
		end
	elseif sdata then
		local corrans = table.foreachi(curTriv.ans, function(_,v)
			if string.lower(sdata) == string.lower(v) then
				return (v)
			end
		end)
		if corrans and (not curTriv:GetGetQues()) then
			-- SetGetQues
			curTriv:SetGetQues(1)
			local ansTime = string.format("%.2f",(os.clock()-curTriv.start)) -- Get Answering Time in sec.
			if (TrivEx._Sets.showcorrectanswer == 1) then
				-- Show right answer
				local talked = nil
				if string.find( sdata, corrans ) then
					talked = corrans
				end
				if talked then
					if not (self:GetPlayMode() == "pm") then
						SendToAll(curUser.sName,corrans)
					end
					self:SendToPlayers("Correct "..curUser.sName.." the answer was \""..corrans.."\", You get "..curTriv.points.." Point(s). Answer solved in "..ansTime.." sec.")
					-- Show other answeres if present
					if curTriv.availans > 1 then
						curTriv:ShowAnswer()
					end
					-- Update Scores
					if self._Scores[curUser.sName] then
						self._Scores[curUser.sName].Score = self._Scores[curUser.sName].Score + curTriv.points
						self._Scores[curUser.sName].AvTime[1] = self._Scores[curUser.sName].AvTime[1] + ansTime
						self._Scores[curUser.sName].AvTime[2] = self._Scores[curUser.sName].AvTime[2] + 1
						self._Scores[curUser.sName].AvTime[3] = tonumber(string.format("%.2f",self._Scores[curUser.sName].AvTime[1]/self._Scores[curUser.sName].AvTime[2]))
					else
						self._Scores[curUser.sName] = {}
						self._Scores[curUser.sName].Score = curTriv.points
						self._Scores[curUser.sName].Streak = 1
						self._Scores[curUser.sName].AvTime = { tonumber(ansTime),1,tonumber(ansTime) }
					end
					if (self._Sets.showcorrectanswer == 1) then
						self:SendToPlayers(curUser.sName.."'s Stats, Score: "..self._Scores[curUser.sName].Score.." Point(s), Answerd Questions: "..self._Scores[curUser.sName].AvTime[2]..", Average Answering Time: "..string.format("%.2f",self._Scores[curUser.sName].AvTime[3]).." sec.")
					end
					-- Check for Streak
					curTriv.streak:UpdStreak(curUser)

					return 1
				end
			elseif (TrivEx._Sets.showcorrectanswer == 2) then
				-- Show right answer
				local talked = nil
				if string.find( sdata, corrans ) then
					talked = corrans
				end
				if talked then
					if not (self:GetPlayMode() == "pm") then
						SendToAll(curUser.sName,corrans)
					end
					self:SendToPlayers("Correct "..curUser.sName.." the answer was \""..corrans.."\", You get "..curTriv.points.." Point(s).")
					-- Show other answeres if present
					if curTriv.availans > 1 then
						curTriv:ShowAnswer()
					end
					-- Update Scores
					if self._Scores[curUser.sName] then
						self._Scores[curUser.sName].Score = self._Scores[curUser.sName].Score + curTriv.points
						self._Scores[curUser.sName].AvTime[1] = self._Scores[curUser.sName].AvTime[1] + ansTime
						self._Scores[curUser.sName].AvTime[2] = self._Scores[curUser.sName].AvTime[2] + 1
						self._Scores[curUser.sName].AvTime[3] = tonumber(string.format("%.2f",self._Scores[curUser.sName].AvTime[1]/self._Scores[curUser.sName].AvTime[2]))
					else
						self._Scores[curUser.sName] = {}
						self._Scores[curUser.sName].Score = curTriv.points
						self._Scores[curUser.sName].Streak = 1
						self._Scores[curUser.sName].AvTime = { tonumber(ansTime),1,tonumber(ansTime) }
					end
					if (self._Sets.showcorrectanswer == 1) then
						self:SendToPlayers(curUser.sName.."'s Stats, Score: "..self._Scores[curUser.sName].Score.." Point(s), Answerd Questions: "..self._Scores[curUser.sName].AvTime[2]..", Average Answering Time: "..string.format("%.2f",self._Scores[curUser.sName].AvTime[3]).." sec.")
					end
					-- Check for Streak
					curTriv.streak:UpdStreak(curUser)
					return 1
				end
			end

		elseif (self:GetPlayMode() == "pm") then

			self:SendToPlayers(data,curUser)
		end

	end

end

*EDIT* Fixed small bugs
*EDIT* Fixed sending answer to Main when playing in PM
Best regards,

jiten

jiten

#30
QuoteOriginally posted by Falstaff
QuoteOriginally posted by Jelf
I know a few people wanted this so here ya go...
Trivia-Ex V.0.68 Lua 5

is there any way of adding the possibility of showing the accumulative score when a user answers the question i.e

correct (user) the answer was (answer) you get 9 points your score so far is 490

this would be a help

Try replacing all the "function TrivEx:ParseData(mode,curUser,data)" with this:
function TrivEx:ParseData(mode,curUser,data)

	self._datamode = mode
	data = string.sub(data,1,string.len(data)-1)
	local _,_,sdata = string.find( data, "^%b<>%s(.*)$")
	local _,_,cmd = string.find( data, "^%b<>%s["..self._Sets.prefixes.."](%w+)")
	if cmd then
		cmd = string.lower(cmd)
		if self._Cmds[cmd] then
			self._Cmds[cmd](self,curUser,data)
			return 1
		end
	elseif sdata then
		local corrans = table.foreachi(curTriv.ans, function(_,v)
			if string.lower(sdata) == string.lower(v) then
				return (v)
			end
		end)
		if corrans and (not curTriv:GetGetQues()) then
			-- SetGetQues
			curTriv:SetGetQues(1)
			local ansTime = string.format("%.2f",(os.clock()-curTriv.start)) -- Get Answering Time in sec.
			if (TrivEx._Sets.showcorrectanswer == 1) then
				-- Show right answer
				local talked = nil
				if string.find( sdata, corrans ) then
					talked = corrans
				end
				if talked then
					local TCopy = {}
					table.foreach(self._Scores, function(i,v) table.insert(TCopy, {i,v}) end)
					table.sort(TCopy,function(a,b) return(a[2].Score>b[2].Score) end)
					for i = 1,TrivEx._Sets.displscorers do
						if TCopy[i] then
							if not (self:GetPlayMode() == "pm") then
								SendToAll(curUser.sName,corrans)
							end
							self:SendToPlayers("Correct "..curUser.sName.." the answer was \""..corrans.."\", You get "..curTriv.points.." Point(s). Your score so far is: "..TCopy[i][2].Score..". Answer solved in "..ansTime.." sec.")
							-- Show other answeres if present
							if curTriv.availans > 1 then
								curTriv:ShowAnswer()
							end
							-- Update Scores
							if self._Scores[curUser.sName] then
								self._Scores[curUser.sName].Score = self._Scores[curUser.sName].Score + curTriv.points
								self._Scores[curUser.sName].AvTime[1] = self._Scores[curUser.sName].AvTime[1] + ansTime
								self._Scores[curUser.sName].AvTime[2] = self._Scores[curUser.sName].AvTime[2] + 1
								self._Scores[curUser.sName].AvTime[3] = tonumber(string.format("%.2f",self._Scores[curUser.sName].AvTime[1]/self._Scores[curUser.sName].AvTime[2]))
							else
								self._Scores[curUser.sName] = {}
								self._Scores[curUser.sName].Score = curTriv.points
								self._Scores[curUser.sName].Streak = 1
								self._Scores[curUser.sName].AvTime = { tonumber(ansTime),1,tonumber(ansTime) }
							end
							if (self._Sets.showcorrectanswer == 1) then
								self:SendToPlayers(curUser.sName.."'s Stats, Score: "..self._Scores[curUser.sName].Score.." Point(s), Answerd Questions: "..self._Scores[curUser.sName].AvTime[2]..", Average Answering Time: "..string.format("%.2f",self._Scores[curUser.sName].AvTime[3]).." sec.")
							end
							-- Check for Streak
							curTriv.streak:UpdStreak(curUser)

							return 1
						end
					end
				end
			elseif (TrivEx._Sets.showcorrectanswer == 2) then
				-- Show right answer
				local talked = nil
				if string.find( sdata, corrans ) then
					talked = corrans
				end
				if talked then
					local TCopy = {}
					table.foreach(self._Scores, function(i,v) table.insert(TCopy, {i,v}) end)
					table.sort(TCopy,function(a,b) return(a[2].Score>b[2].Score) end)
					for i = 1,TrivEx._Sets.displscorers do
						if TCopy[i] then
							if not (self:GetPlayMode() == "pm") then
								SendToAll(curUser.sName,corrans)
							end
							self:SendToPlayers("Correct "..curUser.sName.." the answer was \""..corrans.."\", You get "..curTriv.points.." Point(s). Your score so far is: "..TCopy[i][2].Score..".")
							-- Show other answeres if present
							if curTriv.availans > 1 then
								curTriv:ShowAnswer()
							end
							-- Update Scores
							if self._Scores[curUser.sName] then
								self._Scores[curUser.sName].Score = self._Scores[curUser.sName].Score + curTriv.points
								self._Scores[curUser.sName].AvTime[1] = self._Scores[curUser.sName].AvTime[1] + ansTime
								self._Scores[curUser.sName].AvTime[2] = self._Scores[curUser.sName].AvTime[2] + 1
								self._Scores[curUser.sName].AvTime[3] = tonumber(string.format("%.2f",self._Scores[curUser.sName].AvTime[1]/self._Scores[curUser.sName].AvTime[2]))
							else
								self._Scores[curUser.sName] = {}
								self._Scores[curUser.sName].Score = curTriv.points
								self._Scores[curUser.sName].Streak = 1
								self._Scores[curUser.sName].AvTime = { tonumber(ansTime),1,tonumber(ansTime) }
							end
							if (self._Sets.showcorrectanswer == 1) then
								self:SendToPlayers(curUser.sName.."'s Stats, Score: "..self._Scores[curUser.sName].Score.." Point(s), Answerd Questions: "..self._Scores[curUser.sName].AvTime[2]..", Average Answering Time: "..string.format("%.2f",self._Scores[curUser.sName].AvTime[3]).." sec.")
							end
							-- Check for Streak
							curTriv.streak:UpdStreak(curUser)
							return 1
						end
					end
				end
			end

		elseif (self:GetPlayMode() == "pm") then

			self:SendToPlayers(data,curUser)
		end

	end

end
*EDIT* Fixed some bugs
*EDIT* Fixed sending answer to main when playing in PM
Cheers

Jelf

Wow, you've been busy jiten, as always :)

Nice job

jiten


night_hawk

i am so lost with this Trivia-Ex-V.0.68 for Lua 5  

this is what it does to me all the time

<-RasTriv-> Correct [HFF?]Night_Hawk the answer was "the thing", You get 3 Point(s). Your score so far is: 4. Answer solved in 78.52 sec.


[00:30] <-RasTriv-> Correct [HFF?]Night_Hawk the answer was "ostrich", You get 4 Point(s). Your score so far is: 4. Answer solved in 49.12 sec.

keeps saying the same scores

and my profiles do not work here is what i use...

i run robcop10c

profiles are  


-
-
  Master
  11111111111111001100111111111111
 

-
  Operator
  11110100011001001100110111111001
 

-
  VIP
  10000000000001001000000000000000
 

-
  Reg
  10000000000000000000000000000000
 

-
  Moderator
  11110110011101001100110111111111
 

-
  NetFounder
  11111111111111001100111111111111
 

 


please help me out thank you...

jiten

#34
QuoteOriginally posted by night_hawk
i am so lost with this Trivia-Ex-V.0.68 for Lua 5  

Replace your "function TrivEx:ParseData(mode,curUser,data)" with this:
function TrivEx:ParseData(mode,curUser,data)

	self._datamode = mode
	data = string.sub(data,1,string.len(data)-1)
	local _,_,sdata = string.find( data, "^%b<>%s(.*)$")
	local _,_,cmd = string.find( data, "^%b<>%s["..self._Sets.prefixes.."](%w+)")
	if cmd then
		cmd = string.lower(cmd)
		if self._Cmds[cmd] then
			self._Cmds[cmd](self,curUser,data)
			return 1
		end
	elseif sdata then
		local corrans = table.foreachi(curTriv.ans, function(_,v)
			if string.lower(sdata) == string.lower(v) then
				return (v)
			end
		end)
		if corrans and (not curTriv:GetGetQues()) then
			-- SetGetQues
			curTriv:SetGetQues(1)
			local ansTime = string.format("%.2f",(os.clock()-curTriv.start)) -- Get Answering Time in sec.
			if (TrivEx._Sets.showcorrectanswer == 1) then
				-- Show right answer
				local talked = nil
				if string.find( sdata, corrans ) then
					talked = corrans
				end
				if talked then
					if not (self:GetPlayMode() == "pm") then
						SendToAll(curUser.sName,corrans)
					end
					self:SendToPlayers("Correct "..curUser.sName.." the answer was \""..corrans.."\", You get "..curTriv.points.." Point(s). Answer solved in "..ansTime.." sec.")
					-- Show other answeres if present
					if curTriv.availans > 1 then
						curTriv:ShowAnswer()
					end
					-- Update Scores
					if self._Scores[curUser.sName] then
						self._Scores[curUser.sName].Score = self._Scores[curUser.sName].Score + curTriv.points
						self._Scores[curUser.sName].AvTime[1] = self._Scores[curUser.sName].AvTime[1] + ansTime
						self._Scores[curUser.sName].AvTime[2] = self._Scores[curUser.sName].AvTime[2] + 1
						self._Scores[curUser.sName].AvTime[3] = tonumber(string.format("%.2f",self._Scores[curUser.sName].AvTime[1]/self._Scores[curUser.sName].AvTime[2]))
					else
						self._Scores[curUser.sName] = {}
						self._Scores[curUser.sName].Score = curTriv.points
						self._Scores[curUser.sName].Streak = 1
						self._Scores[curUser.sName].AvTime = { tonumber(ansTime),1,tonumber(ansTime) }
					end
					if (self._Sets.showcorrectanswer == 1) then
						self:SendToPlayers(curUser.sName.."'s Stats, Score: "..self._Scores[curUser.sName].Score.." Point(s), Answerd Questions: "..self._Scores[curUser.sName].AvTime[2]..", Average Answering Time: "..string.format("%.2f",self._Scores[curUser.sName].AvTime[3]).." sec.")
					end
					-- Check for Streak
					curTriv.streak:UpdStreak(curUser)
					return 1
				end
			elseif (TrivEx._Sets.showcorrectanswer == 2) then
				-- Show right answer
				local talked = nil
				if string.find( sdata, corrans ) then
					talked = corrans
				end
				if talked then
					if not (self:GetPlayMode() == "pm") then
						SendToAll(curUser.sName,corrans)
					end
					self:SendToPlayers("Correct "..curUser.sName.." the answer was \""..corrans.."\", You get "..curTriv.points.." Point(s).")
					-- Show other answeres if present
					if curTriv.availans > 1 then
						curTriv:ShowAnswer()
					end
					-- Update Scores
					if self._Scores[curUser.sName] then
						self._Scores[curUser.sName].Score = self._Scores[curUser.sName].Score + curTriv.points
						self._Scores[curUser.sName].AvTime[1] = self._Scores[curUser.sName].AvTime[1] + ansTime
						self._Scores[curUser.sName].AvTime[2] = self._Scores[curUser.sName].AvTime[2] + 1
						self._Scores[curUser.sName].AvTime[3] = tonumber(string.format("%.2f",self._Scores[curUser.sName].AvTime[1]/self._Scores[curUser.sName].AvTime[2]))
					else
						self._Scores[curUser.sName] = {}
						self._Scores[curUser.sName].Score = curTriv.points
						self._Scores[curUser.sName].Streak = 1
						self._Scores[curUser.sName].AvTime = { tonumber(ansTime),1,tonumber(ansTime) }
					end
					if (self._Sets.showcorrectanswer == 1) then
						self:SendToPlayers(curUser.sName.."'s Stats, Score: "..self._Scores[curUser.sName].Score.." Point(s), Answerd Questions: "..self._Scores[curUser.sName].AvTime[2]..", Average Answering Time: "..string.format("%.2f",self._Scores[curUser.sName].AvTime[3]).." sec.")
					end
					-- Check for Streak
					curTriv.streak:UpdStreak(curUser)
					return 1
				end
			end

		elseif (self:GetPlayMode() == "pm") then
			self:SendToPlayers(data,curUser)
		end

	end

end

*EDIT* Fixed SendDataPlayer bug
*EDIT* Fixed sending answer on main when playing in PM
Cheers

night_hawk

getting this

Syntax ... things\nights hub\scripts\Trivia-Ex-V.0.68.lua5.lua:355: attempt to call global `SendDataPlayers'


that is why it is not adding up the scores


and i tryed that last one to and it would show nothing

jiten

QuoteOriginally posted by night_hawk
getting this

Syntax ... things\nights hub\scripts\Trivia-Ex-V.0.68.lua5.lua:355: attempt to call global `SendDataPlayers'


that is why it is not adding up the scores


and i tryed that last one to and it would show nothing

Try now. Guess it's ok now.
I've updated the previous post.

Cheers

night_hawk

Syntax ... things\nights hub\scripts\Trivia-Ex-V.0.68.lua5.lua:37: attempt to call method `NewUserConnected' (a nil value)

jiten

QuoteOriginally posted by night_hawk
Syntax ... things\nights hub\scripts\Trivia-Ex-V.0.68.lua5.lua:37: attempt to call method `NewUserConnected' (a nil value)

Can u tell me when does this error happens?
I've tested the script a bit, and didn't get any.

night_hawk

happens when a user logs into the hub...everytime....and i want it to still play in the main chat ...

jiten

QuoteOriginally posted by night_hawk
happens when a user logs into the hub...everytime....and i want it to still play in the main chat ...

Wierd. That error doesn't happen to me.
Can u post ur NewUserConnected function?

night_hawk

function NewUserConnected(curUser)
   TrivEx:NewUserConnected(curUser)

end

OpConnected = NewUserConnected

-----------------------

function UserDisconnected(curUser)
   TrivEx:UserDisconnected(curUser)

end

OpDisconnected = UserDisconnected
--------------------
function OnTimer()
   TrivEx:OnTimer()
end

jiten

This is the one I'm using (without the errors u're reporting).

Best regards.

James

Hey guy`s!

      Is it possible to change the Trivia-Ex bot on this way, that when anybody knows 10 question without any help that he/she get the "Gag - Rule"? That mean he/she can only answer`s when 30min had past.
      There ary to many poeple which knew`s the question by heart and other poeple can't play in quiz.

         Thanks^^

James

Hey guy`s!

Is it possible to change the Trivia-Ex bot , so that  anybody anwering 10 question in a row without receiving any hints or help will be banned by the gag rule of this hub from main chat for about 30min.there are just to many chaps in here who already know all the answers by heart. those same chaps are taking the fun out the quiz for the new users who havnt played the trivia yet. so please be fair, let others play too, or get caught and be banned...

???????????????

Trivia + Simple GagBot  ????

   Thanks in Advance

jiten

QuoteOriginally posted by James
Hey guy`s!

Is it possible to change the Trivia-Ex bot , so that  anybody anwering 10 question in a row without receiving any hints or help will be banned by the gag rule of this hub from main chat for about 30min.there are just to many chaps in here who already know all the answers by heart. those same chaps are taking the fun out the quiz for the new users who havnt played the trivia yet. so please be fair, let others play too, or get caught and be banned...

???????????????

Trivia + Simple GagBot  ????

   Thanks in Advance
Check your other post again.

Cheers

jiten

Trivia Ex V 0.68 by chill

Changelog:

[*]	Fixed: Answer showing before bot messages on Main and PM (jiten);
[*]	Fixed: SendDataPlayer, ShowAnswer and TrivEx._Sets.solveques bug (thx to phorum)
[*]	Added: Typos, capitals, commas, fullstops and many more (thx to forum)
[*]	Added: Keep streak option - TrivEx._Sets.keepstreak (thx to phorum)
[*]	Removed: Case sensitivity for answers (thx to phorum)
Grab it HERE.

Cheers

phorum

If the answer in the question file contains a dash (minus sign), the script accepts it but doesn't send the line with the correct user's answer to other users.

In function TrivEx:ParseData(mode,curUser,data) there are two instances of the following line:

   if string.find( string.lower(sdata), string.lower(corrans) ) then

i have replaced them with this:

   if string.lower(sdata) == string.lower(corrans) then

and now it's working ok.


TO JITEN:
hey m8, clean your PM box. it's full and won't accept new messages, and i can't reach you on your e-mail.

jiten

QuoteOriginally posted by phorum
If the answer in the question file contains a dash (minus sign), the script accepts it but doesn't send the line with the correct user's answer to other users.

In function TrivEx:ParseData(mode,curUser,data) there are two instances of the following line:

   if string.find( string.lower(sdata), string.lower(corrans) ) then

i have replaced them with this:

   if string.lower(sdata) == string.lower(corrans) then

and now it's working ok.


TO JITEN:
hey m8, clean your PM box. it's full and won't accept new messages, and i can't reach you on your e-mail.
Hi there phorum. Thanks for your report.
And yes, I've cleaned my PM box, didn't know that there was a limit :D
Btw, I'm going to have a look at my mail and will tell you something.

Cheers

Mogli

I forgot my pass,
and was bored of the old nick anyways ( me = chill )

jiten thx for keeping this script alive :), and
working on it

SMF spam blocked by CleanTalk