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

Lua Every time you enter the game open GAME CHAT, HELP and TRADE

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
How do I get it every time that players enter the server open the channels of talk to them (HELP, GAME CHAT, TRADE)?

0.4 (8.60)

channels.xml
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<!-- README:
0 - dynamic, reserved for guilds
1 - always acts as Party channel, only "name" tag available
3 - always acts as Rule Violations channel
9 - acts as Help channel- clientsided message
65535 - DO NOT CHANGE THE ID- only "name", "enabled", "active" and "logged" tags available
-->
<channel id="1" name="Party"/>
<channel id="2" name="Staff" access="3"/>
<channel id="3" name="Rule Violations" logged="yes"/>
<channel id="4" name="Counselor" access="1"/>
<channel id="5" name="Game-Chat" level="2"/>
<channel id="6" name="Trade" level="8" muted="120" conditionId="2" conditionMessage="You may only place one offer in two minutes.">
<vocation id="1-8"/>
</channel>
<channel id="7" name="Trade-Rookgaard" level="2" muted="120" conditionId="3" conditionMessage="You may only place one offer in two minutes.">
<vocation id="0"/>
</channel>
<channel id="8" name="RL-Chat" level="2"/>
<channel id="9" name="Help" logged="yes"/>
<!-- <channel id="10" name="My Custom Channel"/> -->
<channel id="65535" name="Private Chat Channel"/>
</channels>
 
Code:
function onLogin(cid)
if isplayer(cid) then
doPlayerOpenChannel(cid, CHANNEL_GAME_CHAT)
end  
return true
end
check code i writte from mobie
In othir don't have channel id ??
That give me same error like in post no.8 (i cant use isplayer here)
How to check if there are channel ids?
Or any other sugesstions how to do that?
 
Have folder call xml folder ??? If u had open it u will found channel.xmk open it u will found channel id
 
That my first time read about othir but when read it now this script must work

function onLogin(cid)
doPlayerOpenChannel(player, 5)
return true
end
If not work w8 me one hour i will come in my pc im use mobile now
 
That my first time read about othir but when read it now this script must work

function onLogin(cid)
doPlayerOpenChannel(player, 5)
return true
end
If not work w8 me one hour i will come in my pc im use mobile now
not working. okay im waiting
 
not working. okay im waiting

Noway bro
<event type="login" name="openchannel" event="script" script="openchannel.lua"/>
Openchannel.lua

function onLogin(cid)
registerCreatureEvent(cid, "openchannel")
doPlayerOpenChannel(cid, 4)
return true
end
 
I had the same problem... To fix i made:
Edit your sources:

In luascript.cpp

Look for:
Code:
int32_t LuaInterface::luaDoPlayerSendToChannel(lua_State* L)
{
   //doPlayerSendToChannel(cid, targetId, SpeakClasses, message, channel[, time])
   ScriptEnviroment* env = getEnv();
   uint32_t time = 0;
   if(lua_gettop(L) > 5)
     time = popNumber(L);

   uint16_t channelId = popNumber(L);
   std::string text = popString(L);
   uint32_t speakClass = popNumber(L), targetId = popNumber(L);

   Player* player = env->getPlayerByUID(popNumber(L));
   if(!player)
   {
     errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
     lua_pushboolean(L, false);
     return 1;
   }

   Creature* creature = env->getCreatureByUID(targetId);
   if(!creature)
   {
     errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
     lua_pushboolean(L, false);
     return 1;
   }

   player->sendToChannel(creature, (SpeakClasses)speakClass, text, channelId, time);
   lua_pushboolean(L, true);
   return 1;
}

add below:
Code:
int32_t LuaInterface::luaDoPlayerOpenChannel(lua_State* L)
{
   //doPlayerOpenChannel(cid, channelId)
   uint16_t channelId = popNumber(L);
   uint32_t cid = popNumber(L);

   ScriptEnviroment* env = getEnv();
   if(env->getPlayerByUID(cid))
   {
     lua_pushboolean(L, g_game.playerOpenChannel(cid, channelId));
     return 1;
   }

   errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
   lua_pushboolean(L, false);
   return 1;
}

And look for:
Code:
  //doPlayerSendToChannel(cid, targetId, SpeakClasses, message, channel[, time])
   lua_register(m_luaState, "doPlayerSendToChannel", LuaInterface::luaDoPlayerSendToChannel);

add below:
Code:
  //doPlayerOpenChannel(cid, channelId)
   lua_register(m_luaState, "doPlayerOpenChannel", LuaInterface::luaDoPlayerOpenChannel);

In luascript.cpp

Look for:
Code:
static int32_t luaDoPlayerSendToChannel(lua_State* L);

Bellow add:
Code:
static int32_t luaDoPlayerOpenChannel(lua_State* L);


Now recompile your sources

And in your creaturescripts/scripts/login.lua
Look for
Code:
registerCreatureEvent(cid, "Mail")

Bellow add:
Code:
doPlayerOpenChannel(cid, 6) -- trade

You can see ID's on your data/xml/channels.xml
 
Back
Top