Hello, I'm beginner with scripting and trying to learn things by reading other threads. I managed to make simple quests, but now i get some problems and don't have any idea how to fix it.
Quest is simple, npc Joe tell our character to collect items to get prize. When i set collect 1 item its fine, but when i want to add count (for example collect 5 items) script broke. If u could find error, fix it and explain me why its not working I would be delighted.
NPC script:
Error:
Quest is simple, npc Joe tell our character to collect items to get prize. When i set collect 1 item its fine, but when i want to add count (for example collect 5 items) script broke. If u could find error, fix it and explain me why its not working I would be delighted.
NPC script:
Lua:
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
local player = Player(cid)
if msg == "quest" and player:getStorageValue(12556) ~= 1 and player:getStorageValue(12556) ~= 2 then
selfSay('Ive got my old armor for sell, but if you bring me 5 warwolf furs i will give you it for free. Be hasty, I need to delivery those furs to one of the shadows in old camp. {Interested} ?', cid)
talkState[talkUser] = 1
end
if msg == "interested" and talkState[talkUser] == 1 then
selfSay('You are probably too weak to kill such monsters, but you could try talk with guards or hunters. You will find them around the exchange square, still want taking up the {task} ?', cid)
talkState[talkUser] = 2
end
if msg == "task" and talkState[talkUser] == 2 then
player:setStorageValue(12556, 1)
selfSay('Okay, come back when you collect all items', cid)
talkState[talkUser] = 0
end
if msg == "task" and player:getStorageValue(12556) == 1 and player:getStorageValue(12555) ~= 2 then
if player:getItemCount(ItemType(id = 11235, count = 5), :getId()) > 0 then
player:removeItem(ItemType(id = 11235, count = 5):getId(), 1)
selfSay('Thank you so much for helping me! I would be in trouble if i dont delivery those furs. Here is your armor, its little used, but still better than your rags.', cid)
player:addItem(ItemType(2484):getId(), 1)
player:setStorageValue(12556, 2)
talkState[talkUser] = 0
else
selfSay('You dont have enought furs, come back when you will collect all of them', cid)
talkState[talkUser] = 0
end
end
if msg == "task" and player:getStorageValue(12556) ~= 1 and player:getStorageValue(12556) == 2 then
selfSay('Thank you so much for helping me! I would be in trouble if i dont delivery those furs. Here is your armor, its little used, but still better than your rags.', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Error:
Lua:
[Warning - NpcScript::NpcScript] Can not load script: joe.lua
data/npc/scripts/joe.lua:36: ')' expected near '='