mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-29 08:05:36 +03:00
Implement rh_get_client_connect_time()
native (#259)
* Implement `rh_get_client_connect_time()` native
This commit is contained in:
parent
ac3d641406
commit
7be36cc307
@ -159,3 +159,12 @@ native rh_drop_client(const index, const message[] = "");
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
native rh_get_net_from(output[], len);
|
native rh_get_net_from(output[], len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns client's netchan playing time in seconds.
|
||||||
|
*
|
||||||
|
* @param index Client index
|
||||||
|
*
|
||||||
|
* @return Netchan connection time in seconds or 0 if client index is invalid or client is not connected
|
||||||
|
*/
|
||||||
|
native rh_get_client_connect_time(const index);
|
||||||
|
@ -2751,6 +2751,31 @@ cell AMX_NATIVE_CALL rh_get_net_from(AMX* amx, cell* params)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns client's netchan playing time in seconds.
|
||||||
|
*
|
||||||
|
* @param index Client index
|
||||||
|
*
|
||||||
|
* @return Netchan connection time in seconds or 0 if client index is invalid or client is not connected
|
||||||
|
*
|
||||||
|
* native rh_get_client_connect_time(const index);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL rh_get_client_connect_time(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_index };
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (cell)(g_RehldsFuncs->GetRealTime() - pClient->netchan.connect_time);
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO Misc_Natives_RH[] =
|
AMX_NATIVE_INFO Misc_Natives_RH[] =
|
||||||
{
|
{
|
||||||
{ "rh_set_mapname", rh_set_mapname },
|
{ "rh_set_mapname", rh_set_mapname },
|
||||||
@ -2761,6 +2786,8 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
|
|||||||
{ "rh_drop_client", rh_drop_client },
|
{ "rh_drop_client", rh_drop_client },
|
||||||
{ "rh_get_net_from", rh_get_net_from },
|
{ "rh_get_net_from", rh_get_net_from },
|
||||||
|
|
||||||
|
{ "rh_get_client_connect_time", rh_get_client_connect_time },
|
||||||
|
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user