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

Problem with task count

someusername

New Member
Joined
Feb 14, 2013
Messages
24
Reaction score
1
Hello i've found a daily task script on the forum and the npc didnt respond on player first i have fixed that but i have no idea how i fix the kill count i do not get any bug at all but it doesnt count aswel


creature script:
PHP:
local config = {
  [{1, 300}] = {
    {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())


and in login.lua

PHP:
    registerCreatureEvent(cid, "DailyMonsterKill")

and in creature.xml
PHP:
<event type="kill" name="DailyMonsterKill" event="script" value="dailymonsterkill.lua"/>

my server version in TFS: 0.3.6
 
Post the creaturescript (the script with function onKill), the script you posted is an npc.

oh damn i posted the wrong one fail:oops:

PHP:
local config = {
     ['wolf'] = {amount = 25, storage = 50},
     ['minotaur'] = {amount = 50, storage = 60},
     ['cyclops'] = {amount = 75, storage = 70},
     ['dragon'] = {amount = 100, storage = 80}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster then
         return true
     end

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) == monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end

i will edit the monsters later but need to have the count fixed first ;p
 
There is no startstorage and startvalue in the table.
http://otland.net/threads/npc-mission.211063/#post-2022378

The startstorage and startvalue should be from the npc, when it gives you the mission.

PHP:
local config = {
     ['wolf'] = {amount = 25, storage = 50, startstorage = 5002, startvalue = 1},
     ['minotaur'] = {amount = 50, storage = 60, startstorage = 5002, startvalue = 1},
     ['cyclops'] = {amount = 75, storage = 70, startstorage = 5002, startvalue = 1},
     ['dragon'] = {amount = 100, storage = 80, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster then
         return true
     end

     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) == monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end

what do i need to add next to make it work :)
 
The storage in the creaturescript is the storage number, not the value, in the npc it's the value. The startstorage and startvalue you choose should be set in the npc, you can do it the same as the monster storage, since it's set when the mission starts.
 
The storage in the creaturescript is the storage number, not the value, in the npc it's the value. The startstorage and startvalue you choose should be set in the npc, you can do it the same as the monster storage, since it's set when the mission starts.

omg im really stupid it just cant understand what i need to do im sorry
 
Back
Top