2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-03-13 05:50:16 +03:00

Add native rh_client_drop (#135)

* Add new native rh_drop_client
This commit is contained in:
Dmitry 2019-07-29 05:41:37 +07:00 committed by Dmitry Novikov
parent 8b26f29d54
commit a68cde02f2
2 changed files with 40 additions and 0 deletions

View File

@ -137,3 +137,14 @@ native bool:rh_emit_sound2(const entity, const recipient, const channel, const s
* @noreturn
*/
native rh_update_user_info(playerEntIndex);
/*
* Kicks a client from server with message
*
* @param index Client index
* @param message Message that will be sent to client when it is deleted from server
*
* @noreturn
*
*/
native rh_drop_client(const index, const message[] = "");

View File

@ -2364,6 +2364,34 @@ cell AMX_NATIVE_CALL rh_update_user_info(AMX *amx, cell *params)
return TRUE;
}
/*
* Kicks a client from server with message
*
* @param index Client index
* @param message Message that will be sent to client when it is deleted from server
*
* @noreturn
*
* native rh_drop_client(const index, const message[] = "");
*/
cell AMX_NATIVE_CALL rh_drop_client(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_msg };
CHECK_ISPLAYER(arg_index);
client_t *pClient = clientOfIndex(params[arg_index]);
if (unlikely(pClient == nullptr || !(pClient->active | pClient->spawned | pClient->connected)))
{
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
return FALSE;
}
char messagebuf[256];
g_RehldsFuncs->DropClient(g_RehldsSvs->GetClient(params[arg_index] - 1), false, getAmxString(amx, params[arg_msg], messagebuf));
return TRUE;
}
AMX_NATIVE_INFO Misc_Natives_RH[] =
{
{ "rh_set_mapname", rh_set_mapname },
@ -2371,6 +2399,7 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
{ "rh_reset_mapname", rh_reset_mapname },
{ "rh_emit_sound2", rh_emit_sound2 },
{ "rh_update_user_info", rh_update_user_info },
{ "rh_drop_client", rh_drop_client },
{ nullptr, nullptr }
};