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:
parent
3abcd68bba
commit
ce318d366d
|
@ -1,33 +1,33 @@
|
||||||
/* 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.
|
||||||
*
|
*
|
||||||
*
|
* AMX Mod is free software; you can redistribute it and/or modify it
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* under the terms of the GNU General Public License as published by the
|
||||||
* under the terms of the GNU General Public License as published by the
|
* Free Software Foundation; either version 2 of the License, or (at
|
||||||
* Free Software Foundation; either version 2 of the License, or (at
|
* your option) any later version.
|
||||||
* your option) any later version.
|
*
|
||||||
*
|
* AMX Mod is distributed in the hope that it will be useful, but
|
||||||
* This program is distributed in the hope that it will be useful, but
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* General Public License for more details.
|
||||||
* General Public License for more details.
|
*
|
||||||
*
|
* You should have received a copy of the GNU General Public License
|
||||||
* You should have received a copy of the GNU General Public License
|
* along with AMX Mod; if not, write to the Free Software Foundation,
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
*
|
||||||
*
|
* In addition, as a special exception, the author gives permission to
|
||||||
* In addition, as a special exception, the author gives permission to
|
* link the code of this program with the Half-Life Game Engine ("HL
|
||||||
* link the code of this program with the Half-Life Game Engine ("HL
|
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
* respects for all of the code used other than the HL Engine and MODs
|
||||||
* respects for all of the code used other than the HL Engine and MODs
|
* from Valve. If you modify this file, you may extend this exception
|
||||||
* from Valve. If you modify this file, you may extend this exception
|
* to your version of the file, but you are not obligated to do so. If
|
||||||
* 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
|
||||||
* you do not wish to do so, delete this exception statement from your
|
* version.
|
||||||
* version.
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <extdll.h>
|
#include <extdll.h>
|
||||||
#include <meta_api.h>
|
#include <meta_api.h>
|
||||||
|
@ -2060,7 +2060,57 @@ static cell AMX_NATIVE_CALL register_logevent(AMX *amx, cell *params)
|
||||||
return 1;
|
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[] = {
|
AMX_NATIVE_INFO amxmod_Natives[] = {
|
||||||
{ "client_cmd", client_cmd },
|
{ "client_cmd", client_cmd },
|
||||||
|
@ -2198,5 +2248,9 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
|
||||||
{ "write_short", write_short },
|
{ "write_short", write_short },
|
||||||
{ "write_string", write_string },
|
{ "write_string", write_string },
|
||||||
{ "xvar_exists", xvar_exists },
|
{ "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 }
|
{ NULL, NULL }
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user