• 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!

Lua Daily Task NPC do not answer!

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,348
Reaction score
75
Location
Germany
NPC lua.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Daily Task NPC" nameDescription="The Tasker" script="daily.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="142" head="43" body="124" legs="125" feet="57" addons="2"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. I have tasks for you to do!"/>
        <parameter key="message_decline" value="Goodbye!"/>
    </parameters>
</npc>

NPC SCRIPT


Code:
local config = {
  [{1, 30}] = {
    {name = "Wolf", storage = 50, count = 25, exp = 2000, item = 2152, icount = 25, chance = 75},
    {name = "Minotaur", storage = 60, count = 50, exp = 4000, item = 2152, icount = 45, chance = 75},
    {name = "Cyclop", storage = 70, count = 75, exp = 6000, item = 2152, icount = 50, chance = 75},
    {name = "Dragon", storage = 80, count = 100, exp = 60000, item = 2160, icount = 1, chance = 75},
    {name = "Dragon Lord", storage = 90, count = 250, exp = 120000, item = 2160, icount = 5, chance = 75},
    {name = "Hellfire Fighter", storage = 100, count = 120, exp = 150000, item = 2160, icount = 7, chance = 75},
    {name = "Demon", storage = 110, count = 150, exp = 230000, item = 2160, icount = 10, chance = 75}
  }
}


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, 'daily')) then
if getPlayerStorageValue(cid,2423) <= 1 then
local lv = getPlayerLevel(cid)
for level, tasks in pairs(config) do
if lv >= level[1] and lv < level[2] then
local randomTask = tasks[math.random(#tasks)]
selfSay('Your mission for today is to kill ' .. randomTask.count .. ' ' .. randomTask.name .. '\'s. Back when you end.', cid)
setPlayerStorageValue(cid, 2423, randomTask.storage)
break
end
end
elseif getPlayerStorageValue(cid,2423) == 100 then
selfSay('You have completed your mission for today! Come back tomorrow!', cid)
return true
else
local taskID = getPlayerStorageValue(cid, 2423)
local killed = getPlayerStorageValue(cid, 2425)
for level, tasks in pairs(config) do
for k, t in pairs(tasks) do
if t.storage == taskID then
if killed >= t.count then
selfSay('Excellent! You have done your mission for today!', cid)
doPlayerAddExp(cid, t.exp)
setPlayerStorageValue(cid, 2423, 100)
if math.random(100) <= t.chance then
doPlayerAddItem(cid, t.item, t.icount)
end
else
selfSay('You did not kill enough ' .. t.name .. '\'s yet.', cid)
end
return true
end
end
end
end
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Creaturescript not registered in login.lua

Code:
local config = {
  ["wolf"] = {storage = 50, count = 25},
  ["minotaur"] = {storage = 60, count = 50},
  ["cyclop"] = {storage = 70, count = 75},
  ["dragon"] = {storage = 80, count = 100},
  ["dragon lord"] = {storage = 90, count = 250},
  ["hellfire fighter"] = {storage = 100, count = 120},
  ["demon"] = {storage = 110, count = 150}
}


function onKill(cid, target, lastHit)
local creature, task, kills = config[getCreatureName(target):lower()], getPlayerStorageValue(cid, 2423), getPlayerStorageValue(cid, 2425)
local function isSummon(cid)
return getCreatureMaster(cid) ~= cid or false
end
if creature and lastHit then
if isPlayer(target) or isSummon(target) then return true end
if task == creature.storage then
setPlayerStorageValue(cid, 2425, kills + 1)
if kills < creature.count then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Daily Quest: You have killed " .. getCreatureName(target) .. " [" .. kills .. "/" .. creature.count.."]")
elseif kills == creature.count then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Daily Quest: You have killed the last " .. getCreatureName(target) .. ", go back to NPC and report.")
end
end
end
return true
end


Problem : NPC DOES NOT RESPONDS TO ANYTHING!
 
22:24 Dantez [22]: daily
22:24 Tasks: Your mission for today is to kill 150 Demon's. Back when you end.

22:27 Dantez [22]: daily
22:27 Tasks: You did not kill enough Demon's yet.

22:28 Dantez [22]: daily
22:28 Tasks: Excellent! You have done your mission for today!

22:29 Dantez [29]: daily
22:29 Tasks: You have completed your mission for today! Come back tomorrow!

Works fine for me. Added some tabs:

Code:
local config = {
    [{1, 30}] = {
        {name = "Wolf", storage = 50, count = 25, exp = 2000, item = 2152, icount = 25, chance = 75},
        {name = "Minotaur", storage = 60, count = 50, exp = 4000, item = 2152, icount = 45, chance = 75},
        {name = "Cyclop", storage = 70, count = 75, exp = 6000, item = 2152, icount = 50, chance = 75},
        {name = "Dragon", storage = 80, count = 100, exp = 60000, item = 2160, icount = 1, chance = 75},
        {name = "Dragon Lord", storage = 90, count = 250, exp = 120000, item = 2160, icount = 5, chance = 75},
        {name = "Hellfire Fighter", storage = 100, count = 120, exp = 150000, item = 2160, icount = 7, chance = 75},
        {name = "Demon", storage = 110, count = 150, exp = 230000, item = 2160, icount = 10, chance = 75}
    }
}

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 taskID = getPlayerStorageValue(cid, 2423)
  
    if(msgcontains(msg, 'mission') or msgcontains(msg, 'daily')) then
        if taskID <= 1 then
            local lvl = getPlayerLevel(cid)
            for level, tasks in pairs(config) do
                if lvl >= level[1] and lvl <= level[2] then
                    local randomTask = tasks[math.random(#tasks)]
                    selfSay('Your mission for today is to kill ' .. randomTask.count .. ' ' .. randomTask.name .. '\'s. Back when you end.', cid)
                    setPlayerStorageValue(cid, 2423, randomTask.storage)
                    break
                end
            end
        elseif taskID == 100 then
            selfSay('You have completed your mission for today! Come back tomorrow!', cid)
            return true
        else
            local killed = getPlayerStorageValue(cid, 2425)
            for level, tasks in pairs(config) do
                for k, t in pairs(tasks) do
                    if t.storage == taskID then
                        if killed >= t.count then
                            selfSay('Excellent! You have done your mission for today!', cid)
                            doPlayerAddExp(cid, t.exp)
                            setPlayerStorageValue(cid, 2423, 100)
                            if math.random(100) <= t.chance then
                                doPlayerAddItem(cid, t.item, t.icount)
                            end
                        else
                            selfSay('You did not kill enough ' .. t.name .. '\'s yet.', cid)
                        end
                        return true
                    end
                end
            end
        end
    end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And it's bugged with Hellfire Fighter task, the same storage ID - 100.
 
Last edited:
any console error, do you try print test text on console?
print("test 1")
look on database on your player storage value on player_storage table? id player can you take from player table
 
Back
Top