New IsStringInArray stock for array ADT

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401457
This commit is contained in:
Michael McKoy 2007-09-22 17:43:19 +00:00
parent b38f0cc02e
commit d27a768d97

View File

@ -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;
}