plugins/include/sdktools_stocks.inc
branchrefac-jit
changeset 2168 c24a6fa957db
child 2289 44045ead61cd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/sdktools_stocks.inc	Sun Jul 06 04:49:55 2008 +0000
     1.3 @@ -0,0 +1,76 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     1.8 + * =============================================================================
     1.9 + *
    1.10 + * This file is part of the SourceMod/SourcePawn SDK.
    1.11 + *
    1.12 + * This program is free software; you can redistribute it and/or modify it under
    1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.14 + * Free Software Foundation.
    1.15 + * 
    1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.18 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.19 + * details.
    1.20 + *
    1.21 + * You should have received a copy of the GNU General Public License along with
    1.22 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.23 + *
    1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.27 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.28 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.29 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.31 + * or <http://www.sourcemod.net/license.php>.
    1.32 + *
    1.33 + * Version: $Id$
    1.34 + */
    1.35 +
    1.36 +#if defined _sdktools_stocks_included
    1.37 +  #endinput
    1.38 +#endif
    1.39 +#define _sdktools_stocks_included
    1.40 +
    1.41 +/**
    1.42 + * Given a partial team name, attempts to find a matching team.
    1.43 + *
    1.44 + * The search is performed case insensitively and only against the 
    1.45 + * first N characters of the team names, where N is the number of 
    1.46 + * characters in the search pattern.
    1.47 + *
    1.48 + * @param name		Partial or full team name.  
    1.49 + * @return			A valid team index on success.
    1.50 + * 					-1 if no team matched.
    1.51 + *					-2 if more than one team matched.
    1.52 + */
    1.53 +stock FindTeamByName(const String:name[])
    1.54 +{
    1.55 +	new name_len = strlen(name);
    1.56 +	new num_teams = GetTeamCount();
    1.57 +	decl String:team_name[32];
    1.58 +	new found_team = -1
    1.59 +
    1.60 +	for (new i = 0; i < num_teams; i++)
    1.61 +	{
    1.62 +		GetTeamName(i, team_name, sizeof(team_name));
    1.63 +
    1.64 +		if (strncmp(team_name, name, name_len) == 0)
    1.65 +		{
    1.66 +			if (found_team >= 0)
    1.67 +			{
    1.68 +				return -2;
    1.69 +			}
    1.70 +			else
    1.71 +			{
    1.72 +				found_team = i;
    1.73 +			}
    1.74 +		}
    1.75 +	}
    1.76 +
    1.77 +	return found_team;
    1.78 +}
    1.79 +