• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction [0.4] Pop quiz script

Teckman

Intermediate OT User
Joined
Jul 5, 2008
Messages
913
Reaction score
148
Here's my pop quiz script. There's a question drawn, and the first person who answers the question gets the prize.

If you know any questions I could add, post them with comments! :)


/mods/popquiz.xml

Lua:
<?xml version = "1.0" encoding = "UTF-8"?>
    <mod name = "Pop quiz" version = "1.0" author = "Teckman" enabled = "yes">
        <config name = "config"><![CDATA[
            config = {
                questions = {
                    [1] = {question = "What is 'tibia' in latin?", answer = "bone"},
                    [2] = {question = "What is the incantation for rage of the skies spell?", answer = "exevo gran mas vis"},
                    [3] = {question = "How much health has a rotworm?", answer = "65"},
                    [4] = {question = "When was tibia created?", answer = "1997"},
                    [5] = {question = "How much attack has magic sword?", answer = "48"},
                    [6] = {question = "How many feet toes has a cyclops?", answer = "7"},
                    [7] = {question = "What type of item requires soul to be created?", answer = "rune"},
                    [8] = {question = "How many elements are in tibia?", answer = "6"},
                    [9] = {question = "How many professions are in tibia?", answer = "4"},
                    [10] = {question = "How much gold does promotion cost?", answer = "20000"},
                    [11] = {question = "What is the name of the current king?", answer = "tibianus"},
                    [12] = {question = "What is the name of the 'pyramid city'?", answer = "ankrahmun"},
                    [13] = {question = "How many pharaos exist in tibia?", answer = "9"},
                },
                prize = 50000, -- if you want a random number just add for example {50, 20000}
                storage = 400
            }
        ]]></config>
        <globalevent name="popquiz" interval="20" event="script"><![CDATA[
            domodlib("config")
            function onThink(interval)
                setGlobalStorageValue(cid, config.storage, config.questions[math.random(1, table.maxn(config.questions))].question)
                doBroadcastMessage("[POP QUIZ]: " .. getGlobalStorageValue(config.storage) .. " - to answer the question type '/quiz ANSWER'.", MESSAGE_EVENT_ADVANCE)
                return true
            end
        ]]></globalevent>
        <talkaction words = "/quiz" event = "script"><![CDATA[
            domodlib("config")
            function onSay(cid, words, param)
                if(param) then
                    if(getGlobalStorageValue(config.storage)) then
                        for _, v in pairs(config.questions) do
                            if(v.question == getGlobalStorageValue(config.storage)) then
                                if(string.lower(param) == v.answer) then
                                    doBroadcastMessage("[POP QUIZ]: " .. getPlayerName(cid) .. " has answered the question: " .. v.question .. ", with answer: " .. v.answer .. ". Congratulations to the winner!", MESSAGE_EVENT_ADVANCE)
                                    doPlayerAddMoney(cid, type(config.prize) == "table" and math.random(config.prize[1], config.prize[2]) or config.prize
                                    setGlobalStorageValue(config.storage, nil)
                                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
                                    return true
                                end
                            end
                        end
                    else
                        doPlayerSendCancel(cid, "The quiz has already ended.")
                        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                        return true
                    end
                else
                    doPlayerSendCancel(cid, "The answer must be stated in parameter.")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    return true
                end
                doPlayerSendCancel(cid, "This answer is wrong.")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                return true
            end
        ]]></talkaction>
    </mod>
 
Last edited by a moderator:
Thats a script im definitely using on my ot when i open it soon :d great release :p
 
useless!!!!!!!

Pffffffft. Seriously, go read your 5 lines scripts if you wanna see something useless.
@On: Najs, where do you get all these ideas from, I'm always outta creativity.
 
Pffffffft. Seriously, go read your 5 lines scripts if you wanna see something useless.
@On: Najs, where do you get all these ideas from, I'm always outta creativity.

Today I was thinking about an idea for about an hour! Then I saw a pop quiz show on tv and idea came. Most of the time I'm searching for old scripts that I could remake or thinking about something usefull, and idea comes sooner or later. :p
 
Would be cool to have a durability system, like wow. You have a plate armor with 100/100 durability and it goes down when you take hits and stuff and you can get a overdura one (120/120) so it would have 20% more def.
Dunnom if it's possible but would be awesome
 
Today I was thinking about an idea for about an hour! Then I saw a pop quiz show on tv and idea came. Most of the time I'm searching for old scripts that I could remake or thinking about something usefull, and idea comes sooner or later. :p

i need to watch some tv maybe i would get an idea :D
 
Code:
					[10] = {question = "What is the name of the author of this script?", answer = "teckman"},
using that question, you should add it too ;)
 
How do i change what you receve when answered

Example: i want to change the reward to Itemid:2159
 
PHP:
[1:43:47.147] [Error - TalkAction Interface]
[1:43:47.147]                   domodlib("config")
[1:43:47.147]                   function onSay(cid, words, param)
[1:43:47.147]                           if(param) then
[1:43:47.147]                                   if(getGlobalStorageValue(config.
storage)) then
[1:43:47.147]                                           for _, v in pairs(config
.questions) do
[1:43:47.147]                                                   if(v.question ==
 getGlobalStorageValue(config.storage)) then
[1:43:47.147]                                                           if(strin
g.lower(param) == v.answer) then
[1:43:47.147]
doBroadcastMessage("[POP QUIZ]: " .. getPlayerName(cid) .. " has answered the qu
estion: " .. v.question .. ", with answer: " .. v.answer .. ". Congratulations t
o the winner!", MESSAGE_EVENT_ADVANCE)
[1:43:47.147]
doPlayerAddMoney(cid, type(config.prize) == "table" and math.random(config.prize
[1], config.prize[2]) or config.prize)
[1:43:47.147]
setGlobalStorageValue(config.storage, nil)
[1:43:47.163]
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
[1:43:47.163]
return true
[1:43:47.163]                                                           end
[1:43:47.163]                                                   end
[1:43:47.163]                                           end
[1:43:47.163]                                   else
[1:43:47.163]                                           doPlayerSendCancel(cid,
"The quiz has already ended.")
[1:43:47.163]                                           doSendMagicEffect(getPla
yerPosition(cid), CONST_ME_POFF)
[1:43:47.163]                                           return true
[1:43:47.163]                                   end
[1:43:47.163]                           else
[1:43:47.163]                                   doPlayerSendCancel(cid, "The ans
wer must be stated in parameter.")
[1:43:47.163]                                   doSendMagicEffect(getPlayerPosit
ion(cid), CONST_ME_POFF)
[1:43:47.178]                                   return true
[1:43:47.178]                           end
[1:43:47.178]                           doPlayerSendCancel(cid, "This answer is
wrong.")
[1:43:47.178]                           doSendMagicEffect(getPlayerPosition(cid)
, CONST_ME_POFF)
[1:43:47.178]                           return true
[1:43:47.178]                   end
[1:43:47.178]           :onSay
[1:43:47.178] Description:
[1:43:47.178] [string "LuaInterface::loadBuffer"]:5: bad argument #1 to 'pairs'
(table expected, got nil)
[1:43:47.178] stack traceback:
[1:43:47.178]   [C]: in function 'pairs'
[1:43:47.178]   [string "LuaInterface::loadBuffer"]:5: in function <[string "Lua
Interface::loadBuffer"]:2>


for some reason when people try to answer the /quiz answer command stops working and i get this error in console any ideas ???
 
Mike, If you still need the answer PM me. I will tell you how to fix the script.
 
Last edited:
me that it works poorly on this principle, means that when we write off the quiz questions right or wrong questions are repetitive, and there will never end quiz
 
[11/07/2012 21:35:26] [Error - GlobalEvent Interface]
[11/07/2012 21:35:26] buffer:eek:nThink
[11/07/2012 21:35:26] Description:
[11/07/2012 21:35:26] [string "loadBuffer"]:3: attempt to index global 'config' (a nil value)
[11/07/2012 21:35:26] stack traceback:
[11/07/2012 21:35:27] [string "loadBuffer"]:3: in function <[string "loadBuffer"]:2>
[11/07/2012 21:35:27] [Error - GlobalEvents::think] Couldn't execute event: popquiz
 
thanks teckman this is good idea :)
I cannot however, get the talkaction to work.I get no errors in console. Would you be able to help me figure out whats wrong? Crying damson 3.6pl1 (8.54)
 
Trying to use this for 0.3.7, but i get an error that spams out the counsel...
Code:
[string "LuaInterface::loadBuffer"]:3: bad argument #1 to 'maxn' (table expected, got nil)
stack traceback:
[C]: in function 'maxn'
[string "LuaInterface::loadBuffer"]:3: in function <[string "LuaInterface::loadBuffer"]:2>

Using the code posted in the main thread, but here it is because people always ask for script....
Code:
<?xml version = "1.0" encoding = "UTF-8"?>
    <mod name = "Pop quiz" version = "1.0" author = "Teckman" enabled = "yes">
        <config name = "config"><![CDATA[
            config = {
                questions = {
                    [1] = {question = "What means 'tibia' in latin?", answer = "bone"},
                    [2] = {question = "What is the incantation for rage of the skies spell?", answer = "exevo gran mas vis"},
                    [3] = {question = "How much health has a rotworm?", answer = "65"},
                    [4] = {question = "When was tibia created?", answer = "1997"},
                    [5] = {question = "How much attack has magic sword?", answer = "48"},
                    [6] = {question = "How many feet toes has a cyclops?", answer = "7"},
                    [7] = {question = "What type of item requires soul to be created?", answer = "rune"},
                    [8] = {question = "How many elements are in tibia?", answer = "6"},
                    [9] = {question = "How many professions are in tibia?", answer = "4"},
                    [10] = {question = "How much gold does promotion cost?", answer = "20000"},
                    [11] = {question = "What is the name of the current king?", answer = "tibianus"},
                    [12] = {question = "What is the name of the 'pyramid city'?", answer = "ankrahmun"},
                    [13] = {question = "How many pharaos exist in tibia?", answer = "9"},
                },
                prize = 50000, -- if you want a random number just add for example {50, 20000}
                storage = 400
            }
        ]]></config>
        <globalevent name="popquiz" interval="20" event="script"><![CDATA[
            domodlib("config")
            function onThink(interval)
                setGlobalStorageValue(cid, config.storage, config.questions[math.random(1, table.maxn(config.questions))].question)
                doBroadcastMessage("[POP QUIZ]: " .. getGlobalStorageValue(config.storage) .. " - to answer the question type '/quiz ANSWER'.", MESSAGE_EVENT_ADVANCE)
                return true
            end
        ]]></globalevent>
        <talkaction words = "/quiz" event = "script"><![CDATA[
            domodlib("config")
            function onSay(cid, words, param)
                if(param) then
                    if(getGlobalStorageValue(config.storage)) then
                        for _, v in pairs(config.questions) do
                            if(v.question == getGlobalStorageValue(config.storage)) then
                                if(string.lower(param) == v.answer) then
                                    doBroadcastMessage("[POP QUIZ]: " .. getPlayerName(cid) .. " has answered the question: " .. v.question .. ", with answer: " .. v.answer .. ". Congratulations to the winner!", MESSAGE_EVENT_ADVANCE)
                                    doPlayerAddMoney(cid, type(config.prize) == "table" and math.random(config.prize[1], config.prize[2]) or config.prize)
                                    setGlobalStorageValue(config.storage, nil)
                                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)
                                    return true
                                end
                            end
                        end
                    else
                        doPlayerSendCancel(cid, "The quiz has already ended.")
                        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                        return true
                    end
                else
                    doPlayerSendCancel(cid, "The answer must be stated in parameter.")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    return true
                end
                doPlayerSendCancel(cid, "This answer is wrong.")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                return true
            end
        ]]></talkaction>
    </mod>
 
Back
Top