mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-16 08:38:08 +03:00
rh_get_key_value/rh_set_key_value moving from misc to common
This commit is contained in:
parent
b06b1915eb
commit
1a9b80e168
@ -30,6 +30,31 @@ native set_ucmd(const ucmd, const UCmd:var, any:...);
|
|||||||
*/
|
*/
|
||||||
native any:get_ucmd(const ucmd, const UCmd:var, any:...);
|
native any:get_ucmd(const ucmd, const UCmd:var, any:...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets value for key in buffer
|
||||||
|
*
|
||||||
|
* @param pbuffer Pointer to buffer
|
||||||
|
* @param key Key string
|
||||||
|
* @param value Buffer to copy value to
|
||||||
|
* @param maxlen Maximum size of the buffer
|
||||||
|
*
|
||||||
|
* @return Number of cells written to buffer
|
||||||
|
* @error If the index is not within the range of 1 to MaxClients or
|
||||||
|
* the client is not connected, an error will be thrown.
|
||||||
|
*/
|
||||||
|
native get_key_value(const pbuffer, const key[], const value[], const maxlen);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets value for key in buffer
|
||||||
|
*
|
||||||
|
* @param pbuffer Pointer to buffer
|
||||||
|
* @param key Key string
|
||||||
|
* @param value Value to set
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native set_key_value(const pbuffer, const key[], const value[]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets the name of the map.
|
* Sets the name of the map.
|
||||||
*
|
*
|
||||||
@ -88,28 +113,3 @@ native bool:rh_emit_sound2(const entity, const recipient, const channel, const s
|
|||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native rh_update_user_info(playerEntIndex);
|
native rh_update_user_info(playerEntIndex);
|
||||||
|
|
||||||
/*
|
|
||||||
* Gets value for key in buffer
|
|
||||||
*
|
|
||||||
* @param pbuffer Pointer to buffer
|
|
||||||
* @param key Key string
|
|
||||||
* @param value Buffer to copy value to
|
|
||||||
* @param maxlen Maximum size of the buffer
|
|
||||||
*
|
|
||||||
* @return Number of cells written to buffer
|
|
||||||
* @error If the index is not within the range of 1 to MaxClients or
|
|
||||||
* the client is not connected, an error will be thrown.
|
|
||||||
*/
|
|
||||||
native rh_get_key_value(const pbuffer, const key[], value[], maxlen)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sets value for key in buffer
|
|
||||||
*
|
|
||||||
* @param pbuffer Pointer to buffer
|
|
||||||
* @param key Key string
|
|
||||||
* @param value Value to set
|
|
||||||
*
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
native rh_set_key_value(const pbuffer, const key[], const value[])
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
// Key + value + 2 x slash + NULL
|
// Key + value + 2 x slash + NULL
|
||||||
const int MAX_INFO_STRING = 256;
|
const int MAX_INFO_STRING = 256;
|
||||||
|
const int MAX_KV_LEN = 127;
|
||||||
|
|
||||||
typedef struct client_frame_s
|
typedef struct client_frame_s
|
||||||
{
|
{
|
||||||
|
@ -111,12 +111,63 @@ cell AMX_NATIVE_CALL amx_get_viewent(AMX *amx, cell *params)
|
|||||||
return indexOfEdictAmx(pClient->pViewEntity);
|
return indexOfEdictAmx(pClient->pViewEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets value for key in buffer
|
||||||
|
*
|
||||||
|
* @param pbuffer Pointer to buffer
|
||||||
|
* @param key Key string
|
||||||
|
* @param value Buffer to copy value to
|
||||||
|
* @param maxlen Maximum size of the buffer
|
||||||
|
*
|
||||||
|
* @return Number of cells written to buffer
|
||||||
|
* @error If the index is not within the range of 1 to MaxClients or
|
||||||
|
* the client is not connected, an error will be thrown.
|
||||||
|
*
|
||||||
|
* native get_key_value(const pbuffer, const key[], const value[], const maxlen);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL amx_get_key_value(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_buffer, arg_key, arg_value, arg_maxlen };
|
||||||
|
|
||||||
|
char buffer[MAX_INFO_STRING], key[MAX_KV_LEN];
|
||||||
|
Q_strlcpy(buffer, getAmxString(amx, params[arg_buffer]));
|
||||||
|
Q_strlcpy(key, getAmxString(amx, params[arg_key]));
|
||||||
|
|
||||||
|
return g_amxxapi.SetAmxString(amx, params[arg_value], g_engfuncs.pfnInfoKeyValue(buffer, key), params[arg_maxlen]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets value for key in buffer
|
||||||
|
*
|
||||||
|
* @param pbuffer Pointer to buffer
|
||||||
|
* @param key Key string
|
||||||
|
* @param value Value to set
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*
|
||||||
|
* native set_key_value(const pbuffer, const key[], const value[]);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL amx_set_key_value(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_buffer, arg_key, arg_value };
|
||||||
|
|
||||||
|
char buffer[MAX_INFO_STRING], key[MAX_KV_LEN], value[MAX_KV_LEN];
|
||||||
|
Q_strlcpy(buffer, getAmxString(amx, params[arg_buffer]));
|
||||||
|
Q_strlcpy(key, getAmxString(amx, params[arg_key]));
|
||||||
|
Q_strlcpy(value, getAmxString(amx, params[arg_value]));
|
||||||
|
|
||||||
|
g_engfuncs.pfnSetKeyValue(buffer, key, value);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO Natives_Common[] =
|
AMX_NATIVE_INFO Natives_Common[] =
|
||||||
{
|
{
|
||||||
{ "FClassnameIs", amx_FClassnameIs },
|
{ "FClassnameIs", amx_FClassnameIs },
|
||||||
{ "GetGrenadeType", amx_GetGrenadeType },
|
{ "GetGrenadeType", amx_GetGrenadeType },
|
||||||
{ "engset_view", amx_engset_view },
|
{ "engset_view", amx_engset_view },
|
||||||
{ "get_viewent", amx_get_viewent },
|
{ "get_viewent", amx_get_viewent },
|
||||||
|
{ "get_key_value", amx_get_key_value },
|
||||||
|
{ "set_key_value", amx_set_key_value },
|
||||||
|
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
@ -2012,28 +2012,6 @@ cell AMX_NATIVE_CALL rh_update_user_info(AMX *amx, cell *params)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell AMX_NATIVE_CALL rh_get_key_value(AMX *amx, cell *params)
|
|
||||||
{
|
|
||||||
enum args_e { arg_count, arg_buffer, arg_key, arg_value, arg_maxlen };
|
|
||||||
|
|
||||||
char *buffer = getAmxString(amx, params[arg_buffer]);
|
|
||||||
const char *key = getAmxString(amx, params[arg_key]);
|
|
||||||
|
|
||||||
return g_amxxapi.SetAmxString(amx, params[arg_value], g_engfuncs.pfnInfoKeyValue(buffer, key), params[arg_maxlen]);
|
|
||||||
}
|
|
||||||
|
|
||||||
cell AMX_NATIVE_CALL rh_set_key_value(AMX *amx, cell *params)
|
|
||||||
{
|
|
||||||
enum args_e { arg_count, arg_buffer, arg_key, arg_value };
|
|
||||||
|
|
||||||
char *buffer = getAmxString(amx, params[arg_buffer]);
|
|
||||||
const char *key = getAmxString(amx, params[arg_key]);
|
|
||||||
const char *value = getAmxString(amx, params[arg_value]);
|
|
||||||
|
|
||||||
g_engfuncs.pfnSetKeyValue(buffer, key, value);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
AMX_NATIVE_INFO Misc_Natives_RH[] =
|
AMX_NATIVE_INFO Misc_Natives_RH[] =
|
||||||
{
|
{
|
||||||
{ "rh_set_mapname", rh_set_mapname },
|
{ "rh_set_mapname", rh_set_mapname },
|
||||||
@ -2041,8 +2019,6 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
|
|||||||
{ "rh_reset_mapname", rh_reset_mapname },
|
{ "rh_reset_mapname", rh_reset_mapname },
|
||||||
{ "rh_emit_sound2", rh_emit_sound2 },
|
{ "rh_emit_sound2", rh_emit_sound2 },
|
||||||
{ "rh_update_user_info", rh_update_user_info },
|
{ "rh_update_user_info", rh_update_user_info },
|
||||||
{ "rh_get_key_value", rh_get_key_value },
|
|
||||||
{ "rh_set_key_value", rh_set_key_value },
|
|
||||||
|
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
MAX_KV_LEN = 127,
|
|
||||||
MAX_INFO_STRING = 256
|
|
||||||
};
|
|
||||||
|
|
||||||
enum WpnInfo
|
enum WpnInfo
|
||||||
{
|
{
|
||||||
WI_ID,
|
WI_ID,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user