• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Problem with function

therrax

Member
Joined
Jul 12, 2012
Messages
262
Solutions
1
Reaction score
11
Hi.
TFS 1.0

error:
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/task.lua:onCreatureSay
data/lib/020_task_lib.lua:80: attempt to call global 'getCreatureStorage' (a ni value)
stack traceback:
        [C]: in function 'getCreatureStorage'
        data/lib/020_task_lib.lua:80: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:393: in function 'onCreatureSay'
        data/npc/scripts/task.lua:10: in function <data/npc/scripts/task.lua:10

code:
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/task.lua:onCreatureSay
data/lib/020_task_lib.lua:80: attempt to call global 'getCreatureStorage' (a ni value)
stack traceback:
        [C]: in function 'getCreatureStorage'
        data/lib/020_task_lib.lua:80: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:393: in function 'onCreatureSay'
        data/npc/scripts/task.lua:10: in function <data/npc/scripts/task.lua:10
 
@Limos Thanks :) but now I have this:

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/task_window.lua:onModalWindow
data/compat.lua:748: attempt to call method 'getThingIndex' (a nil value)
stack traceback:
        [C]: in function 'getThingIndex'
        data/compat.lua:748: in function 'getThingPos'
        data/creaturescripts/scripts/task_window.lua:45: in function <data/creaturescripts/scripts/task_window.lua:1>
 
Last edited:
script:
Code:
function onModalWindow(cid, modalWindowId, buttonId, choiceId)
    local rank = getCreatureStorage(cid, rankStorage)
    if rank < 0 then
        doCreatureSetStorage(cid, rankStorage, 0)
    end
                  
    local r_string = function() if tasks[choiceId].repeatable then return "repeatable" end return "not repeatable" end
    local r_article_string = function (id, amount)
        task_item_word = ""
        if amount > 1 then
            task_item_word = task_item_word .. amount .. "x " .. getItemName(id)
        else
            if ItemType(itemId):getArticle() == "" then
                task_item_word = task_item_word .. getItemName(id)
            else
                task_item_word = task_item_word .. ItemType(itemId):getArticle() .. " " .. getItemName(id)
            end
        end
    return task_item_word
    end
    local storage_string = {[80000] = "The Snapper",
[80001] = "Demodras",
[80002] = "The Hide",
[80003] = "The Bloodtusk",
[80004] = "The Shardhead",
[80005] = "Thul",
[80006] = "Esmeralda",
[80007] = "The Old Widow",
[80008] = "The Many",
[80009] = "The Leviathan",
[80010] = "The Stonecracker",
[80011] = "The Noxious Spawn",
[80012] = "Merikh The Slaughterer",
[80013] = "Fahim The Wise",
[80014] = "pirate leader",
[80015] = "The Horned Fox",
[80016] = "Necropharus"
    }
    if (not modalWindowId == 1900) then return false end

    if buttonId == 1 then -- confirm task
        if getCreatureStorage(cid, tasks[choiceId].questStarted) < 1 then
            doCreatureSetStorage(cid, tasks[choiceId].questStarted, 1)
            doCreatureSetStorage(cid, tasks[choiceId].questStorage, 0)
            doCreatureSay(taskNPCuid, "In this mission you have to hunt " .. tasks[choiceId].killsRequired .. " " .. tasks[choiceId].raceName .. " down. Good luck!", TALKTYPE_PRIVATE_NP, false, cid, getThingPos(taskNPCuid))
        else
            if getCreatureStorage(cid, tasks[choiceId].questStarted) == 1 then
                if tasks[choiceId].killsRequired > getCreatureStorage(cid, tasks[choiceId].questStorage) then
                    doPlayerPopupFYI(cid,"Status: Active\nKills: " .. getCreatureStorage(cid, tasks[choiceId].questStorage) .. "/" .. tasks[choiceId].killsRequired .. " (" .. tasks[choiceId].killsRequired - getCreatureStorage(cid, tasks[choiceId].questStorage) .. " left)\n\nThis mission is " .. r_string() .. ".")
                    sendTaskWindow(cid)
                else
                    doCreatureSetStorage(cid, tasks[choiceId].questStarted, 2)
                    task_reward_str = "Reward(s):\n"
                    for i = 1, table.maxn(tasks[choiceId].rewards) do
                        if(tasks[choiceId].rewards[i].enable) then
                            if isInArray({"boss", "teleport", 1}, tasks[choiceId].rewards[i].type) then
                                doTeleportThing(cid, tasks[choiceId].rewards[i].values)
                                task_reward_str = task_reward_str .. "You have been teleported.\n"
                            elseif isInArray({"exp", "experience", 2}, tasks[choiceId].rewards[i].type) then
                                doPlayerAddExperience(cid, tasks[choiceId].rewards[i].values)
                                task_reward_str = task_reward_str .. "+ " .. tasks[choiceId].rewards[i].values .. " exp\n"
                            elseif isInArray({"item", 3}, tasks[choiceId].rewards[i].type) then
                                doPlayerAddItem(cid, tasks[choiceId].rewards[i].values[1], tasks[choiceId].rewards[i].values[2])
                                task_reward_str = task_reward_str .. r_article_string(tasks[choiceId].rewards[i].values[1], tasks[choiceId].rewards[i].values[2]) .. "\n"
                            elseif isInArray({"money", 4}, tasks[choiceId].rewards[i].type) then
                                doPlayerAddMoney(cid, tasks[choiceId].rewards[i].values)
                                task_reward_str = task_reward_str .. "+ " .. tasks[choiceId].rewards[i].values .. " gp\n"
                            elseif isInArray({"storage", "stor", 5}, tasks[choiceId].rewards[i].type) then
                                doCreatureSetStorage(cid, tasks[choiceId].rewards[i].values[1], tasks[choiceId].rewards[i].values[2])
                                task_reward_str = task_reward_str .. "Chance to duel " .. storage_string[tasks[choiceId].rewards[i].values[1]] .. ".\n"
                            elseif isInArray({"points", "rank", 2}, tasks[choiceId].rewards[i].type) then
                                doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[choiceId].rewards[i].values)
                                task_reward_str = task_reward_str .. "+ " .. tasks[choiceId].rewards[i].values .. " rank points.\n"
                            else
                                print("[Warning - Npc::KillingInTheNameOf] Wrong reward type: " .. (tasks[choiceId].rewards[i].type or "nil") .. ", reward could not be loaded.")
                            end
                        end
                    end
                    if task_reward_str == "Reward(s):\n" then
                        doPlayerPopupFYI(cid,task_reward_str .. "none")
                    else
                        doPlayerPopupFYI(cid,task_reward_str)
                    end
                    doCreatureSay(taskNPCuid, "Great job" .. (((rank > 4 and rank < 10) and (", Huntsman") or (rank > 9 and rank < 20) and (", Ranger") or (rank > 19 and rank < 30) and (", Big Game Hunter") or (rank > 29 and rank < 50) and (", Trophy Hunter") or (rank > 49) and (", Elite Hunter")) or ", my Beginner") .. "! Here is your reward. Keep hunting and good luck!", TALKTYPE_PRIVATE_NP, false, cid, getThingPos(taskNPCuid))
                end
            else
                if tasks[choiceId].repeatable then
                    for i = 1, table.maxn(tasks[choiceId].rewards) do
                        if isInArray({"storage", "stor", 5}, tasks[choiceId].rewards[i].type) then
                            doPlayerPopupFYI(cid,"To repeat this mission again, fight with " .. storage_string[tasks[choiceId].rewards[i].values[1]] .. " first.")
                            break

        sendTaskWindow(cid)
    end
  
return true
end
 
Although since you are using 1.1 and not 1.0, you probable need to edit more, better is just using TFS 1.0/1.0 metatable functions instead.
I followed this guide

First Error... Got past it changed In Modules ---> getNpcId = getNpcCid

http://gyazo.com/d1c4b006cdf2f3b990c8c9ccedf21d10

But it just comes new error all the time :p.. Now i got another Error wich is.. 'getCreatureStorage' (a nil value)

followed this guide: http://otland.net/threads/fully-working-healing-bless-guide-npc-saying-random-lines.183507/

i edited this in global.lua also..

getNpcId = getNpcCid < -----------Fixed first problem..
getCreatureStorage = getPlayerStorageValue < -----------same problem
doCreatureSetStorage = setPlayerStorageValue

same.. problem



Cant post correct lua links.. im sorry :p so wont bother with it.. u can look in the thread i linked there u got all XMLs and Luas. used.. :) thanks!

@Limos

better is just using TFS 1.0/1.0 metatable functions instead. If this solves the problem could u explain how to do it? =)

i dont got any compat.lua :p useing printers realmap project
Edit.. Added latest compat.lua and dofile data/compat.lua dont work :p
 
Last edited:
Back
Top