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

NPC adding achievement

Crunch

Member
Joined
Jun 21, 2011
Messages
353
Reaction score
19
Location
England
Hello.. again!

I have got an issue trying to get an NPC to give an achievement when a player has completed a quest. I have tried both the normal player:addachievement, and also added the old doPlayerAddAchievement. This is my console error, the npc worked fine but adding an achievement at the same time he gives the outfits brings this error. Like with most of my problems, this script was made some years ago so not sure if theres something I need to add somewhere. Any help would be appreciated, thanks again

1607093529022.png
 
Last edited:
would you share your achievements lib modifications and the npc you trying to do? with this information we barely can do something
 
I have changed the console error as I posted the wrong one, this is my npc with no achievement changes, using TFS 1.3
Lua:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
function onCreatureAppear(player) npcHandler:onCreatureAppear(player) end 
function onCreatureDisappear(player) npcHandler:onCreatureDisappear(player) end 
function onCreatureSay(player, type, msg) npcHandler:onCreatureSay(player, type, msg) end 
function onThink() npcHandler:onThink() end 
function creatureSayCallback(player, type, msg) 
    if(not npcHandler:isFocused(player)) then 
        return false 
    end

        
        
    if msgcontains(msg:lower(), 'mission') then
        if isPremium(player) then --May not work in TFS 0.3.6. If not, use 'if getPlayerPremiumDays(player) > 0 then'.
            if getPlayerStorageValue(player,1259) < 1 then
                selfSay('Why indeed I have a mission you can do. I would love it if you could rid these lands of some of the {Demonic Monsters} that roam here.', player)
            elseif getPlayerStorageValue(player,1257) == 1 then
               selfSay('Please bring me 3000 Demonic Essence so I can start my research.', player)
            elseif getPlayerStorageValue(player,1258) == 1 then
                selfSay('Please bring me 3000 Demonic Essense so I can complete my research.', player)                
            elseif getPlayerStorageValue(player,1259) == 2 then
                selfSay('Why yes I do have a further mission for you. I need another 3000 Demonic Essence to complete my research. Will you be able to get them for me?', player)
                topic = 3
            elseif getPlayerStorageValue(player,1259) == 4 then
                selfSay('Thank you for all you have done, my research will be finished soon, and I can begin fighting against these evil creatures.', player)
            end
        else
            selfSay('You must be premium to find out more.', player)         
        end          
    elseif msgcontains(msg:lower(), 'monster') then
        selfSay('These monsters drop Demonic Essence. I require these to understand the evil powers that these creatures bare, and try to find a way to protect against them. Will you gather these for me?', player)
        topic = 1
    elseif msgcontains(msg:lower(), 'yes') and topic == 1 then
        selfSay('Great. I will require 3000 Demonic Essense to get me research going. Please bring these to me and I will get a reward ready for you.', player)                
        setPlayerStorageValue(player,1257,1)
        setPlayerStorageValue(player,1259,1)
        setPlayerStorageValue(player,5008,1)
    elseif msgcontains(msg:lower(), 'demonic') then
            if getPlayerStorageValue(player,1257) == 1 then
                selfSay('Did you bring me 3000 Demonic Essence?', player)
                topic = 2
            else  
                if getPlayerStorageValue(player,1258) == 1 then
                selfSay('Did you bring me 3000 Demonic Essence?', player)
                topic = 4
                end
            end
    elseif msgcontains(msg:lower(), 'yes') and topic == 2 then 
        if getPlayerItemCount(player,6500) >= 3000 then             
            doPlayerRemoveItem(player,6500,3000)
            setPlayerStorageValue(player,1259,1)
            setPlayerStorageValue(player,1257,2)
            selfSay('Ooo I can sense the evil from here! This will certainly get my research going. Please take this outfit. The ancient and evil Nightmare Nights used to wear it. I found it buried beneath the temple.. Must of been from when they attacked us! Come and see my again, I may have a further mission.', player)
         
        else   
            selfSay('You do not have 3000 Demonic Essence!', player)
            topic = 0
        end     

        if getPlayerStorageValue(player,1259) == 1 and getPlayerStorageValue(player,1257) == 2 then
            doSendMagicEffect(getPlayerPosition(player), 29)       
            doPlayerAddOutfit(player, 268, 3)
            doPlayerAddOutfit(player, 269, 3)
            setPlayerStorageValue(player,1259,2)
            setPlayerStorageValue(player,5008,2)    
            player:addAchievement("Nightmare Walker")
        end    
    elseif msgcontains(msg:lower(), 'yes') and topic == 3 then
        selfSay('Marvelous! While you collect these, I will train this monster I captured so your able to ride on it. I trust this will satisfy as a reward!', player)
        setPlayerStorageValue(player,1258,1)
        setPlayerStorageValue(player,5009,1)

    elseif msgcontains(msg:lower(), 'yes') and topic == 4 then              
        if getPlayerItemCount(player,6500) >= 3000 then             
            doPlayerRemoveItem(player,6500,3000)
            setPlayerStorageValue(player,1259,3)
            setPlayerStorageValue(player,1258,2)
        end
        if getPlayerStorageValue(player,1259) == 3 and getPlayerStorageValue(player,1258) == 2 then
            doSendMagicEffect(getPlayerPosition(player), 30)       
            doPlayerAddMount(player, 104)
            setPlayerStorageValue(player,1259,4)
            setPlayerStorageValue(player,5009,2)
            player:addAchievement("A Total Nightmare")
            selfSay('Excellent, my research will soon be complete! This monster is now fully trained, please take it as a thank you for all your hard work.', player)
        else
            selfSay('You don\'t have the 3000 Demonic Essence I require!', player)
            topic = 0
        end    
    end      
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
you mixing code, try to use some compat function for that achievement call if there is any or just try something like
Player(player):addAchievement("A Total Nightmare") instead of what you have.

Btw, is this TFS 1.something? otherwise Im writing nonsense
 
Yes its TFS 1.3, the Player(player) gave the same error, I'm not sure how I could use the compat in all honesty, hence me being here
 
Can you try if it will work on an action script or movement script instead of NPC? Only this one.
Lua:
player:addAchievement("A Total Nightmare")
 
Back
Top