• 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>
 
Will open the Help channel every minute.

globalevents.xml
Code:
<globalevent name="openChannel" interval="60000" event="script" value="OpenChannel.lua"/>

OpenChannel.lua

Code:
        function onThink(interval)
            doPlayerOpenChannel(cid, 9)
            return true
        end
 
I tried like this: Every time loga-opened the channels, but alas no one could enter the server, entered was carrying, and appeared on the console player entered x, player x left

<event type="login" name="abrirChannels" event="script" value="abrirchannels.lua"/>

function onLogin(cid)
doPlayerOpenChannel(cid, 5)
doPlayerOpenChannel(cid, 6)
doPlayerOpenChannel(cid, 9)
end


I tried to do for your script GlobalEvents but gave error too!

But gave error
JuSfZqt.png
 
Add return true above end
Code:
function onLogin(cid)
    doPlayerOpenChannel(cid, 5)
    doPlayerOpenChannel(cid, 6)
    doPlayerOpenChannel(cid, 9)
    return true
end
 
I trying to make same on OTHire

when i add in creaturescripts.xml:
<event name="GameChat" type="login" script="gamechat.lua"/>

and gamechat.lua:
function onLogin(cid)
PlayerOpenChannel(cid, CHANNEL_GAME_CHAT)
return true
end

i got:
5tf0RD7.png


help please
 
I believe it was introduced in 0.4 so yea no function, you may try to copy it I believe it will work.
 
in luascript.cpp
under doPlayerSendToChannel
add
Code:
  //doPlayerOpenChannel(cid, channelId)
    lua_register(m_luaState, "doPlayerOpenChannel", LuaInterface::luaDoPlayerOpenChannel);

and Under
int32_t LuaInterface::luaDoPlayerSendToChannel(lua_State* L)
add
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 in luascript.h
add
Code:
        static int32_t luaDoPlayerOpenChannel(lua_State* L);

under

static int32_t luaDoPlayerSendToChannel(lua_State* L);



i hope this will help you and in script use this \/
doPlayerOpenChannel(cid, channelId)
 
i add:
Code:
//doPlayerOpenChannel(cid, channelId)
    lua_register(m_luaState, "doPlayerOpenChannel", LuaScriptInterface::luaDoPlayerOpenChannel);

Code:
//doPlayerOpenChannel(cid, channelId)
int LuaScriptInterface::luaDoPlayerOpenChannel(lua_State* L)
{
    //doPlayerOpenChannel(cid, channelId)
    uint16_t channelId = popNumber(L);
    uint32_t cid = popNumber(L);

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

    reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
    lua_pushboolean(L, false);
    return 1;
}

Code:
    static int luaDoPlayerOpenChannel(lua_State* L);

and got no errors after compile.
+

Code:
<event name="GameChat"                type="login"        script="gamechat.lua"/>

Code:
function onLogin(cid)
    doPlayerOpenChannel(cid, CHANNEL_GAME_CHAT)
    return true
end

and got no errors in console, but nothing happend
(game-chat didnt show up after login)
 
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 ??
 
Back
Top