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

CreatureEvent [TFS 1.x] Custom Chat Channels (Name, Text + Open onLogin)

Eldin

Eldin Projects
Premium User
Joined
Jun 12, 2008
Messages
1,334
Reaction score
613
Location
Sweden
Greets,

Tested with TFS 1.1

Making your server feel more custom in big ways but also in smaller detailed ways is an important aspect from my side as a developer. These scripts will give you the option to make your own named chat channels, your custom text when they are opened instead of real tibias as well as forcing your players to have them open onLogin to use them.

ChatChannel_zps7eifb99x.png


chatchannels.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
 <channel id="10" name="ServerName" public="1" script="mainchannel.lua" />
</channels>

I recommend you to start from channel id="10" and up on custom channels as lower might force you with Real Tibia Text, unless you want it ofcourse. If you want real tibias text you could simply try channel ids 1-7 and just change the channel name, name="ServerName".

mainchannel.lua
Code:
local function sendMessage(cid)
  local player = Player(cid)
  if not player then
  return false
  end
  
  player:sendChannelMessage("", "Welcome to the Main Channel.\nHere you can advertise all kinds of things. Among others, advertise ingame events, seek characters for a quest or a hunting group, find members for your guild or look for somebody to help you with something.", TALKTYPE_CHANNEL_O, 10)
end

function onJoin(player)
  addEvent(sendMessage, 100, player:getId())
  return true
end

function onSpeak(player, type, message)
 local playerAccountType = player:getAccountType()
 if player:getLevel() == 1 and playerAccountType < ACCOUNT_TYPE_GAMEMASTER then
 player:sendCancelMessage("You may not speak into channels as long as you are on level 1.")
 return false
 end

 if type == TALKTYPE_CHANNEL_Y then
 if playerAccountType >= ACCOUNT_TYPE_GAMEMASTER then
 type = TALKTYPE_CHANNEL_O
 end
 elseif type == TALKTYPE_CHANNEL_O then
 if playerAccountType < ACCOUNT_TYPE_GAMEMASTER then
 type = TALKTYPE_CHANNEL_Y
 end
 elseif type == TALKTYPE_CHANNEL_R1 then
 if playerAccountType < ACCOUNT_TYPE_GAMEMASTER and not getPlayerFlagValue(player, PlayerFlag_CanTalkRedChannel) then
 type = TALKTYPE_CHANNEL_Y
 end
 end
 return type
end

Remember to change this if you create another channel:
"TALKTYPE_CHANNEL_O, 10" where 10 = channelID.


Now we'll force our players to open our chosen chat-channels everytime they login.

creaturescripts.xml
Code:
 <event type="login" name="ChatChannels" script="chatchannels.lua"/>

chatchannels.lua
Code:
function onLogin(cid)
local player = Player(cid)
  player:openChannel(10)
  return true
end

Simply add Another line of "player: openChannel(WantedNumber)" if you want to have them open another chat channel.

Good luck and have a nice day.

Kind Regards,
Eldin.
 
How do you do so the channel never closes? Even if you try to close it (ctrl+e) it reopens.
 
How do you do so the channel never closes? Even if you try to close it (ctrl+e) it reopens.
You can't make a "permanent" channel serversided, but you can -re-open the desired channel when the player closes it (Using the onLeave() function).
 
Back
Top