• 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 0.X open channels on login

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
246
Solutions
1
Reaction score
40
Location
Ankrahmun
hey guys is it possible to open some chat channels directly when player login
using tfs 0.4 860 . I see this option in many server but not mine so I need when any player login to got some channels opens as server log and so
 
Solution
1. Add
C++:
static int32_t luaDoPlayerOpenChannel(lua_State* L);
below Fir3element/3777 (https://github.com/Fir3element/3777/blob/master/src/luascript.h#L653)

2. Add
C++:
    //doPlayerOpenChannel(cid, channelId)
    lua_register(m_luaState, "doPlayerOpenChannel", LuaInterface::luaDoPlayerOpenChannel);
below https://github.com/Fir3element/3777/blob/master/src/luascript.cpp#L1626

3. Add
C++:
int32_t LuaInterface::luaDoPlayerOpenChannel(lua_State* L)
{
    //doPlayerOpenChannel(cid, channelId)
    ScriptEnviroment* env = getEnv();
    uint16_t channelId = popNumber(L);
    uint32_t cid = popNumber(L);

    Player* player = env->getPlayerByUID(cid);
    if(player)
        lua_pushnumber(L, g_game.playerOpenChannel(cid...
Code:
doPlayerOpenChannel(cid, 4)
to see all chat id, go to data/xml/channels.xml and check.

if u get error (NIL VALUE) with this function, u will have to add the function in your source
 
1. Add
C++:
static int32_t luaDoPlayerOpenChannel(lua_State* L);
below Fir3element/3777 (https://github.com/Fir3element/3777/blob/master/src/luascript.h#L653)

2. Add
C++:
    //doPlayerOpenChannel(cid, channelId)
    lua_register(m_luaState, "doPlayerOpenChannel", LuaInterface::luaDoPlayerOpenChannel);
below https://github.com/Fir3element/3777/blob/master/src/luascript.cpp#L1626

3. Add
C++:
int32_t LuaInterface::luaDoPlayerOpenChannel(lua_State* L)
{
    //doPlayerOpenChannel(cid, channelId)
    ScriptEnviroment* env = getEnv();
    uint16_t channelId = popNumber(L);
    uint32_t cid = popNumber(L);

    Player* player = env->getPlayerByUID(cid);
    if(player)
        lua_pushnumber(L, g_game.playerOpenChannel(cid, channelId) ? true : false);
    else
    {
        errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
    }

    return 1;
}
below https://github.com/Fir3element/3777/blob/master/src/luascript.cpp#L9259

4. Now you can use for example doPlayerOpenChannel(cid, 5) below Fir3element/3777 (https://github.com/Fir3element/3777/blob/master/data/creaturescripts/scripts/login.lua#L43)
 
Solution
1. Add
C++:
static int32_t luaDoPlayerOpenChannel(lua_State* L);
below Fir3element/3777 (https://github.com/Fir3element/3777/blob/master/src/luascript.h#L653)

2. Add
C++:
    //doPlayerOpenChannel(cid, channelId)
    lua_register(m_luaState, "doPlayerOpenChannel", LuaInterface::luaDoPlayerOpenChannel);
below https://github.com/Fir3element/3777/blob/master/src/luascript.cpp#L1626

3. Add
C++:
int32_t LuaInterface::luaDoPlayerOpenChannel(lua_State* L)
{
    //doPlayerOpenChannel(cid, channelId)
    ScriptEnviroment* env = getEnv();
    uint16_t channelId = popNumber(L);
    uint32_t cid = popNumber(L);

    Player* player = env->getPlayerByUID(cid);
    if(player)
        lua_pushnumber(L, g_game.playerOpenChannel(cid, channelId) ? true : false);
    else
    {
        errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
    }

    return 1;
}
below https://github.com/Fir3element/3777/blob/master/src/luascript.cpp#L9259

4. Now you can use for example doPlayerOpenChannel(cid, 5) below Fir3element/3777 (https://github.com/Fir3element/3777/blob/master/data/creaturescripts/scripts/login.lua#L43)
where I should add these codes? player.cpp?
 
oki thanks that was my mistake
but finally I want to know, are you show about this fir3element trunk, should I download and use it for my ot?
 
Back
Top