dvander@1616: /** dvander@1616: * vim: set ts=4 : dvander@1616: * ============================================================================= ds@1947: * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. dvander@1616: * ============================================================================= dvander@1616: * dvander@1616: * This file is part of the SourceMod/SourcePawn SDK. dvander@1616: * dvander@1616: * This program is free software; you can redistribute it and/or modify it under dvander@1616: * the terms of the GNU General Public License, version 3.0, as published by the dvander@1616: * Free Software Foundation. dvander@1616: * dvander@1616: * This program is distributed in the hope that it will be useful, but WITHOUT dvander@1616: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS dvander@1616: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more dvander@1616: * details. dvander@1616: * dvander@1616: * You should have received a copy of the GNU General Public License along with dvander@1616: * this program. If not, see . dvander@1616: * dvander@1616: * As a special exception, AlliedModders LLC gives you permission to link the dvander@1616: * code of this program (as well as its derivative works) to "Half-Life 2," the dvander@1616: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software dvander@1616: * by the Valve Corporation. You must obey the GNU General Public License in dvander@1616: * all respects for all other code used. Additionally, AlliedModders LLC grants dvander@1616: * this exception to all derivative works. AlliedModders LLC defines further dvander@1616: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), dvander@1616: * or . dvander@1616: * dvander@1616: * Version: $Id$ dvander@1616: */ dvander@1616: dvander@1616: #if defined _sdktools_stocks_included dvander@1616: #endinput dvander@1616: #endif dvander@1616: #define _sdktools_stocks_included dvander@1616: dvander@1616: /** dvander@1616: * Given a partial team name, attempts to find a matching team. dvander@1616: * dvander@1616: * The search is performed case insensitively and only against the dvander@1616: * first N characters of the team names, where N is the number of dvander@1616: * characters in the search pattern. dvander@1616: * dvander@1616: * @param name Partial or full team name. dvander@1616: * @return A valid team index on success. dvander@1616: * -1 if no team matched. dvander@1616: * -2 if more than one team matched. dvander@1616: */ dvander@1616: stock FindTeamByName(const String:name[]) dvander@1616: { dvander@1616: new name_len = strlen(name); dvander@1616: new num_teams = GetTeamCount(); dvander@1616: decl String:team_name[32]; dvander@2383: new found_team = -1; dvander@1616: dvander@1616: for (new i = 0; i < num_teams; i++) dvander@1616: { dvander@1616: GetTeamName(i, team_name, sizeof(team_name)); dvander@1616: dvander@2447: if (strncmp(team_name, name, name_len, false) == 0) dvander@1616: { dvander@1616: if (found_team >= 0) dvander@1616: { dvander@1616: return -2; dvander@1616: } dvander@1616: else dvander@1616: { dvander@1616: found_team = i; dvander@1616: } dvander@1616: } dvander@1616: } dvander@1616: dvander@1616: return found_team; dvander@1616: } dvander@1616: