• 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+ How do I add a new channel? Its acting weird prob im dumb

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,832
Solutions
82
Reaction score
1,948
Location
Germany
I have tried to create a new channel and as soon as I try to open it with player:eek:penChannel(9) its not working..

XML:
XML:
<channel id="9" name="Task" public="0" script="task.lua" />

LUA:
Lua:
function canJoin(player)
    return player:getAccountType() >= ACCOUNT_TYPE_NORMAL
end

function onSpeak(player, type, message)
    return type
end

Do I have to regist it somewhere else?
Using tfs 1.5 without client support 12x
 
Solution
are u able to open the channel with player:eek:penChannel() ?
Yep, I used this code to test.
Lua:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(9)
    player:sendChannelMessage("", "Hello. Y", TALKTYPE_CHANNEL_Y, 9)
    player:sendChannelMessage("", "Hello. O", TALKTYPE_CHANNEL_O, 9)
    return true
end

--action:aid(45025)
action:id(2173)
action:register()
View attachment bandicam 2022-01-08 14-46-16-001.mp4
I have tried to create a new channel and as soon as I try to open it with player:eek:penChannel(9) its not working..

XML:
XML:
<channel id="9" name="Task" public="0" script="task.lua" />

LUA:
Lua:
function canJoin(player)
    return player:getAccountType() >= ACCOUNT_TYPE_NORMAL
end

function onSpeak(player, type, message)
    return type
end

Do I have to regist it somewhere else?
Using tfs 1.5 without client support 12x
Are you able to open the channel normally, not through script?

On my TFS 1.4 I installed your code and it's working fine. o.o
 
Are you able to open the channel normally, not through script?

On my TFS 1.4 I installed your code and it's working fine. o.o

I can open it without the script yes but it seems like its not really the channel

we have added print on open channel and it prints out ( Cant be added )

are u able to open the channel with player:eek:penChannel() ?
 
are u able to open the channel with player:eek:penChannel() ?
Yep, I used this code to test.
Lua:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(9)
    player:sendChannelMessage("", "Hello. Y", TALKTYPE_CHANNEL_Y, 9)
    player:sendChannelMessage("", "Hello. O", TALKTYPE_CHANNEL_O, 9)
    return true
end

--action:aid(45025)
action:id(2173)
action:register()
View attachment bandicam 2022-01-08 14-46-16-001.mp4
 
Solution
Yep, I used this code to test.
Lua:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(9)
    player:sendChannelMessage("", "Hello. Y", TALKTYPE_CHANNEL_Y, 9)
    player:sendChannelMessage("", "Hello. O", TALKTYPE_CHANNEL_O, 9)
    return true
end

--action:aid(45025)
action:id(2173)
action:register()
View attachment 64522

For no reason its working for me too now
 
Lua:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(9)
    player:sendChannelMessage("", "Hello. Y", TALKTYPE_CHANNEL_Y, 9)
    player:sendChannelMessage("", "Hello. O", TALKTYPE_CHANNEL_O, 9)
    return true
end

--action:aid(45025)
action:id(2173)
action:register()

how should it be to receive the loot messages in there and not in server log? without source editions for tfs 1.5?
 
Lua:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(9)
    player:sendChannelMessage("", "Hello. Y", TALKTYPE_CHANNEL_Y, 9)
    player:sendChannelMessage("", "Hello. O", TALKTYPE_CHANNEL_O, 9)
    return true
end

--action:aid(45025)
action:id(2173)
action:register()

how should it be to receive the loot messages in there and not in server log? without source editions for tfs 1.5?
Edit: this worked for me 100%
Lua:
local channelId = 11 -- Replace with the actual channel ID
local ec = EventCallback

ec.onDropLoot = function(self, corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 11)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 11)
        end
    end
end
 
Last edited:
Lua:
loot_channel.lua
...sktop\TFS-8.0-7.72 otb-RPG\data\scripts\loot_channel.lua:35: attempt to call global 'addChannelMessageEvent' (a nil value)
stack traceback:
        [C]: in function 'addChannelMessageEvent'
        ...sktop\TFS-8.0-7.72 otb-RPG\data\scripts\loot_channel.lua:35: in main chunk
> loot_channel.lua [error]
i'm using nekiro's downgrade tfs 1.5
Code:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(11)
    player:sendChannelMessage("", "Hello. Y", TALKTYPE_CHANNEL_Y, 11)
    player:sendChannelMessage("", "Hello. O", TALKTYPE_CHANNEL_O, 11)
    return true
end

function onChannelMessage(channelId, player, message)
    if channelId == 11 then
        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end
-- handle the message received on the loot channel
   -- end
--end

addChannelMessageEvent(onChannelMessage)

-- action:aid(45025)
action:id(2173)
action:register()
 
Back
Top