From a0d6570d319bcf0b1217465307d0d29f4dd78bf6 Mon Sep 17 00:00:00 2001 From: ArKaNeMaN Date: Tue, 27 Jul 2021 16:54:26 +0300 Subject: [PATCH] Add native `arraycompare`. --- amxmodx/amxmodx.cpp | 15 +++++++++++++++ plugins/include/amxmodx.inc | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 55914ec1..3e9de4e6 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -4453,6 +4453,20 @@ static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params) return 1; } +// native bool:arraycompare(const any:what[], const any:with[], const size); +static cell AMX_NATIVE_CALL arraycompare(AMX *amx, cell *params) +{ + cell *what = get_amxaddr(amx, params[1]); + cell *with = get_amxaddr(amx, params[2]); + int size = params[3]; + + while (size--) + if (*with++ != *what++) + return 0; + + return 1; +} + static cell AMX_NATIVE_CALL CreateLangKey(AMX *amx, cell *params) { int len; @@ -4682,6 +4696,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] = {"admins_push", admins_push}, {"amxclient_cmd", amxclient_cmd}, {"arrayset", arrayset}, + {"arraycompare", arraycompare}, {"get_addr_val", get_addr_val}, {"get_var_addr", get_var_addr}, {"set_addr_val", set_addr_val}, diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index ed1f3ec5..306d338f 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -3309,6 +3309,17 @@ native DestroyForward(forward_handle); */ native arrayset(any:array[], any:value, size); +/** + * Compares two arrays. + * + * @param what First array + * @param with Second array + * @param size Size of array + * + * @return Returns true if arrays are equaly, false otherwise. + */ +native bool:arraycompare(const any:what[], const any:with[], const size); + /** * Returns the weapon id associated with a weapon name. *