Hey guy`s!
Trivia Ex Quiss Bot in Combination with Simple Gag Bot !!
Is it possible to change the Trivia-Ex bot , so that anybody anwering 12 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.
Example:
if (self.streak == 12) then
TrivEx:SendToPlayers(nick.." *!gag/mute* ??? ;), "..self.streak.." runs in a row. Amazing.")
elseif (self.streak == 9) then
TrivEx:SendToPlayers("ey "..nick.."Warning No 2")
elseif (self.streak == 5) then
TrivEx:SendToPlayers("ey "..nick.."Warning No 1")
elseif (self.streak == 1) then
TrivEx:SendToPlayers(nick..", that makes "..self.streak.." runs in a row.")
The Warning is ok...works
The Gag/Mute is not ok
Thanks in Advance
nothing? or not possible ?
Well, the "smart guy" will be gagged when he reaches a streak of 12 and that gag can be removed with the "!iungag" command. Hope this helps you...
Add this to your lua file:
sGag = {}
TrivEx._Cmds.iungag = TrivEx.UnGag -- Ungags a user
function TrivEx:UnGag(curUser,data)
if self:AllowedProf("Config+",curUser) then
local s,e,v = string.find(data,"%b<>%s+%S+%s+(%S+)")
local victim = GetItemByName(v)
if victim == nil then
self:SendToUser(curUser,"User is not in the hub.")
else
if sGag[victim.sName] == 1 then
sGag[victim.sName] = nil;
TrivEx:SendToPlayers(victim.sName.." was ungagged for knowing all the answers by heart.")
TrivEx:WriteTable(sGag,"sGag","gagged.tbl")
else
self:SendToUser(curUser,victim.sName.." wasn?t gagged.")
end
end
end
end
and replace your old functions with these:
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 sGag[curUser.sName] == 1 then
return 1
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
curTriv.streak.UpdStreak = function(self,curUser)
if curUser then
-- Write Scores by next saving
curTriv.streak.write_scores = 1
-- Set Unanswered Questions to zero
curTriv.unansques = 0
local nick = curUser.sName
if (self.nick == nick) then
self.streak = self.streak + 1
if (self.streak > TrivEx._Scores[curUser.sName].Streak) then
TrivEx:SendToPlayers(nick..", you broke your current run of "..TrivEx._Scores[curUser.sName].Streak..".")
TrivEx._Scores[curUser.sName].Streak = self.streak
end
if (self.streak == 12) then
if sGag[nick] == nil then
sGag[nick] = 1
TrivEx:SendToPlayers(nick.." was gagged for knowing all the answers by heart.")
TrivEx:WriteTable(sGag,"sGag","gagged.tbl")
end
elseif (self.streak == 9) then
TrivEx:SendToPlayers("ey "..nick.."Warning No 2")
elseif (self.streak == 6) then
TrivEx:SendToPlayers("And the miracle continues, "..nick.." that makes "..self.streak.." runs in a row now.")
elseif (self.streak == 5) then
TrivEx:SendToPlayers("ey "..nick.."Warning No 1")
elseif (self.streak == 3) then
TrivEx:SendToPlayers(nick..", that makes "..self.streak.." runs in a row.")
end
else
if (self.streak >= 12) then
TrivEx:SendToPlayers("And "..nick.." ends "..self.nick.." miracle of "..self.streak.." runs in a row. Ole!")
elseif (self.streak >= 9) then
TrivEx:SendToPlayers(nick.." *applause*, was about time to break, "..self.nick.."'s "..self.streak.." runs in a row.")
elseif (self.streak >= 6) then
TrivEx:SendToPlayers("Beat it "..self.nick..", "..nick.." just set and end to your "..self.streak.." runs in a row.")
elseif (self.streak >= 3) then
TrivEx:SendToPlayers("There goes "..self.nick.."'s run of "..self.streak)
end
self.nick = nick
self.streak = 1
end
else
if (self.nick ~= "") then
if (self.streak >= 12) then
TrivEx:SendToPlayers("Well that was obvious, that this questions would end "..self.nick.."'s run of "..self.streak.." ;)")
elseif (self.streak >= 9) then
TrivEx:SendToPlayers(self.nick.." say 'good bye' to your run of "..self.streak)
elseif (self.streak >= 3) then
TrivEx:SendToPlayers("There goes "..self.nick.."'s run of "..self.streak)
end
end
self.nick = ""
self.streak = 0
end
end
Best regards,
jiten
Thanks jiten ...-))) but ...
if i change it, trivia quiz will not work... or im doing something wrong?... can you give me the whole changed trivia quizbot?
Thanks in advance -)))
QuoteOriginally posted by James
Thanks jiten ...-))) but ...
if i change it, trivia quiz will not work... or im doing something wrong?... can you give me the whole changed trivia quizbot?
Thanks in advance -)))
Ok, I'll post the whole script here later today.
Btw, check the allowed profiles in the script.
That could be the reason also.
Best regards
Grab the stand-alone Lua file here (http://mznetwork.mozdesigners.com/i/forum_files/Trivia-Ex-V.0.681.lua5.lua).
Best regards,
jiten
^^ no syntax error
but
^^ no works ;(
QuoteOriginally posted by James
^^ no syntax error
but
^^ no works ;(
What PtokaX version are u using?
I tried the script some minutes ago and it worked perfectly (PtokaX build 17.03 debug).
Btw, check ur profile settings in the script too.
Cheers
ufff...16.05 ... have LavMaker @ this works not with 17.03
QuoteOriginally posted by James
ufff...16.05 ... have LavMaker @ this works not with 17.03
Tried it with 16.05 and it worked.
Open ur .lua file and replace the profile part with this:
TrivEx._Profiles.Normal = {
[0] = "Master",
[1] = "Operator",
[2] = "VIP",
[3] = "Reg",
[4] = "Moderator",
[5] = "NetFounder",
[-1] = "Noobs",
}
TrivEx._Profiles.Config = {
[0] = "Master",
[1] = "Operator",
[2] = "VIP",
[3] = "Reg",
[4] = "Moderator",
[5] = "NetFounder",
}
TrivEx._Profiles["Config+"] = {
[0] = "Master",
[1] = "Operator",
[4] = "Moderator",
[5] = "NetFounder",
}
If I'm not wrong, u haven't added the extra profiles of LawMaker in the TriviaEx tables.
Not sure of them so I just added robocop ones. Change at will. It will certainly work after this.
Cheers
QuoteOriginally posted by jiten
If I'm not wrong, u haven't added the extra profiles of LawMaker in the TriviaEx tables.
Cheers
You are wrong, because LawMaker uses the default profiles, however I don't know whether Triv has them as defaults. ;)
LOOOOOL
I'm so stupid. The changed TriviaQuiss does work with ptoka 16.05, with 17.03 and lawmaker too. But I had the Quiss on autmaticstart so I never thought about turning it on with !triviastart *ashamed* . Very good work.
thank you. ;)
QuoteOriginally posted by James
LOOOOOL
I'm so stupid. The changed TriviaQuiss does work with ptoka 16.05, with 17.03 and lawmaker too. But I had the Quiss on autmaticstart so I never thought about turning it on with !triviastart *ashamed* . Very good work.
thank you. ;)
Glad to hear that it's working :]
Best regards,
jiten
Is it possible to change The Gag/Mute in Gag on Time ?
Example after 5 or 10 Min automaticaly ungag ?
in Your script jiten '' ungag ''not works...
Change this please :
TrivEx._Cmds.1ungag = TrivEx.UnGag
To this
TrivEx._Cmds.ungag = TrivEx.UnGag
now works the ungag-)))
Is possible to add the Timegag ??? ;)
Well, it's possible. Add this to ur script:
TrivEx._Sets.gtime = 1 -- After this period in minutes, the gagged user is automatically ungagged
and replace your functions with these:
curTriv.streak.UpdStreak = function(self,curUser)
if curUser then
-- Write Scores by next saving
curTriv.streak.write_scores = 1
-- Set Unanswered Questions to zero
curTriv.unansques = 0
local nick = curUser.sName
if (self.nick == nick) then
self.streak = self.streak + 1
if (self.streak > TrivEx._Scores[curUser.sName].Streak) then
TrivEx:SendToPlayers(nick..", you broke your current run of "..TrivEx._Scores[curUser.sName].Streak..".")
TrivEx._Scores[curUser.sName].Streak = self.streak
end
if (self.streak == 12) then
if sGag[nick] == nil then
sGag[nick] = TrivEx._Sets.gtime*60
TrivEx:SendToPlayers(nick.." was gagged for knowing all the answers by heart.")
TrivEx:WriteTable(sGag,"sGag","gagged.tbl")
end
elseif (self.streak == 9) then
TrivEx:SendToPlayers("ey "..nick.."Warning No 2")
elseif (self.streak == 6) then
TrivEx:SendToPlayers("And the miracle continues, "..nick.." that makes "..self.streak.." runs in a row now.")
elseif (self.streak == 5) then
TrivEx:SendToPlayers("ey "..nick.."Warning No 1")
elseif (self.streak == 2) then
TrivEx:SendToPlayers(nick..", that makes "..self.streak.." runs in a row.")
end
else
if (self.streak >= 12) then
TrivEx:SendToPlayers("And "..nick.." ends "..self.nick.." miracle of "..self.streak.." runs in a row. Ole!")
elseif (self.streak >= 9) then
TrivEx:SendToPlayers(nick.." *applause*, was about time to break, "..self.nick.."'s "..self.streak.." runs in a row.")
elseif (self.streak >= 6) then
TrivEx:SendToPlayers("Beat it "..self.nick..", "..nick.." just set and end to your "..self.streak.." runs in a row.")
elseif (self.streak >= 3) then
TrivEx:SendToPlayers("There goes "..self.nick.."'s run of "..self.streak)
end
self.nick = nick
self.streak = 1
end
else
if (self.nick ~= "") then
if (self.streak >= 12) then
TrivEx:SendToPlayers("Well that was obvious, that this questions would end "..self.nick.."'s run of "..self.streak.." ;)")
elseif (self.streak >= 9) then
TrivEx:SendToPlayers(self.nick.." say 'good bye' to your run of "..self.streak)
elseif (self.streak >= 3) then
TrivEx:SendToPlayers("There goes "..self.nick.."'s run of "..self.streak)
end
end
self.nick = ""
self.streak = 0
end
end
function TrivEx:OnTimer()
-- Load Questions if needed
if (table.getn(self._Questions) == 0) then
self:LoadQuestions()
end
-- Check if Trivia should be paused
if (self._Sets.dobreak == 1) then
if (not curTriv:Pause()) then
-- Update TimeBreak
TrivTimers.timebreak = TrivTimers.timebreak + 1
if (TrivTimers.timebreak >= self._Sets.timebreak) and curTriv:GetGetQues() then
curTriv:SetPause(1)
TrivTimers.timebreak = 0
TrivTimers.breaktime = 0
self:SendToPlayers("Short Trivia break for "..(self._Sets.breaktime/60).." min.")
end
end
if curTriv:Pause() then
-- Update BreakTime
TrivTimers.breaktime = TrivTimers.breaktime + 1
if (TrivTimers.breaktime >= self._Sets.breaktime) then
curTriv:SetPause(0)
TrivTimers.timebreak = 0
TrivTimers.breaktime = 0
TrivTimers.showques = 0
end
end
end
-- Check if Trivia should be Autostoped
if curTriv:GetGetQues() then
if self._Sets.autostop and (curTriv.unansques == self._Sets.autostop) then
StopTimer()
curTriv:SetGetQues(1)
self:WriteTable(self._Scores,"TrivEx._Scores",self._Sets.folder.."/"..TrivEx._Sets.ScoresFile)
self:SendToPlayers("Trivia stopped due to Autostop, "..self._Sets.autostop.." questions weren't answered in a row.")
return
end
end
if (not curTriv:Pause()) then
--Update ShowQuestion Time
TrivTimers.showques = TrivTimers.showques + 1
if (TrivTimers.showques == self._Sets.showques) then
TrivTimers.showques = 0
-- Check if to get new question
if curTriv:GetNewQues() then
curTriv:SendQuestion()
-- Count unsanswered questions one up
curTriv.unansques = curTriv.unansques + 1
else
curTriv:UpdHint()
if curTriv:GetGetQues() then
-- Show the Answer
curTriv:ShowAnswer()
-- Check for Streak
curTriv.streak:UpdStreak()
else
curTriv:SendQuestion()
end
end
end
for nick,v in sGag do
local usr = GetItemByName(nick)
sGag[nick] = sGag[nick] - 1
if sGag[nick] == 0 then
sGag[nick] = nil
TrivEx:SendToPlayers(nick.. " was ungagged from TriviaGame.")
TrivEx:WriteTable(sGag,"sGag","gagged.tbl")
end
end
end
if (self._Sets.savestats ~= 0) then
TrivTimers.savestats = TrivTimers.savestats + 1
if TrivTimers.savestats >= self._Sets.savestats then
TrivTimers.savestats = 0
if (curTriv.streak.write_scores == 1) then
self:WriteTable(self._Scores,"TrivEx._Scores",self._Sets.folder.."/"..TrivEx._Sets.ScoresFile)
curTriv.streak.write_scores = 0
end
end
end
end
Not really tested.
Cheers
QuoteOriginally posted by James
in Your script jiten '' ungag ''not works...
Change this please :
TrivEx._Cmds.1ungag = TrivEx.UnGag
To this
TrivEx._Cmds.ungag = TrivEx.UnGag
now works the ungag-)))
Is possible to add the Timegag ??? ;)
It was a small typo ;)
Already fixed it.
Cheers