plugins/include/helpers.inc
author Scott Ehlert <ds@alliedmods.net>
Fri Mar 16 06:57:31 2007 +0000 (2007-03-16)
changeset 622 ecf5428b05b1
parent 621 5a0f5014aac1
child 650 ab919035c173
permissions -rw-r--r--
Thank you for the typo, UltraEdit
dvander@460
     1
/**
ds@475
     2
 * vim: set ts=4 :
dvander@460
     3
 * ===============================================================
dvander@460
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
dvander@460
     5
 * ===============================================================
dvander@460
     6
 *
dvander@460
     7
 *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
dvander@460
     8
 * or modified under the Terms and Conditions of its License Agreement, which is found 
dvander@460
     9
 * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
dvander@460
    10
 * may change at any time.  To view the latest information, see:
dvander@460
    11
 *   http://www.sourcemod.net/license.php
dvander@460
    12
 *
dvander@460
    13
 * Version: $Id$
dvander@460
    14
 */
dvander@460
    15
 
dvander@460
    16
#if defined _helpers_included
dvander@460
    17
 #endinput
dvander@460
    18
#endif
dvander@460
    19
#define _helpers_included
dvander@460
    20
dvander@460
    21
/**
dvander@460
    22
 * Formats a user's info as log text.
dvander@460
    23
 *
dvander@460
    24
 * @param client		Client index.
dvander@460
    25
 * @param buffer		Buffer for text.
dvander@460
    26
 * @param maxlength		Maximum length of text.
dvander@460
    27
 */
dvander@460
    28
stock FormatUserLogText(client, String:buffer[], maxlength)
dvander@460
    29
{
dvander@460
    30
	decl String:auth[32];
dvander@460
    31
	decl String:name[40];
dvander@460
    32
	
dvander@460
    33
	new userid = GetClientUserId(client);
dvander@460
    34
	if (!GetClientAuthString(client, auth, sizeof(auth)))
dvander@460
    35
	{
dvander@460
    36
		StrCopy(auth, sizeof(auth), "UNKNOWN");
dvander@460
    37
	}
dvander@460
    38
	if (!GetClientName(client, name, sizeof(name)))
dvander@460
    39
	{
dvander@460
    40
		StrCopy(name, sizeof(name), "UNKNOWN");
dvander@460
    41
	}
dvander@460
    42
	
dvander@460
    43
	/** Currently, no team stuff ... */
dvander@460
    44
	
dvander@460
    45
	Format(buffer, maxlength, "\"%s<%d><%s><>\"", name, userid, auth);
dvander@460
    46
}
ds@621
    47
ds@621
    48
/**
ds@621
    49
 * Returns plugin handle from plugin filename.
ds@621
    50
 *
ds@621
    51
 * @param filename		Filename of the plugin to search for.
ds@622
    52
 * @return				Handle to plugin if found, INVALID_HANDLE otherwise.
ds@621
    53
 */
ds@621
    54
stock Handle:FindPluginByFile(const String:filename[])
ds@621
    55
{
ds@621
    56
	decl String:buffer[256];
ds@621
    57
	
ds@621
    58
	new Handle:iter = GetPluginIterator();
ds@621
    59
	new Handle:pl;
ds@621
    60
	
ds@621
    61
	while (MorePlugins(iter))
ds@621
    62
	{
ds@621
    63
		pl = ReadPlugin(iter);
ds@621
    64
		
ds@621
    65
		GetPluginFilename(pl, buffer, sizeof(buffer));
ds@621
    66
		if (StrCompare(buffer, filename) == 0)
ds@621
    67
		{
ds@621
    68
			return pl;
ds@621
    69
		}
ds@621
    70
	}
ds@621
    71
	
ds@621
    72
	return INVALID_HANDLE;
ds@621
    73
}