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:
and in login.lua
and in creature.xml
my server version in TFS: 0.3.6
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