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

Killing monster quest help

Andréew

Humble mapper.
Joined
Apr 14, 2015
Messages
833
Solutions
2
Reaction score
1,929
Location
Sweden
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
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())
 
Shouldn't the start value be set to -1, since the return value of an empty or 1st time storage value returns -1?

Edit: nvm
 
Did you register the creature event in login.lua? (data/creaturescripts/scripts/login.lua)
What exactly doesn't work?
 
Then yeah, it's most likely not registered.
(Just woke up.. that was so much derp. :()
 
ah maybe you are right Xikini, but what should i add in login.lua?

registerCreatureEvent(cid, "???????")
sorry for being noobish, to tierd to think right now
 
ah maybe you are right Xikini, but what should i add in login.lua?

registerCreatureEvent(cid, "???????")
sorry for being noobish, to tierd to think right now
Code:
<event type="kill" name="troll_mission" event="script" value="trollmission.lua"/>
Use the name value from your creaturescripts.xml
Code:
registerCreatureEvent(cid, "Insert Name Here")
 
Yeah i did add that late last night but it still does not work, i will take a good look at it when i get home! If i fugure it out i will post the solution if anyone else is having this problem :) or maybe i need some help with it since im no expert on this script things.
 
Back
Top