Here is the talkaction part of the script unless whole script is needed.
]]></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)
doPlayerAddItem(cid, 5957, 1)
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>