• 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+ MESSAGE_WALKAWAY In NPCs channel

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
Hi
How to send
[MESSAGE_IDLETIMEOUT] = "Good bye.",
[MESSAGE_WALKAWAY] = "Good bye.",
in NPCs channel instead of default chat?
 
Solution
Well then you have different code, because that gif was taken just before i posted it, after testing on my server.
Post the code you had for the function NpcHandler: onThink().

also post the code you have for then functions.
unGreet
and onWalkAway


Lua:
 function NpcHandler:onThink()
        local callback = self:getCallback(CALLBACK_ONTHINK)
        if callback == nil or callback() then
            if NPCHANDLER_TALKDELAY == TALKDELAY_NONE then
                for cid, talkDelay in pairs(self.talkDelay) do
                    if talkDelay.time ~= nil and talkDelay.message ~= nil and os.time() >= talkDelay.time then
                        selfSay(talkDelay.message, cid, talkDelay.publicize and true or false)...
try changing this values.
selfSay(message_female), selfSay(message_male) and selfSay(message)
you can found them at npchandler.lua inside libs
with something like

Lua:
if player then
   self:say(message_female, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
end
 
try changing this values.
selfSay(message_female), selfSay(message_male) and selfSay(message)
you can found them at npchandler.lua inside libs
with something like

Lua:
if player then
   self:say(message_female, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
end
Then it never applies walkaway function and it gives attempt to call function getposition error
Lua:
    function NpcHandler:onWalkAway(cid)
        if self:isFocused(cid) then
            local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
            if callback == nil or callback() then
                if self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid) then
                    local msg = self:getMessage(MESSAGE_WALKAWAY)

                    local player = Player(cid)
                    local playerName = player and player:getName() or -1
                    local playerSex = player and player:getSex() or 0

                    local parseInfo = { [TAG_PLAYERNAME] = playerName }
                    local message = self:parseMessage(msg, parseInfo)

                    local msg_male = self:getMessage(MESSAGE_WALKAWAY_MALE)
                    local message_male = self:parseMessage(msg_male, parseInfo)
                    local msg_female = self:getMessage(MESSAGE_WALKAWAY_FEMALE)
                    local message_female = self:parseMessage(msg_female, parseInfo)
                    if message_female ~= message_male then
                        if playerSex == PLAYERSEX_FEMALE then
                        self:say(message_female, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
                        else
                         self:say(message_male, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
                        end
                    elseif message ~= "" then
                        self:say(message, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
                    end
                    self:resetNpc(cid)
                    self:releaseFocus(cid)
                end
            end
        end
    end
 
The 'this is pretty close to the error' doesn't really help. xD

Based on the info, it seems that you are attempting to use a function that doesn't exist in your server.
Check to see if there is a similar function, and replace that part in your script.

or, y'know post the actual error, and the scripts you are using
 
The 'this is pretty close to the error' doesn't really help. xD

Based on the info, it seems that you are attempting to use a function that doesn't exist in your server.
Check to see if there is a similar function, and replace that part in your script.

or, y'know post the actual error, and the scripts you are using
You've got to change some line or something like that.
actual error (Floods in console non-stop)
Untitled.png

Exact script
Lua:
    function NpcHandler:onWalkAway(cid)
        if self:isFocused(cid) then
            local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
            if callback == nil or callback() then
                if self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid) then
                    local msg = self:getMessage(MESSAGE_WALKAWAY)

                    local player = Player(cid)
                    local playerName = player and player:getName() or -1
                    local playerSex = player and player:getSex() or 0

                    local parseInfo = { [TAG_PLAYERNAME] = playerName }
                    local message = self:parseMessage(msg, parseInfo)

                    local msg_male = self:getMessage(MESSAGE_WALKAWAY_MALE)
                    local message_male = self:parseMessage(msg_male, parseInfo)
                    local msg_female = self:getMessage(MESSAGE_WALKAWAY_FEMALE)
                    local message_female = self:parseMessage(msg_female, parseInfo)
                    if message_female ~= message_male then
                        if playerSex == PLAYERSEX_FEMALE then
                        self:say(message_female, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
                        else
                         self:say(message_male, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
                        end
                    elseif message ~= "" then
                        self:say(message, TALKTYPE_PRIVATE_NP, false, player, self:getPosition())
                    end
                    self:resetNpc(cid)
                    self:releaseFocus(cid)
                end
            end
        end
    end
Whole npchandler
[Lua] if NpcHandler == nil then -- Constant talkdelay behaviors. TALKDELAY_NONE = - Pastebin.com
 
npchandler.lua

put at top:
Lua:
local useNpc = true

line 528:
Lua:
self:onWalkAway(focus)

replace with
Lua:
if useNPC then
   self:unGreet(focus)
else
  self:onWalkAway(focus)
end

HZqRG1k.gif
 
Well then you have different code, because that gif was taken just before i posted it, after testing on my server.
Post the code you had for the function NpcHandler: onThink().

also post the code you have for then functions.
unGreet
and onWalkAway


Lua:
 function NpcHandler:onThink()
        local callback = self:getCallback(CALLBACK_ONTHINK)
        if callback == nil or callback() then
            if NPCHANDLER_TALKDELAY == TALKDELAY_NONE then
                for cid, talkDelay in pairs(self.talkDelay) do
                    if talkDelay.time ~= nil and talkDelay.message ~= nil and os.time() >= talkDelay.time then
                        selfSay(talkDelay.message, cid, talkDelay.publicize and true or false)
                        self.talkDelay[cid] = nil
                    end
                end
            end
            if self:processModuleCallback(CALLBACK_ONTHINK) then
                for pos, focus in pairs(self.focuses) do
                    if focus ~= nil then
                        if not self:isInRange(focus) then
                           self:unGreet(focus)  -- self:onWalkAway(focus)
                        elseif self.talkStart[focus] ~= nil and (os.time() - self.talkStart[focus]) > self.idleTime then
                            self:unGreet(focus) -- here
                        else
                            self:updateFocus()
                        end
                    end
                end
            end
        end
    end
 
Last edited:
Solution
Well then you have different code, because that gif was taken just before i posted it, after testing on my server.
Post the code you had for the function NpcHandler: onThink().

also post the code you have for then functions.
unGreet
and onWalkAway
Lua:
    function NpcHandler:onThink()
        local callback = self:getCallback(CALLBACK_ONTHINK)
        if callback == nil or callback() then
            if NPCHANDLER_TALKDELAY == TALKDELAY_NONE then
                for cid, talkDelay in pairs(self.talkDelay) do
                    if talkDelay.time ~= nil and talkDelay.message ~= nil and os.time() >= talkDelay.time then
                        selfSay(talkDelay.message, cid, talkDelay.publicize and true or false)
                        self.talkDelay[cid] = nil
                    end
                end
            end

            if self:processModuleCallback(CALLBACK_ONTHINK) then
                for pos, focus in pairs(self.focuses) do
                    if focus ~= nil then
                        if not self:isInRange(focus) then
                            self:onWalkAway(focus) -- here
                        elseif self.talkStart[focus] ~= nil and (os.time() - self.talkStart[focus]) > self.idleTime then
                            self:unGreet(focus) -- here
                        else
                            self:updateFocus()
                        end
                    end
                end
            end
        end
    end
 
Thats the exact same code I have and it works, did you restart the server after editing the code?
I think you can do it with a reload of /reload global, /reload config
But i restarted the whole server.

Lua:
    function NpcHandler:onThink()
        local callback = self:getCallback(CALLBACK_ONTHINK)
        if callback == nil or callback() then
            if NPCHANDLER_TALKDELAY == TALKDELAY_NONE then
                for cid, talkDelay in pairs(self.talkDelay) do
                    if talkDelay.time ~= nil and talkDelay.message ~= nil and os.time() >= talkDelay.time then
                        selfSay(talkDelay.message, cid, talkDelay.publicize and true or false)
                        self.talkDelay[cid] = nil
                    end
                end
            end
            if self:processModuleCallback(CALLBACK_ONTHINK) then
                for pos, focus in pairs(self.focuses) do
                    if focus ~= nil then
                        if not self:isInRange(focus) then
                           self:unGreet(focus)  -- self:onWalkAway(focus) 
                        elseif self.talkStart[focus] ~= nil and (os.time() - self.talkStart[focus]) > self.idleTime then
                            self:unGreet(focus) -- here
                        else
                            self:updateFocus()
                        end
                    end
                end
            end
        end
    end
 
Back
Top