Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rh_get_client_incoming_sequence native #322

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_engine.inc
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,12 @@ native bool:IsMessageDataModified(MsgDataType:type = MsgAny, const number = -1);
* @return Returns true if the modified data type was reset, otherwise false.
*/
native bool:ResetModifiedMessageData(MsgDataType:type = MsgAny, const number = -1);

/*
* Returns client's netchan incoming sequence.
*
* @param index Client index
*
* @return Netchan incoming sequence or -1 if client index is invalid or client is not connected
*/
native rh_get_client_incoming_sequence(const index);
32 changes: 32 additions & 0 deletions reapi/src/natives/natives_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3668,6 +3668,37 @@ cell AMX_NATIVE_CALL rh_get_client_connect_time(AMX *amx, cell *params)
return (cell)(g_RehldsFuncs->GetRealTime() - pClient->netchan.connect_time);
}


/*
* Returns client's netchan incoming sequence.
*
* @param index Client index
*
* @return Netchan incoming sequence or -1 if client index is invalid or client is not connected
*/

cell AMX_NATIVE_CALL rh_get_client_incoming_sequence(AMX* amx, cell* params)
{
enum args_e { arg_count, arg_index };

CHECK_ISPLAYER(arg_index);

if (unlikely(params[arg_index] <= 0 || params[arg_index] > gpGlobals->maxClients))
{
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: invalid player index %i", __FUNCTION__, params[arg_index]);
return -1;
}

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 -1;
}

return pClient->netchan.incoming_sequence;
}

AMX_NATIVE_INFO Misc_Natives_RH[] =
{
{ "rh_set_mapname", rh_set_mapname },
Expand All @@ -3679,6 +3710,7 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
{ "rh_get_net_from", rh_get_net_from },

{ "rh_get_client_connect_time", rh_get_client_connect_time },
{ "rh_get_client_incoming_sequence", rh_get_client_incoming_sequence },

{ nullptr, nullptr }
};
Expand Down
Loading