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

TFS 1.X+ NPC changes name with calling function

Mjmackan

Mapper ~ Writer
Premium User
Joined
Jul 18, 2009
Messages
1,424
Solutions
15
Reaction score
177
Location
Sweden
Engine: TFS 1.4
I have several npc's that uses addevent or simply calls for other functions, when using "npchandler:say" the npc talks but changes its name to any other npc I have stored in the npc/xml-folder. I am including everything afaik within the call of other functions, any idéa why this occurs?

Example script: (When this npc follows row: 233 (Kill all monsters first, then we can talk..) it will be outputted as any other npc-name than its own.
This npcs name is 'mere', but it will be shown as: '[Alice]: Kill all monsters first, then we can talk..' for example.
What i want to be shown: '[Mere]: Kill all monsters first, then we can talk..'
Lua:
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
local qStorage = 89001
local answerWrongStorage = 89002

    firstEvent = {}
    secondEvent = {}
    thirdEvent = {}
    fourthEvent = {}
    fifthEvent = {}
 
    local function firstSpawn(player)
        npcHandler:say("Suprise it was! Tell me {ready} when you killed the monsters, so we can continue.",player)
        Game.setStorageValue(qStorage, 2)
        Game.createMonster("werebadger", {x = 1511, y = 1122, z = 7})
        Game.createMonster("werebadger", {x = 1509, y = 1125, z = 7})
     return true
    end
    local function secondSpawn(player)
        npcHandler:say("Suprise here we gooo! Tell me {ready} when you killed the monsters, so we can continue.",cid)
        Game.setStorageValue(qStorage, 3)
        Game.createMonster("werebadger", {x = 1511, y = 1122, z = 7})
        Game.createMonster("werebadger", {x = 1509, y = 1125, z = 7})
        Game.createMonster("werebadger", {x = 1511, y = 1127, z = 7})
        Game.createMonster("werebadger", {x = 1515, y = 1126, z = 7})
     return true
    end
    local function thirdSpawn(player)
        npcHandler:say("Suprise here we gooo! Tell me {ready} when you killed the monsters, so we can continue.",cid)
        Game.setStorageValue(qStorage, 3)
        Game.createMonster("werebadger", {x = 1511, y = 1122, z = 7})
        Game.createMonster("werebadger", {x = 1509, y = 1125, z = 7})
        Game.createMonster("werebadger", {x = 1511, y = 1127, z = 7})
        Game.createMonster("werebadger", {x = 1515, y = 1126, z = 7})
     return true
    end
    local function fourthSpawn(player)
        npcHandler:say("You're a fool, take the consequence! Tell me {ready} when you killed the monsters, so we can continue.",cid)
        Game.setStorageValue(qStorage, 4)
        Game.createMonster("werebadger", {x = 1511, y = 1122, z = 7})
        Game.createMonster("wereboar", {x = 1509, y = 1125, z = 7})
        Game.createMonster("werebadger", {x = 1511, y = 1127, z = 7})
        Game.createMonster("werebadger", {x = 1515, y = 1126, z = 7})
     return true
    end
    local function fifthSpawn(player)
        npcHandler:say("You're a fool, take the consequence! Tell me {ready} when you killed the monsters, so we can continue.",cid)
        Game.setStorageValue(qStorage, 6)
        Game.createMonster("wereboar", {x = 1511, y = 1122, z = 7})
        Game.createMonster("wereboar", {x = 1509, y = 1125, z = 7})
        Game.createMonster("werebadger", {x = 1511, y = 1127, z = 7})
        Game.createMonster("werebadger", {x = 1515, y = 1126, z = 7})
     return true
    end
 
function greet(cid, type, msg)
local player = Player(cid)
 
if (not npcHandler:isFocused(cid)) then return false end
    if Game.getStorageValue(qStorage) == nil then
        Game.setStorageValue(qStorage, 0)
    end
    if Game.getStorageValue(answerWrongStorage) == nil then
        Game.setStorageValue(answerWrongStorage, 0)
    end

 if msgcontains(msg, "ready") and Game.getStorageValue(qStorage) < 1 then
    npcHandler:say("I will ask you 5 questions, you have 10 seconds to answer each question. If you don't answer or answer faulty.. you're up for a suprise!",cid)
    addEvent(function()
        Game.setStorageValue(answerWrongStorage, 1)
        npcHandler:say("First question! 3 + 19 = ",cid)
        Game.setStorageValue(qStorage, 1)
    end, 8000)
    firstEvent[player:getId()] = addEvent(firstSpawn, 18000, player:getId())
 end
 
    if msgcontains(msg, "22") and Game.getStorageValue(qStorage) == 1 then --succeeded question 1
        stopEvent(firstEvent[player:getId()])
            firstEvent[player:getId()] = nil
            npcHandler:say("Well done, maybe a bit too easy right?!",cid)
        addEvent(function()
            npcHandler:say("Second question! Whats the full name of the daily quest npc?",cid)
            Game.setStorageValue(answerWrongStorage, 1)
            Game.setStorageValue(qStorage, 2)
        end, 3500)
        secondEvent[player:getId()] = addEvent(secondSpawn, 13500, player:getId())
    elseif not msgcontains(msg, "22") and Game.getStorageValue(qStorage) == 1 and Game.getStorageValue(answerWrongStorage) == 1 then
        stopEvent(firstEvent[player:getId()])
            firstEvent[player:getId()] = nil
        firstSpawn(player:getId())
        return true
    end
 
    if msgcontains(msg, "ready") and Game.getStorageValue(qStorage) == 2 then --failed question 1
        local mobs = Game.getSpectators({x = 1512, y = 1124, z = 7}, false, false, 4, 4, 4, 4)
            for i = 1, #mobs do
            mob = mobs[i]
            if mob:isMonster() then
                npcHandler:say("Kill all monsters first, then we can talk..",cid)
            return true
            end
        end
            Game.setStorageValue(answerWrongStorage, 2)
            Game.setStorageValue(qStorage, 2)
            npcHandler:say("Second question! Whats the full name of the daily quest npc?",cid)
            secondEvent[player:getId()] = addEvent(secondSpawn, 10000, player:getId())
    end
 
    if msgcontains(msg, "daily octodad") and Game.getStorageValue(qStorage) == 2 or msgcontains(msg, "octodad") and Game.getStorageValue(qStorage) == 2 then --succeeded question 2
        stopEvent(secondEvent[player:getId()])
            secondEvent[player:getId()] = nil
            npcHandler:say("Im almost impressed, we're stepping on to next one okay?",cid)
        addEvent(function()
            npcHandler:say("Third question!! A magical tree can be found in a teleport-room, where does this tree take you?",cid)
            Game.setStorageValue(qStorage, 3)
            Game.setStorageValue(answerWrongStorage, 1)
        end, 4000)
        thirdEvent[player:getId()] = addEvent(thirdSpawn, 14000, player:getId())
    elseif not msgcontains(msg, "daily octodad") and not msgcontains(msg, "octodad") and Game.getStorageValue(qStorage) == 2 and Game.getStorageValue(answerWrongStorage) == 2 then
        stopEvent(secondEvent[player:getId()])
            secondEvent[player:getId()] = nil  
        secondSpawn(player:getId())
        return true
    end

    if msgcontains(msg, "ready") and Game.getStorageValue(qStorage) == 3 then --failed question 2
        local mobs = Game.getSpectators({x = 1512, y = 1124, z = 7}, false, false, 4, 4, 4, 4)
            for i = 1, #mobs do
            mob = mobs[i]
            if mob:isMonster() then
                npcHandler:say("Kill all monsters first, then we can talk..",cid)
            return true
            end
        end
            npcHandler:say("Third question!! A magical tree can be found in a teleport-room, where does this tree take you?",cid)
            Game.setStorageValue(answerWrongStorage, 1)
            Game.setStorageValue(qStorage, 3)
            thirdEvent[player:getId()] = addEvent(thirdSpawn, 10000, player:getId())
    end
 
    if msgcontains(msg, "neverland") and Game.getStorageValue(qStorage) == 3 then --succeeded question 3
        stopEvent(thirdEvent[player:getId()])
            thirdEvent[player:getId()] = nil
            npcHandler:say("Sheeeeeeeshh, you seem educated..",cid)
        addEvent(function()
            npcHandler:say("Fourth! The idea behind Gamefate was created several years ago, which year was first release?",cid)
            Game.setStorageValue(qStorage, 4)
            Game.setStorageValue(answerWrongStorage, 4)
        end, 3000)
        fourthEvent[player:getId()] = addEvent(fourthSpawn, 13000, player:getId())
    elseif not msgcontains(msg, "neverland") and Game.getStorageValue(qStorage) == 3 and Game.getStorageValue(answerWrongStorage) == 3 then
        stopEvent(thirdEvent[player:getId()])
            thirdEvent[player:getId()] = nil      
        thirdSpawn(player:getId())
        return true
    end

    if msgcontains(msg, "ready") and Game.getStorageValue(qStorage) == 4 then --failed question 3
        local mobs = Game.getSpectators({x = 1512, y = 1124, z = 7}, false, false, 4, 4, 4, 4)
            for i = 1, #mobs do
            mob = mobs[i]
            if mob:isMonster() then
                npcHandler:say("Kill all monsters first, then we can talk..",cid)
            return true
            end
        end
            npcHandler:say("Fourth! The idea behind Gamefate was created several years ago, which year was first release?",cid)
            Game.setStorageValue(answerWrongStorage, 4)
            Game.setStorageValue(qStorage, 4)
            fourthEvent[player:getId()] = addEvent(fourthSpawn, 10000, player:getId())
    end
 
    if msgcontains(msg, "2011") and Game.getStorageValue(qStorage) == 4 then --succeeded question 4
        stopEvent(fourthEvent[player:getId()])
            fourthEvent[player:getId()] = nil
            npcHandler:say("I shall remain silent for this one, oh did i talk? sorry..",cid)
        addEvent(function()
            npcHandler:say("Fifth and last question lets go. How many npcs can be found in entire Gamefate city?",cid)
            Game.setStorageValue(answerWrongStorage, 5)
            Game.setStorageValue(qStorage, 5)
        end, 3000)
        fifthEvent[player:getId()] = addEvent(fifthSpawn, 13000, player:getId())
    elseif not msgcontains(msg, "2011") and Game.getStorageValue(qStorage) == 4 and Game.getStorageValue(answerWrongStorage) == 4 then
        stopEvent(fourthEvent[player:getId()])
            fourthEvent[player:getId()] = nil      
        fourthSpawn(player:getId())
        return true
    end
 
    if msgcontains(msg, "ready") and Game.getStorageValue(qStorage) == 5 then --failed question 4
        local mobs = Game.getSpectators({x = 1512, y = 1124, z = 7}, false, false, 4, 4, 4, 4)
            for i = 1, #mobs do
            mob = mobs[i]
            if mob:isMonster() then
                npcHandler:say("Kill all monsters first, then we can talk..",cid)
            return true
            end
        end
        fifthEvent[player:getId()] = addEvent(fifthSpawn, 10000, player:getId())
            npcHandler:say("Fifth and last question lets go. How many npcs can be found in entire Gamefate city?",cid)
            Game.setStorageValue(answerWrongStorage, 5)
            Game.setStorageValue(qStorage, 5)
    end
 
    if msgcontains(msg, "10") and Game.getStorageValue(qStorage) == 5 then
        stopEvent(fourthEvent[player:getId()])
            fourthEvent[player:getId()] = nil
            npcHandler:say("You're definitely experienced enough to continue.",cid)
        addEvent(function()
            npcHandler:say("You may continue onto your journey.",cid)
        Game.setStorageValue(qStorage, 0)
        Game.setStorageValue(answerWrongStorage, 0)
        player:teleportTo({x = 1511, y = 1105, z = 6})
        end, 3000)
    elseif not msgcontains(msg, "10") and Game.getStorageValue(qStorage) == 5 and Game.getStorageValue(answerWrongStorage) == 5 then
        stopEvent(fifthEvent[player:getId()])
            fifthEvent[player:getId()] = nil      
        fifthSpawn(player:getId())
        return true
    end
 
    if msgcontains(msg, "ready") and Game.getStorageValue(qStorage) == 6 then --failed question 5
        local mobs = Game.getSpectators({x = 1512, y = 1124, z = 7}, false, false, 4, 4, 4, 4)
            for i = 1, #mobs do
            mob = mobs[i]
            if mob:isMonster() then
                npcHandler:say("Kill all monsters first, then we can talk..",cid)
            return true
            end
        end
            npcHandler:say("You're definitely experienced enough to continue.",cid)
        addEvent(function()
            npcHandler:say("You may continue onto your journey.",cid)
        Game.setStorageValue(qStorage, 0)
        Game.setStorageValue(answerWrongStorage, 0)
        player:teleportTo({x = 1511, y = 1105, z = 6})
        end, 3000)
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, greet)
npcHandler:addModule(FocusModule:new())
 
Back
Top