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

Windows Cannot Get My Npc working!

Zaggyzigzig

plx itens menz
Joined
Aug 25, 2014
Messages
386
Reaction score
50
Location
Canada Ontario
Using Avesta 7.6 old school, onkill doesn't work.... heres my files take a look please!
Code:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
      
      
      
        -- OTServ event handling functions start
        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

-- XVX FORGER START --
function mission(cid, message, keywords, parameters, node)
    if(npcHandler.focus ~= cid) then
        return false
    end
        if getPlayerStorageValue(cid, 5002) == -1 then
            npcHandler:say('You have accepted the mission!', cid)
            setPlayerStorageValue(cid,5002,1)
        else
            npcHandler:say('You already have this mission.', cid)
    end
    end

function report(cid, message, keywords, parameters, node)
    if(npcHandler.focus ~= cid) then
        return false
    end
        if getPlayerStorageValue(cid, 19000) == 5 then
            npcHandler:say('Here is your reward', cid)
            doPlayerAddItem(cid, 2152, 80)
            doPlayerAddExp(cid, 2000)
        else
            npcHandler:say('come back when you killed 5 rats. Killed:[' .. (getPlayerStorageValue(cid, 19000)+1) .. '/5] Rats.', cid)
    end  
    end

keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You can claim a Mission, report as mission or leave the mission."})

local node1 = keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hmm, Do you want to go kill 5 rats for me ?'})
    node1:addChildKeyword({'yes'}, mission, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you want this mission.', reset = true})

local node2 = keywordHandler:addKeyword({'report'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You would like to report the mission, have you killed 5 rats?'})
    node2:addChildKeyword({'yes'}, report, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you killed 5 rats.', reset = true})


npcHandler:addModule(FocusModule:new())
 
Last edited by a moderator:
heres my login file


Code:
function onLogin(cid)
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "VipCheck")

    
end

Code:
function onLogin(cid)
if getPlayerPremiumDays(cid) == 0 then
setPlayerStorageValue(cid,30009,-1)
end

    return TRUE
end

03:28 tasks: You would like to report the mission, have you killed 5 rats?
03:29 Rosot: yes
03:29 tasks: come back when you killed 5 rats. Killed:[7/5] Rats.


:<
 
Last edited by a moderator:
You have to register the name of the creaturescript in login.lua, like PlayerDeath and VipCheck.

Use code tags when you post scripts.
[ code]
your script
[/code]
 
If you can overkill creatures, then you'd have to show us your kill-creaturescript file (kill.lua?) for us to help you.

Ignazio
 
In the script, set the amount to 5, you can also do this.
Code:
if getPlayerStorageValue(cid, 19000) >= 5 then
This way it also works if you kill more than 5.
 
Thats the problem we don't got one that was working messed around with it all night trying to get it to work. ended up just adding storage to an item and using it to see if npc was functioning right.
the avesta063"think" he has doesn't seem do register creature events in the monsters file, and its like OnKill or OnDeath does not even work

He had the old file.
Code:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
    
    
    
        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 mission(cid, message, keywords, parameters, node)
    if(npcHandler.focus ~= cid) then
        return false
    end
        if getPlayerStorageValue(cid, 5002) == -1 then
            npcHandler:say('You have accepted the mission!', cid)
            setPlayerStorageValue(cid,5002,1)
        else
            npcHandler:say('You already have this mission.', cid)
    end
    end

function report(cid, message, keywords, parameters, node)
    if(npcHandler.focus ~= cid) then
        return false
    end
        if getPlayerStorageValue(cid, 19000) >= 5 then
            npcHandler:say('You completed the mission and gained +2,000 Experience points and 8,000 gold.', cid)
            doPlayerAddItem(cid, 2152, 80)
            doPlayerAddExp(cid, 2000)
            setPlayerStorageValue(cid, 19000, 0)
        else
            npcHandler:say('come back when you killed 5 rats. Killed:[' .. getPlayerStorageValue(cid, 19000) .. '/5] Rats.', cid)
    end
    end

keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "You can claim a Mission, report as mission or leave the mission."})

local node1 = keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hmm, Do you want to go kill 5 rats for me ?'})
    node1:addChildKeyword({'yes'}, mission, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you want this mission.', reset = true})

local node2 = keywordHandler:addKeyword({'report'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You would like to report the mission, have you killed 5 rats?'})
    node2:addChildKeyword({'yes'}, report, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you killed 5 rats.', reset = true})


npcHandler:addModule(FocusModule:new())

And i used this as i tested files and fought back and forth on Onkill, OnDeath :/
Code:
Onlogin File
    registerCreatureEvent(cid, "Mission")

Creaturescripts
<event type="kill" name="Mission" event="script" value="Rats.lua"/>

Monsters Event line
<script>
    <event name="Mission"/>
    </script>

I Give up tho its bed time!
 
Last edited by a moderator:
Register the kill script on login.lua since the killer (cid) is the player.
Post how it's added and look for errors and if it loads.
You can test if it loads by adding print, a broadcast or textmessage or magiceffect and see if you get it when you kill a monster, if not, the script is not added correct.

Don't register it in the monster file, the killer (cid) is supposed to be a player, not the monster.
 
Code:
local config = {
     ['rat'] = {amount = 5, storage = 19000, 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
 
I know the script, I made it :p

Test if it's loading, you can add a textmessage under function onKill to test it.
It's possible the doesn't have the function isSummon, but you will get an error about that, so then you have to add it or remove that part if the monster can't be a summon.
 
Back
Top