local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
local storage = 1234
function creatureSayCallback(cid, type, msg)
if msgcontains(msg, "hi") and (not npcHandler:isFocused(cid)) then
if getPlayerStorageValue(cid, storage) < 1 then
npcHandler:say("Me despertaste! Eres un bobo " .. getPlayerName(cid) .. " y no te concedere tres deseos. Toma esta limosna para que te vayas en alfombra voladora.", cid, TRUE)
npcHandler:releaseFocus(cid)
setPlayerStorageValue(cid, storage, 1)
doPlayerAddMoney(cid, math.ceil(math.random(500, 5000)))
elseif getPlayerStorageValue(cid, storage) == 1 then
npcHandler:say("No hay tiempo para ti.", cid, TRUE)
npcHandler:releaseFocus(cid)
end
elseif (not npcHandler:isFocused(cid)) then
return false
end
return true
end
npcHandler:setCallback(CALLBACK_FAREWELL, creatureFarewell)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye then.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)