From ce318d366d91a9d2320e378795d2140117f03df6 Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Thu, 26 Feb 2004 19:04:03 +0000 Subject: [PATCH] added natives is_plugin_loaded(const name[]); is_module_loaded(const name[]); get_modulesnum(); get_module(id, name[], nameLen, author[], authorLen, version[], versionLen); --- amxmodx/amxmod.cpp | 114 +++++++++++++++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 30 deletions(-) diff --git a/amxmodx/amxmod.cpp b/amxmodx/amxmod.cpp index f38aa434..25a1e558 100755 --- a/amxmodx/amxmod.cpp +++ b/amxmodx/amxmod.cpp @@ -1,33 +1,33 @@ -/* AMX Mod X -* -* by the AMX Mod X Development Team -* originally developed by OLO -* -* -* 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 -* 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 -* 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, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* 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 -* 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 -* you do not wish to do so, delete this exception statement from your -* version. -*/ +/* + * Copyright (c) 2002-2003 Aleksander Naszko + * + * This file is part of AMX Mod. + * + * 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. + * + * 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 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 + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * 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 + * 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 + * you do not wish to do so, delete this exception statement from your + * version. + * + */ #include #include @@ -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::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(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::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 } }; \ No newline at end of file