OPEN TRADE CHAT AUTOMATICALLY AFTER LOGIN

falls13

Member
Joined
Nov 3, 2015
Messages
29
Reaction score
1
TFS 0.3.6

[Error - CreatureScript Interface]
[08/04/2019 23:10:46] data/creaturescripts/scripts/login.lua:eek:nLogin
[08/04/2019 23:10:46] Description:
[08/04/2019 23:10:46] data/creaturescripts/scripts/login.lua:19: attempt to call global 'doPlayerOpenChannel' (a nil value)
[08/04/2019 23:10:46] stack traceback:
[08/04/2019 23:10:46] data/creaturescripts/scripts/login.lua:19: in function <data/creaturescripts/scripts/login.lua:6>







local config = {
loginMessage = getConfigValue('loginMessage'),
useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
local loss = getConfigValue('deathLostPercent')
if(loss ~= nil) then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 30)
doPlayerSetLossPercent(cid, PLAYERLOSS_ITEMS, loss * 100)



end

local accountManager = getPlayerAccountManager(cid)
if(accountManager == MANAGER_NONE) then
local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
doPlayerOpenChannel(cid, 8)
if(lastLogin > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
else
str = str .. " Please choose your outfit."
doPlayerSendOutfitWindow(cid)
end

doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
elseif(accountManager == MANAGER_NAMELOCK) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
elseif(accountManager == MANAGER_ACCOUNT) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
end

if(not isPlayerGhost(cid)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end


registerCreatureEvent(cid, "Mail")
registerCreatureEvent(cid, "GuildMotd")
registerCreatureEvent(cid, "kill")
registerCreatureEvent(cid, "onPrepareDeath")
registerCreatureEvent(cid, "deathBroadcast")
registerCreatureEvent(cid, "hmup")
registerCreatureEvent(cid, "DeathBroadcast")
registerCreatureEvent(cid, "TiraBattle")
registerCreatureEvent(cid, "showKD")
registerCreatureEvent(cid, "redSkullAmulet")
registerCreatureEvent(cid, "redSkullAmule")
registerCreatureEvent(cid, "RED")
registerCreatureEvent(cid, "FirstItems")
registerCreatureEvent(cid, "DoubleXP")
registerCreatureEvent(cid, "noAttackParty")
registerCreatureEvent(cid, "attackguild")
registerCreatureEvent(cid, "pop")
registerCreatureEvent(cid, "Idle")
if(config.useFragHandler) then
registerCreatureEvent(cid, "SkullCheck")
end

registerCreatureEvent(cid, "ReportBug")




return true
end
 

roriscrave

Intermediate OT User
Joined
Dec 7, 2011
Messages
405
Reaction score
39
You need to add this function in your source, u dont have it:
Code:
doPlayerOpenChannel
 

Mustafa1337

Î Àm ŁĕğẹňĎ
Joined
Mar 4, 2017
Messages
366
Reaction score
88
It is already posted many times, Try to use search.
Since you are using TFS 0.3.6 so in luascript.h line 611 below this
C++:
static int32_t luaGetChannelUsers(lua_State* L);
add this
C++:
static int32_t luaDoPlayerOpenChannel(lua_State* L);
in luascript.cpp line 1559 below this
C++:
//getChannelUsers(channelId)
lua_register(m_luaState, "getChannelUsers", LuaScriptInterface::luaGetChannelUsers);
add this
C++:
    //doPlayerOpenChannel(cid, channelId)
    lua_register(m_luaState, "doPlayerOpenChannel", LuaInterface::luaDoPlayerOpenChannel);
in luascript.cpp line 8500 below this
C++:
int32_t LuaScriptInterface::luaGetChannelUsers(lua_State* L)
{
    //getChannelUsers(channelId)
    ScriptEnviroment* env = getEnv();
    uint16_t channelId = popNumber(L);

    if(ChatChannel* channel = g_chat.getChannelById(channelId))
    {
        UsersMap usersMap = channel->getUsers();
        UsersMap::iterator it = usersMap.begin();

        lua_newtable(L);
        for(int32_t i = 1; it != usersMap.end(); ++it, ++i)
        {
            lua_pushnumber(L, i);
            lua_pushnumber(L, env->addThing(it->second));
            pushTable(L);
        }
    }
    else
        lua_pushboolean(L, false);

    return 1;
}
add this
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;
}
I got it exactly from the link roriscrave posted above just changed the lines to help you.
 
Top