• 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!

Lua Question task help

DanneZ

Web-Scripting-Design-Host
Joined
Jan 16, 2010
Messages
84
Reaction score
2
Location
Sweden
I used this npc script made by Cykotitan, but i want it like if u answer all questions correctly you get an storage.

Script by Cykotitan.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local Topic = {}
local conv = {
	{
		[1] = "What genre are tibia?"

	},
	{
		[1] = "mmorpg"

	}
}
 
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
 
function greetCallback(cid)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	Topic[talkUser] = 0
	return true
end
 
function creatureSayCallback(cid, type, msg)
 
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	if Topic[talkUser] > 0 then
		if msgcontains(msg, conv[2][Topic[talkUser]]) then
		          local storage = 133341
			npcHandler:say("Congratulations, you have answered correctly!", cid)
			npcHandler:say("Now go to the leader and get your reward!", cid)
			setPlayerStorageValue(cid, storage, 1)
		else
			npcHandler:say("Sorry, but that wasn't the correct answer.", cid)
		end
		Topic[talkUser] = 0
	elseif msgcontains(msg, "question") then
		local random = math.random(#conv[1])
		npcHandler:say(conv[1][random], cid)
		Topic[talkUser] = random
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Ofc I Rep++ if u helped.
Thanks for ur time, Yours DanneZ.
 
Back
Top