Lua api function client_kill

This commit is contained in:
HarpyWar 2014-06-19 21:16:24 +04:00
parent d65dc73dfe
commit 7af51a1f88
3 changed files with 30 additions and 1 deletions

View file

@ -713,7 +713,6 @@ namespace pvpgn
{
const char * username;
unsigned int request_id, offset, length;
int messagebox_type;
try
{
lua::stack st(L);
@ -740,6 +739,34 @@ namespace pvpgn
return 0;
}
/* Destroy client connection */
extern int __client_kill(lua_State* L)
{
const char * username;
try
{
lua::stack st(L);
// get args
st.at(1, username);
if (t_account * account = accountlist_find_account(username))
{
if (t_connection * c = account_get_conn(account))
conn_set_state(c, conn_state_destroy);
}
}
catch (const std::exception& e)
{
eventlog(eventlog_level_error, __FUNCTION__, e.what());
}
catch (...)
{
eventlog(eventlog_level_error, __FUNCTION__, "lua exception\n");
}
return 0;
}
}
}
#endif

View file

@ -51,6 +51,7 @@ namespace pvpgn
extern int __server_get_games(lua_State* L);
extern int __server_get_channels(lua_State* L);
extern int __client_kill(lua_State* L);
extern int __client_readmemory(lua_State* L);
extern int __command_get_group(lua_State* L);

View file

@ -139,6 +139,7 @@ namespace pvpgn
{ "server_get_games", __server_get_games },
{ "server_get_channels", __server_get_channels },
{ "client_kill", __client_kill },
{ "client_readmemory", __client_readmemory },
{ "command_get_group", __command_get_group },