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:
And
luascript.h
Player.h
And
And at the top
I think that's it
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);
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;
}
C++:
static int32_t luaDoPlayerAddCastBan(lua_State* L);
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;
}
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;
}
C++:
struct CastBan
{
std::string name;
uint32_t ip;
CastBan(std::string n, uint32_t _ip) {
name = n;
ip = _ip;
}
};
Last edited: