diff --git a/reapi/extra/amxmodx/scripting/include/reapi_reunion.inc b/reapi/extra/amxmodx/scripting/include/reapi_reunion.inc index ea85bce..311f0c2 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_reunion.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_reunion.inc @@ -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. * diff --git a/reapi/src/natives/natives_reunion.cpp b/reapi/src/natives/natives_reunion.cpp index 3437b4a..4dad578 100644 --- a/reapi/src/natives/natives_reunion.cpp +++ b/reapi/src/natives/natives_reunion.cpp @@ -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, 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. * @@ -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 }