Skip to content

Commit fe6150a

Browse files
committed
Implemented native REU_GetAuthKey
1 parent 15aca1d commit fe6150a

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

reapi/extra/amxmodx/scripting/include/reapi_reunion.inc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ native REU_GetProtocol(const index);
3939
*/
4040
native client_auth_type:REU_GetAuthtype(const index);
4141

42+
/*
43+
* Get client authkey
44+
*
45+
* @param index Client index
46+
* @param index Buffer to copy the authkey
47+
* @param index Maximum buffer size
48+
*
49+
* @return Number of cells copied to buffer
50+
*
51+
*/
52+
native REU_GetAuthKey(const index, dest[], maxlen);
53+
4254
/*
4355
* Check if the client is running RevEmu with limited user rights.
4456
*

reapi/src/natives/natives_reunion.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,36 @@ cell AMX_NATIVE_CALL REU_GetAuthtype(AMX *amx, cell *params)
3636
return g_ReunionApi->GetClientAuthtype(params[arg_index] - 1);
3737
}
3838

39+
/*
40+
* Get client authkey
41+
*
42+
* @param index Client index
43+
* @param index Buffer to copy the authkey
44+
* @param index Maximum buffer size
45+
*
46+
* @return Number of cells copied to buffer
47+
*
48+
* native REU_GetAuthKey(const index, dest[], maxlen);
49+
*/
50+
cell AMX_NATIVE_CALL REU_GetAuthKey(AMX *amx, cell *params)
51+
{
52+
enum args_e { arg_count, arg_index, arg_output, arg_maxlen };
53+
54+
CHECK_ISPLAYER(arg_index);
55+
56+
int clientId = params[arg_index] - 1;
57+
58+
char buffer[256];
59+
size_t size = g_ReunionApi->GetClientAuthdata(clientId, buffer, sizeof buffer);
60+
if (size <= 0)
61+
return 0;
62+
63+
size_t numToCopy = min<size_t>(size, params[arg_maxlen]);
64+
cell *dest = getAmxAddr(amx, params[arg_output]);
65+
setAmxString(dest, buffer, numToCopy);
66+
return numToCopy;
67+
}
68+
3969
/*
4070
* Check if the client is running RevEmu with limited user rights.
4171
*
@@ -70,6 +100,7 @@ AMX_NATIVE_INFO Reunion_Natives[] =
70100
{
71101
{ "REU_GetProtocol", REU_GetProtocol },
72102
{ "REU_GetAuthtype", REU_GetAuthtype },
103+
{ "REU_GetAuthKey", REU_GetAuthKey },
73104
{ "REU_IsRevemuWithoutAdminRights", REU_IsRevemuWithoutAdminRights },
74105

75106
{ nullptr, nullptr }

0 commit comments

Comments
 (0)