added natives

is_plugin_loaded(const name[]);
is_module_loaded(const name[]);
get_modulesnum();
get_module(id, name[], nameLen, author[], authorLen, version[], versionLen);
This commit is contained in:
Pavol Marko 2004-02-26 19:04:03 +00:00
parent 3abcd68bba
commit ce318d366d

View File

@ -1,21 +1,20 @@
/* AMX Mod X
/*
* Copyright (c) 2002-2003 Aleksander Naszko
*
* by the AMX Mod X Development Team
* originally developed by OLO
* This file is part of AMX Mod.
*
*
* This program is free software; you can redistribute it and/or modify it
* AMX Mod is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* AMX Mod is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* along with AMX Mod; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
@ -27,6 +26,7 @@
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include <extdll.h>
@ -2060,7 +2060,57 @@ static cell AMX_NATIVE_CALL register_logevent(AMX *amx, cell *params)
return 1;
}
// native is_module_loaded(const name[]);
static cell AMX_NATIVE_CALL is_module_loaded(AMX *amx, cell *params)
{
// param1: name
int len;
char *name = get_amxstring(amx, params[1], 0, len);
for (CList<CModule>::iterator iter = g_modules.begin(); iter; ++iter)
{
if (stricmp((*iter).getName(), name) == 0)
return 1;
}
return 0;
}
// native is_plugin_loaded(const name[]);
static cell AMX_NATIVE_CALL is_plugin_loaded(AMX *amx, cell *params)
{
// param1: name
int len;
char *name = get_amxstring(amx, params[1], 0, len);
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
{
if (stricmp((*iter).getName(), name) == 0)
return 1;
}
return 0;
}
// native get_modulesnum();
static cell AMX_NATIVE_CALL get_modulesnum(AMX *amx, cell *params)
{
return static_cast<cell>(g_modules.size());
}
// native get_module(id, name[], nameLen, author[], authorLen, version[], versionLen);
static cell AMX_NATIVE_CALL get_module(AMX *amx, cell *params)
{
CList<CModule>::iterator moduleIter;
int i = params[1];
for (moduleIter = g_modules.begin(); moduleIter && i; ++moduleIter)
--i;
if (i != 0 || !moduleIter)
return -1;
module_info_s *info = (*moduleIter).getInfo();
set_amxstring(amx, params[2], info->name, params[3]);
set_amxstring(amx, params[4], info->author, params[5]);
set_amxstring(amx, params[6], info->version, params[7]);
return params[1];
}
AMX_NATIVE_INFO amxmod_Natives[] = {
{ "client_cmd", client_cmd },
@ -2198,5 +2248,9 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
{ "write_short", write_short },
{ "write_string", write_string },
{ "xvar_exists", xvar_exists },
{ "is_module_loaded", is_module_loaded },
{ "is_plugin_loaded", is_plugin_loaded },
{ "get_modulesnum", get_modulesnum },
{ "get_module", get_module },
{ NULL, NULL }
};