- added SearchForClients

- fixed versions and some header info in base plugins

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40908
This commit is contained in:
David Anderson 2007-06-07 03:45:44 +00:00
parent 7817602d75
commit 877b604ce9
3 changed files with 71 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/** /**
* admin-flatfile.sp * admin-auth.sp
* Manages the standard flat files for admins. This is the file to compile. * Authenticates admins.
* This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -26,7 +26,7 @@ public Plugin:myinfo =
name = "Admin Auth", name = "Admin Auth",
author = "AlliedModders LLC", author = "AlliedModders LLC",
description = "Authenticates Admins", description = "Authenticates Admins",
version = "1.0.0.0", version = SOURCEMOD_VERSION,
url = "http://www.sourcemod.net/" url = "http://www.sourcemod.net/"
}; };

View File

@ -30,7 +30,7 @@ public Plugin:myinfo =
name = "Admin File Reader", name = "Admin File Reader",
author = "AlliedModders LLC", author = "AlliedModders LLC",
description = "Reads admin files", description = "Reads admin files",
version = "1.0.0.0", version = SOURCEMOD_VERSION,
url = "http://www.sourcemod.net/" url = "http://www.sourcemod.net/"
}; };

View File

@ -73,3 +73,70 @@ stock Handle:FindPluginByFile(const String:filename[])
return INVALID_HANDLE; return INVALID_HANDLE;
} }
/**
* Searches for clients that match an input string.
*
* Allowed patterns:
* 1) #<userid> or #<exact name>
* 2) <partial or full name>
*/
stock SearchForClients(const String:pattern[], clients[], maxClients)
{
new maxclients = GetMaxClients();
new total = 0;
if (maxClients == 0)
{
return 0;
}
if (pattern[0] == '#')
{
new input = StringToInt(pattern[1]);
if (!input)
{
decl String:name[65]
for (new i=1; i<=maxclients; i++)
{
if (!IsClientInGame(i))
{
continue;
}
GetClientName(i, name, sizeof(name));
if (StrEqual(name, pattern, false))
{
clients[0] = i;
return 1;
}
}
} else {
new client = GetClientOfUserId(input);
if (client)
{
clients[0] = client;
return 1;
}
}
}
decl String:name[65]
for (new i=1; i<=maxclients; i++)
{
if (!IsClientInGame(i))
{
continue;
}
GetClientName(i, name, sizeof(name));
if (StrContains(name, pattern, false) != -1)
{
clients[total++] = i;
if (total >= maxClients)
{
break;
}
}
}
return total;
}