Hello friends... i make one npc whit MATCH RANDON but, when i'm say YES, NPC don't make nothing, but don't send errors on CONSOLE, this is a NPC SCRIPT:
-- Plx friends help me to fix this... my npc its equal santa claus, but i use TFS 0.2 - patch 23...
-- Thx for all...
F@bio
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
------------------------------------------------ Present ------------------------------------------------
if msgcontains(msg, 'present') then
presend = getPlayerStorageValue(cid,9999)
if presend == -1 then
if getPlayerLevel(cid) >= 15 then
npcHandler:say('Humm... você gostaria de ganhar um presente de páscoa???', cid)
talk_state = 1
else
npcHandler:say('Você precisa de level 15 para iniciar essa missão', cid)
talk_state = 0
end
else
npcHandler:say('Você já ganhou seu presente de páscoa seu fominha', cid)
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
rand = math.random(1,20)
if rand == 1 then
npcHandler:say('Aqui está o seu presente e feliz páscoa para você', cid)
doPlayerAddItem(cid, 2687, 10) --biscoito
doPlayerAddItem(cid, 2674, 1) --karmor
setPlayerStorageValue(cid,9999,1)
elseif rand == 8 then
npcHandler:say('Aqui está o seu presente e feliz páscoa para você', cid)
doPlayerAddItem(cid, 6574, 1) --chocolate
doPlayerAddItem(cid, 8873, 1) --hybicus dress
setPlayerStorageValue(cid,9999,1)
elseif rand == 15 then
npcHandler:say('Aqui está o seu presente e feliz páscoa para você', cid)
doPlayerAddItem(cid, 8111, 10) --biscoito
doPlayerAddItem(cid, 2430, 1) --kaxe
setPlayerStorageValue(cid,9999,1)
elseif rand == 20 then
npcHandler:say('Aqui está o seu presente e feliz páscoa para você', cid)
doPlayerAddItem(cid, 8847, 1) --chocolate
doPlayerAddItem(cid, 2409, 1) --serpent sword
setPlayerStorageValue(cid,9999,1)
end
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') or msgcontains(msg, 'nao') and (talk_state >= 1 and talk_state <= 41) then
npcHandler:say('Ok então, vaza!!!', cid)
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
-- Plx friends help me to fix this... my npc its equal santa claus, but i use TFS 0.2 - patch 23...
-- Thx for all...
F@bio