Sir Bananas
Lua Scripter, Spriter
Can anyone tell me whats wrong with this script?
PHP:
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
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 (msgcontains(msg, "mission") or msgcontains(msg, "help")) and getPlayerStorageValue(cid, 400010) == -1 then
npcHandler:say("Thats great! I need some supplies, for my hunting trip.", cid)
npcHandler:say("Could you fetch me 5 pieces of meat?", cid)
talkState[talkUser] = 1
doPlayerSetStorageValue(cid, 400010, 1)
end
if (msgcontains(msg, "mission") or msgcontains(msg, "help")) and getPlayerStorageValue(cid, 400010) == 1 then
npcHandler:say("Do you have the meat yet?.", cid)
talkState[talkUser] = 2
end
if (msgcontains(msg, "yes")) and talkState[talkUser] == 2 then
if getPlayerItemCount(cid, 2666) >= 5 then
npcHandler:say("Thanks! Here is a reward for you.", cid)
doPlayerAddMoney(cid, 130)
else
npcHandler:say("You don't have the meat yet!", cid)
talkState[talkUser] = 0
end
else
npcHandler:say("Oh. Okay. Come back when you have the meat.", cid)
talkState[talkUser] = 0
end
if (msgcontains(msg, "yes")) and talkState[talkUser] == 1 then
npcHandler:say("Perfect. You can get meat by killing deer and rabbits outside the town.", cid)
else
npcHandler:say("Oh. Too bad.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())