Ray Rewind
Doctor
NPC lua.
NPC SCRIPT
Creaturescript not registered in login.lua
Problem : NPC DOES NOT RESPONDS TO ANYTHING!
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!