From d27a768d9704f9a37bcdc1b85cca3b466576c873 Mon Sep 17 00:00:00 2001 From: Michael McKoy Date: Sat, 22 Sep 2007 17:43:19 +0000 Subject: [PATCH] New IsStringInArray stock for array ADT --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401457 --- plugins/include/adt_array.inc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugins/include/adt_array.inc b/plugins/include/adt_array.inc index a19a114e..98db273d 100644 --- a/plugins/include/adt_array.inc +++ b/plugins/include/adt_array.inc @@ -248,3 +248,27 @@ native RemoveFromArray(Handle:array, index); * @error Invalid Handle or invalid index. */ native SwapArrayItems(Handle:array, index1, index2); + +/** + * Returns true is the supplied string exists within the supplied array. + * + * @param array Array Handle. + * @param item String to search for + * @return True if found, false if not + * @error Invalid handle + */ +stock bool:IsStringInArray(Handle:array, const String:item[]) +{ + decl String:curItem[64]; + + for (new i = 0; i < GetArraySize(array); i++) + { + GetArrayString(array, i, curItem, sizeof(curItem)); + if(strcmp(item, curItem, false) == 0) + { + return true; + } + } + + return false; +}