Hiya! Long time since i even played around with coding at all, if someone could explain what the issue is, i can't seem to understand what the problem is.
Thanks!!!
Getting this error:
This is my creaturescript:
And this is my lib:
Thanks!!!
Getting this error:
Code:
[0:34:41.243] [Error - CreatureScript Interface]
[0:34:41.244] data/creaturescripts/scripts/npcQuestKill.lua:onKill
[0:34:41.245] Description:
[0:34:41.245] data/lib/115-npcquestsystem.lua:50: attempt to index local 'missions' (a nil value)
[0:34:41.245] stack traceback:
[0:34:41.246] data/lib/115-npcquestsystem.lua:50: in function 'npcGetMissionInfo'
[0:34:41.246] data/creaturescripts/scripts/npcQuestKill.lua:6: in function <data/creaturescripts/scripts/npcQuestKill.lua:1>
This is my creaturescript:
Code:
function onKill(cid, target, lastHit)
if(isMonster(target) and getCreatureStorage(cid, NPC_questsConfig["any_quest_is_running"]) ~= -1) then
for i, questConfig in pairs(NPC_questsConfig) do
if(type(questConfig) == "table") then
if(getCreatureStorage(cid, questConfig["storage_id"] + 1) >= 0) then
local mission, state = npcGetMissionInfo(getCreatureStorage(cid, questConfig["storage_id"]), questConfig["missions"])
local requested_monster = mission["requested_monster"]
if(requested_monster[1] == getCreatureName(target)) and ((not requested_monster[3]) or (requested_monster[3] and lastHit)) then
doCreatureSetStorage(cid, questConfig["storage_id"] + 1, getCreatureStorage(cid, questConfig["storage_id"] + 1) + 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You killed ".. getCreatureStorage(cid, questConfig["storage_id"] + 1) .." / ".. requested_monster[2] .." needed ".. getCreatureName(target) .." for NPC ".. i ..".")
end
end
end
end
end
return true
end
And this is my lib:
Code:
-- library NPC quests
function npcCheckPlayerItems(cid, itemsList)
if(#itemsList > 0) then
for i, item in pairs(itemsList) do
if(getPlayerItemCount(cid, item.itemid, item.subType) < item.count) then
return false
end
end
end
return true
end
function npcRemovePlayerItems(cid, itemsList)
if(npcCheckPlayerItems(cid, itemsList)) then
for i, item in pairs(itemsList) do
doPlayerRemoveItem(cid, item.itemid, item.count, item.subType and item.subType or -1)
end
end
end
function npcAddPlayerRewards(cid, rewards) -- not ready
for i, reward in pairs(rewards) do
if(reward["type"] == "item") then
for i, item in pairs(reward["itemsList"]) do
if(item.subType ~= nil) then
doPlayerAddItem(cid, item.itemid, item.count, 1, item.subType)
else
doPlayerAddItem(cid, item.itemid, item.count, 1)
end
end
elseif(reward["type"] == "exp") then
doPlayerAddExperience(cid, reward["value"])
end
end
return true
end
function npcMessageContains(msg, words)
for i, v in pairs(words) do
if(msg:lower():find(v:lower()) and not msg:lower():find('(%w+)' .. v:lower()) and not msg:lower():find(v:lower() .. '(%w+)')) then
return true
end
end
return false
end
function npcGetMissionInfo(storage, missions)
local mission_id = math.floor(storage / 2)
return missions[mission_id+1], (mission_id == tonumber(storage / 2)) and 0 or 1
end
function npcParseMessage(text, cid)
local info = {["|PLAYERNAME|"] = getCreatureName(cid)}
for search, replace in pairs(info) do
text = string.gsub(text, search, replace)
end
return text
end
function npcCheckStorages(cid, storagesTable)
for i, storage in pairs(storagesTable) do
local value = getCreatureStorage(cid, storage[1])
if(value == storage[2] and not storage[3]) or (value ~= storage[2] and storage[3]) then
return false
end
end
return true
end
function npcSetStorages(cid, storagesTable)
for i, storage in pairs(storagesTable) do
doCreatureSetStorage(cid, storage[1], storage[2])
end
end