• 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 make certains npc talk in default channel instead of npcs

ForgottenNot

Banned User
Joined
Feb 10, 2023
Messages
303
Reaction score
29
HI

as title says would like that certains npcs have the old talk behavior example boats by that i mean talk in default chat channel, is this possible ? if so how? i use canary 13.x
or makes npcs able to talk with only one person so in that case players will be force to use bring me to function in these cases or scenarios

thank you
 
okey i've been able to make npcs reply in default channel i changed in npc.lua TALKTYPE_PRIVATE_NP TO TALKTYPE_SAY

LUA:
-- Npc send message to player
-- npc:sendMessage(text)
function Npc:sendMessage(player, text)
    return self:say(string.format(text or "", player:getName()), TALKTYPE_SAY, true, player)
end

function Npc:sayWithDelay(npcId, text, messageType, delay, eventDelay, player)
    eventDelay.done = false
    eventDelay.event = addEvent(sayFunction, delay < 1 and 1000 or delay, npcId, text, messageType, eventDelay, player)
end

function SayEvent(npcId, playerId, messageDelayed, npcHandler, textType)
    local npc = Npc(npcId)
    if not npc then
        return logger.error("[{} NpcHandler:say] - Npc parameter for npc '{}' is missing, nil or not found", npc:getName(), npc:getName())
    end

    local player = Player(playerId)
    if not player then
        return logger.error("[{} NpcHandler:say] - Player parameter for npc '{}' is missing, nil or not found", npc:getName(), npc:getName())
    end

    local parseInfo = {
        [TAG_PLAYERNAME] = player:getName(),
        [TAG_TIME] = getFormattedWorldTime(),
        [TAG_BLESSCOST] = Blessings.getBlessingsCost(player:getLevel(), false),
        [TAG_PVPBLESSCOST] = Blessings.getPvpBlessingCost(player:getLevel(), false),
    }
    npc:say(npcHandler:parseMessage(messageDelayed, parseInfo), textType or TALKTYPE_SAY, false, player, npc:getPosition())
end

function GetCount(string)
    local b, e = string:find("%d+")
    return b and e and tonumber(string:sub(b, e)) or -1
end
in npc_handler.lua
Code:
            -- The "self.talkDelayTimeForOutgoingMessages * 1000" = Interval for sending subsequent messages from the first
            local parsedMessage = self:parseMessage(msgs[messagesTable], parseInfo, player, messageString)
            npc:sayWithDelay(npcUniqueId, parsedMessage, TALKTYPE_SAY, ((messagesTable - 1) * self.talkDelay + self.talkDelayTimeForOutgoingMessages * 1000), self.eventDelayedSay[playerId][messagesTable], playerUniqueId)
            ret[#ret + 1] = self.eventDelayedSay[playerId][messagesTable]
        end
        return ret
    end
and here in npc_functions.cpp
Code:
    SpeakClasses type = getNumber<SpeakClasses>(L, 3, TALKTYPE_SAY);
    const std::string &text = getString(L, 2);
    std::shared_ptr<Npc> npc = getUserdataShared<Npc>(L, 1);
    if (!npc) {
        lua_pushnil(L);
        return 1;

the npcs are talking in default channel but if i say trade or other they wont do anything so they are not working doe snot even reply on bye just the first hi. no errors in console
. also i would like to make only few npcs talk in default channel not all them. in this case only boat and carpets npcs
would be this possible?
Post automatically merged:

Untitled.webp
 

Attachments

Back
Top