• 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++ TFS 0.4 Helps you add a function in the Cast System

Matheuuss

New Member
Joined
Nov 20, 2018
Messages
25
Reaction score
0
Good night! I wanted to add a function of Kick Cast members. I use TFS 0.4 rev3777 with Summ Cast. There it only has the function of banishing, it does not have to kick.
Could you please send me the kick code for me here?

The one to banish is this:
Luascript.cpp:
C++:
//doPlayerAddCastBan(cid, ip)
    lua_register(m_luaState, "doPlayerAddCastBan", LuaInterface::luaDoPlayerAddCastBan);
And
C++:
int32_t LuaInterface::luaDoPlayerAddCastBan(lua_State* L)
{
    //doPlayerAddCastBan(cid, ip)
    std::string name = popString(L);
    ScriptEnviroment* env = getEnv();
    if(Player* player = env->getPlayerByUID(popNumber(L)))
    {
        if(player->addCastBan(name))
            lua_pushboolean(L, true);
        else
            lua_pushboolean(L, false);
    }
    else
    {
        errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
    }

    return 1;
}
luascript.h
C++:
static int32_t luaDoPlayerAddCastBan(lua_State* L);
Player.h
C++:
bool addCastBan(std::string n) {
            uint32_t ip = getCastIpByName(n);
            if(!ip)
                return false;

            cast.bans.push_back(CastBan(n, ip));
            kickCastViewerByName(n);
            return true;
        }
And
C++:
uint32_t getCastIpByName(std::string n) {
            for(AutoList<ProtocolGame>::iterator it = cSpectators.begin(); it != cSpectators.end(); ++it)
                if(it->second->getViewerName() == n && it->second->getPlayer() == this)
                    return it->second->getIP();

            return NULL;
        }
And at the top
C++:
struct CastBan
{
    std::string name;
    uint32_t ip;

    CastBan(std::string n, uint32_t _ip) {
        name = n;
        ip = _ip;
    }
};
I think that's it
 
Last edited:
Back
Top