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

Solved NPC kill mission help

highclick

New Member
Joined
Mar 21, 2011
Messages
80
Reaction score
4
TFS 0.3.6

Hey guys! I've followed this guide (http://otland.net/threads/npc-mission.211063/#post-2022378) to create a monster killing quest.

For some reason it won't start the monster count.

Here are my files:

PHP:
    <event type="kill" name="onKill" event="script" value="OnKill.lua"/>


The spider name is actually "Spider [Level 10]" in game.
PHP:
local config = {
     ['Spider [Level 10]'] = {amount = 5, storage = 19002, startstorage = 5003, 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

PHP:
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 injuredcharlie = 1313
local spidercount = 19002
local spiderstart = 5003

function creatureSayCallback(cid, type, msg)
     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if not npcHandler:isFocused(cid) then
        if string.lower(msg) =="hi" or string.lower(msg) == "hello" then
                if getPlayerStorageValue(cid, injuredcharlie) == -1 then -- Om questen inte är påbörjad
                    selfSay("H-{Help} me!", cid)
                    talkState[talkUser] = 1
                elseif getPlayerStorageValue(cid, injuredcharlie) == 1 then -- Om questen är påbörjad
                    selfSay("Did you get me a potion?", cid)
                    talkState[talkUser] = 1
                elseif getPlayerStorageValue(cid, injuredcharlie) == 2 then
                    selfSay("There are to many spiders here! I can't handle them by myself.", cid)
                    selfSay("Will you help me {kill} some of them?", cid)
                    talkState[talkUser] = 1
                elseif getPlayerStorageValue(cid, injuredcharlie) == 3 then
                    if getPlayerStorageValue(cid, spidercount) >= 5 then
                    selfSay("You completed the quest biatch", cid)
                    setPlayerStorageValue(cid, injuredcharlie, 3)
                    npcHandler:releaseFocus(cid)
                    elseif getPlayerStorageValue(cid, spidercount) < 5 then
                    selfSay("You didn't kill them all", cid)
                    npcHandler:releaseFocus(cid)
                    end
                else
                    selfSay("Thank you for the help!", cid)
                    npcHandler:releaseFocus(cid)
                end
                npcHandler:addFocus(cid)
        else
            return false
        end
       
    end

    if string.lower(msg) =="help" or string.lower(msg) == "yes" or string.lower(msg) == "kill" and talkState[talkUser] == 1 then
            if getPlayerStorageValue(cid, injuredcharlie) == -1 then
                selfSay("I'm weak... Will you get me a health potion?", cid) -- Om du säger "help".
                talkState[talkUser] = 2
            elseif getPlayerStorageValue(cid, injuredcharlie) == 1 then
                if doPlayerRemoveItem(cid, 7618, 1) then
                    selfSay("Thank you!", cid)
                    doPlayerAddItem(cid, 2160, 3)
                    doPlayerAddExp(cid, 5000)
                    setPlayerStorageValue(cid, injuredcharlie, 2)
                    npcHandler:releaseFocus(cid)
                else
                    selfSay("You don't have a potion, come back when you have one", cid)
                    npcHandler:releaseFocus(cid)
                end
            elseif getPlayerStorageValue(cid, injuredcharlie) == 2 then
                    selfSay("Thank you. Please kill 5 spiders and return to me!", cid)
                    setPlayerStorageValue(cid, injuredcharlie, 3)
                    setPlayerStorageValue(cid, spiderstart, 1)
                    npcHandler:releaseFocus(cid)
            end
    end
   
    if string.lower(msg) =="yes" and talkState[talkUser] == 2 then
        selfSay("Thank you, I'll wait here!", cid)
        setPlayerStorageValue(cid, injuredcharlie, 1)
        npcHandler:releaseFocus(cid)
    end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)


Any ideas?
 
Add this in login.lua, where the other registerCreatureEvent lines are.
Code:
registerCreatureEvent(cid, "onKill")

For next creaturescripts, you have to register the name you choose, which is onKill atm.
Code:
name="onKill"
 
Add this in login.lua, where the other registerCreatureEvent lines are.
Code:
registerCreatureEvent(cid, "onKill")

For next creaturescripts, you have to register the name you choose, which is onKill atm.
Code:
name="onKill"

Alright, I'm getting somewhere!

I'm getting an error in the cosole. Unfortunately the error spams so i cannot copy it.

something about " attempt to call global 'isSummon' (a nil value)
 
Add functions in data/lib/050-functions.lua, global.lua is the lib file in TFS 0.2, several older versions and TFS 1.x.
 
Add functions in data/lib/050-functions.lua, global.lua is the lib file in TFS 0.2, several older versions and TFS 1.x.

Okay! The function is inserted and the error is gone. However i get no message while killing spiders nor can i finish the quest. So something is still wrong

BUMP

Nobody knows a fix for this??
 
Last edited by a moderator:
Back
Top