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

C++ Get pvtchannel ID

filhodaputa

New Member
Joined
Apr 29, 2010
Messages
4
Reaction score
0
Hello! i need a simple call with lua to know the private channel id...
well i know private channel have a number between 100 and 10000...


where i call this:
in lua
Code:
getPlayerChannelId(cid)

in luascript.cpp i do:
Code:
int32_t LuaScriptInterface::luagetPlayerChannelId(lua_State* L)
{

    ScriptEnviroment* env = getEnv();

    uint32_t cid = popNumber(L);
                 
    Player* player = env->getPlayerByUID(cid);
      
    if(PrivateChatChannel* channel = g_chat.getChannelidByplayer(player))
    {
        lua_pushnumber(L, channel->getId());
     } else {
           lua_pushboolean(L, false);    
     }}
in chat.cpp i created:

Code:
PrivateChatChannel* Chat::getChannelidByplayer(Player* player)
{
    if(!player || player->isRemoved())
        return NULL;

    PrivateChatChannel* channel = NULL;
    for(PrivateChannelMap::iterator it = m_privateChannels.begin(); it != m_privateChannels.end(); ++it)
    {
        if((channel = it->second) && channel->getOwner() == player->getGUID())
            return channel;
           
    }

    return NULL;
}

compilation work as well, but in game i get NULL...
someone can help-me?

thx advanced!
 
Back
Top