Skip to content

Commit

Permalink
Implemented native REU_GetAuthKey
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jan 30, 2022
1 parent 15aca1d commit fe6150a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_reunion.inc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ native REU_GetProtocol(const index);
*/
native client_auth_type:REU_GetAuthtype(const index);

/*
* Get client authkey
*
* @param index Client index
* @param index Buffer to copy the authkey
* @param index Maximum buffer size
*
* @return Number of cells copied to buffer
*
*/
native REU_GetAuthKey(const index, dest[], maxlen);

/*
* Check if the client is running RevEmu with limited user rights.
*
Expand Down
31 changes: 31 additions & 0 deletions reapi/src/natives/natives_reunion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ cell AMX_NATIVE_CALL REU_GetAuthtype(AMX *amx, cell *params)
return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1);
}

/*
* Get client authkey
*
* @param index Client index
* @param index Buffer to copy the authkey
* @param index Maximum buffer size
*
* @return Number of cells copied to buffer
*
* native REU_GetAuthKey(const index, dest[], maxlen);
*/
cell AMX_NATIVE_CALL REU_GetAuthKey(AMX *amx, cell *params)
{
enum args_e { arg_count, arg_index, arg_output, arg_maxlen };

CHECK_ISPLAYER(arg_index);

int clientId = params[arg_index] - 1;

char buffer[256];
size_t size = g_ReunionApi->GetClientAuthdata(clientId, buffer, sizeof buffer);
if (size <= 0)
return 0;

size_t numToCopy = min<size_t>(size, params[arg_maxlen]);
cell *dest = getAmxAddr(amx, params[arg_output]);
setAmxString(dest, buffer, numToCopy);
return numToCopy;
}

/*
* Check if the client is running RevEmu with limited user rights.
*
Expand Down Expand Up @@ -70,6 +100,7 @@ AMX_NATIVE_INFO Reunion_Natives[] =
{
{ "REU_GetProtocol", REU_GetProtocol },
{ "REU_GetAuthtype", REU_GetAuthtype },
{ "REU_GetAuthKey", REU_GetAuthKey },
{ "REU_IsRevemuWithoutAdminRights", REU_IsRevemuWithoutAdminRights },

{ nullptr, nullptr }
Expand Down

0 comments on commit fe6150a

Please sign in to comment.