Andréew
Humble mapper.
I've read @Limos tutorial/thread " NPC mission " and i did follow it but for some reason it does not work for me. I think i added everything right.
i use 0.3.6 v8.2 cryingdamson
in the creaturescripts xml
and the creaturescrips/scripts/trollmission.lua
then i also added this to the data/lib/050-function.lua
i can speak with the npc and i can accept the quest, but it does not count my kills and i dont get any massage that i've killed 1/25 trolls
when i did kill enough to make the quest i go back to the npc and he says " You haven't killed them all.
here is npc script
i use 0.3.6 v8.2 cryingdamson
in the creaturescripts xml
Code:
<event type="kill" name="troll_mission" event="script" value="trollmission.lua"/>
and the creaturescrips/scripts/trollmission.lua
Code:
local config = {
['troll'] = {amount = 25, storage = 19000, startstorage = 5002, startvalue = 1},
['troll champion'] = {amount = 10, storage = 19001, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) 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
then i also added this to the data/lib/050-function.lua
Code:
function isSummon(cid)
return (isCreature(cid) == TRUE and (getCreatureMaster(cid) ~= cid)) and TRUE or FALSE
end
i can speak with the npc and i can accept the quest, but it does not count my kills and i dont get any massage that i've killed 1/25 trolls
when i did kill enough to make the quest i go back to the npc and he says " You haven't killed them all.
here is npc script
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tomas" script="Tomas.lua" speed="100" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="78" body="20" legs="116" feet="38" addons="1"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|, can you do me a {favor}?"/>
</parameters>
</npc>
Code:
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
local storage = 5002
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, "favor") then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("I have a mission for you, to kill 25 trolls and 10 troll champions, do you accept?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Did you kill 25 trolls and 10 troll champions?", cid)
talkState[talkUser] = 1
else
selfSay("You already did the mission.", cid)
end
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Thank you, the trolls has been harassing this village for to long", cid)
setPlayerStorageValue(cid, storage, 1)
else
if getPlayerStorageValue(cid, 19000) == 5 and getPlayerStorageValue(cid, 19001) == 3 then
selfSay("Good job, here is your reward. go to the anvil at Darnells shop and use this.", cid)
doPlayerAddItem(cid, 2225, 1)
setPlayerStorageValue(cid, storage, 2)
else
selfSay("You didn't kill them all.", cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())