diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props
index 7f03daa..6284480 100644
--- a/Source/Directory.Build.props
+++ b/Source/Directory.Build.props
@@ -1,5 +1,5 @@
- 1.0.1-alpha
+ 1.0.2-alpha
diff --git a/Template/Amxmodx.Module.Template/.template.config/template.json b/Template/Amxmodx.Module.Template/.template.config/template.json
new file mode 100644
index 0000000..95f51b3
--- /dev/null
+++ b/Template/Amxmodx.Module.Template/.template.config/template.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "http://json.schemastore.org/template",
+ "author": "CeSun",
+ "classifications": [ "GoldSrc", "Plugin", "MetaMod", "Amxmodx" ],
+ "name": "Amxmodx Module",
+ "identity": "AmxmodxModule",
+ "groupIdentity": "CeSun",
+ "shortName": "AMT",
+ "tags": {
+ "language": "C#",
+ "type": "project"
+ },
+ "sourceName": "Amxmodx.Module.Template",
+ "preferNameDirectory": true
+}
+
\ No newline at end of file
diff --git a/Template/Amxmodx.Module.Template/Amxmodx.Module.csproj b/Template/Amxmodx.Module.Template/Amxmodx.Module.Template.csproj
similarity index 70%
rename from Template/Amxmodx.Module.Template/Amxmodx.Module.csproj
rename to Template/Amxmodx.Module.Template/Amxmodx.Module.Template.csproj
index 9c03752..4616131 100644
--- a/Template/Amxmodx.Module.Template/Amxmodx.Module.csproj
+++ b/Template/Amxmodx.Module.Template/Amxmodx.Module.Template.csproj
@@ -7,11 +7,11 @@
true
true
Module
+ $(MSBuildProjectName.Replace(".", ""))_amxx
-
-
+
diff --git a/Template/Amxmodx.Module.Template/Amxmodx.Module.Template.nuspec b/Template/Amxmodx.Module.Template/Amxmodx.Module.Template.nuspec
new file mode 100644
index 0000000..845c6ef
--- /dev/null
+++ b/Template/Amxmodx.Module.Template/Amxmodx.Module.Template.nuspec
@@ -0,0 +1,15 @@
+
+
+
+ Amxmodx.Module.Template
+ 1.0.2-alpha
+ Amxmodx Module
+ CeSun
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Template/Amxmodx.Module.Template/Config.cs b/Template/Amxmodx.Module.Template/Config.cs
new file mode 100644
index 0000000..ef61637
--- /dev/null
+++ b/Template/Amxmodx.Module.Template/Config.cs
@@ -0,0 +1,9 @@
+namespace Module;
+
+static class ModuleConfig
+{
+ public const string Name = "AmxmodxModule";
+ public const string Version = "";
+ public const string Author = "";
+ public const string Url = "";
+}
\ No newline at end of file
diff --git a/Template/Amxmodx.Module.Template/Global.cs b/Template/Amxmodx.Module.Template/Global.cs
new file mode 100644
index 0000000..8c1201a
--- /dev/null
+++ b/Template/Amxmodx.Module.Template/Global.cs
@@ -0,0 +1,163 @@
+using GoldSrc.Amxmodx.Native;
+using GoldSrc.HLSDK;
+using GoldSrc.HLSDK.Native;
+using GoldSrc.MetaMod;
+using GoldSrc.MetaMod.Native;
+using System.Runtime.InteropServices;
+#pragma warning disable CS8981
+using cell = int;
+#pragma warning restore CS8981
+using size_t = uint;
+
+namespace Module;
+
+
+public unsafe static class Global
+{
+ public static DLL_FUNCTIONS g_EntityAPI_Table;
+ public static DLL_FUNCTIONS* g_pFunctionTable;
+
+ public static DLL_FUNCTIONS g_EntityAPI_Post_Table;
+ public static DLL_FUNCTIONS* g_pFunctionTable_Post;
+
+ public static NEW_DLL_FUNCTIONS g_NewFuncs_Table;
+ public static NEW_DLL_FUNCTIONS* g_pNewFunctionsTable;
+
+ public static NEW_DLL_FUNCTIONS g_NewFuncs_Post_Table;
+ public static NEW_DLL_FUNCTIONS* g_pNewFunctionsTable_Post;
+
+ public static enginefuncs_t g_EngineFuncs_Table;
+ public static enginefuncs_t* g_pengfuncsTable;
+
+ public static enginefuncs_t g_EngineFuncs_Post_Table;
+ public static enginefuncs_t* g_pEngineFuncs_Post;
+
+ public static enginefuncs_t g_engfuncs;
+ public static globalvars_t* gpGlobals;
+
+ public static meta_globals_t* gpMetaGlobals; // metamod globals
+ public static gamedll_funcs_t* gpGamedllFuncs; // gameDLL function tables
+ public static mutil_funcs_t* gpMetaUtilFuncs;
+
+ public static plugin_info_t* Plugin_info;
+ public static META_FUNCTIONS g_MetaFunctions_Table;
+
+ public static amxx_module_info_t g_ModuleInfo;
+
+ public static delegate* unmanaged[Cdecl] g_fn_RequestFunction;
+
+
+ static Global()
+ {
+ Plugin_info = (plugin_info_t*)Marshal.AllocHGlobal(sizeof(mutil_funcs_t));
+ Plugin_info->ifvers = MetaModInfo.META_INTERFACE_VERSION.GetNativeString();
+ Plugin_info->name = ModuleConfig.Name.GetNativeString();
+ Plugin_info->version = ModuleConfig.Name.GetNativeString();
+ Plugin_info->date = DateTime.Now.ToString().GetNativeString();
+ Plugin_info->author = ModuleConfig.Author.GetNativeString();
+ Plugin_info->url = ModuleConfig.Url.GetNativeString();
+ Plugin_info->logtag = ModuleConfig.Name.GetNativeString();
+ Plugin_info->loadable = PLUG_LOADTIME.PT_ANYTIME;
+ Plugin_info->unloadable = PLUG_LOADTIME.PT_ANYTIME;
+
+ g_ModuleInfo.name = Plugin_info->name;
+ g_ModuleInfo.author = Plugin_info->author;
+ g_ModuleInfo.version = Plugin_info->version;
+ g_ModuleInfo.reload = 1;
+ g_ModuleInfo.library = ModuleConfig.Name.GetNativeString();
+ g_ModuleInfo.libclass = "".GetNativeString();
+
+ }
+
+
+ public const int False = 0;
+ public const int True = 1;
+
+ public const int AMXX_OK = 0; /* no error */
+ public const int AMXX_IFVERS = 1; /* interface version */
+ public const int AMXX_PARAM = 2; /* Invalid parameter */
+ public const int AMXX_FUNC_NOT_PRESENT = 3; /* Function not present */
+
+
+ public const int AMXX_GAME_OK = 0; /* This module can load on the current game mod. */
+ public const int AMXX_GAME_BAD = 1; /* This module can not load on the current game mod. */
+
+
+
+ // amxx api
+ public static delegate* unmanaged[Cdecl] g_fn_AddNatives;
+ public static delegate* unmanaged[Cdecl] g_fn_AddNewNatives;
+ public static delegate* unmanaged[Cdecl] g_fn_BuildPathname;
+ public static delegate* unmanaged[Cdecl] g_fn_BuildPathnameR;
+ public static delegate* unmanaged[Cdecl] g_fn_GetAmxAddr;
+ public static delegate* unmanaged[Cdecl] g_fn_PrintSrvConsole;
+ public static delegate* unmanaged[Cdecl] g_fn_GetModname;
+ public static delegate* unmanaged[Cdecl] g_fn_GetAmxScriptName;
+ public static delegate* unmanaged[Cdecl] g_fn_GetAmxScript;
+ public static delegate* unmanaged[Cdecl] g_fn_FindAmxScriptByAmx;
+ public static delegate* unmanaged[Cdecl] g_fn_FindAmxScriptByName;
+ public static delegate* unmanaged[Cdecl] g_fn_SetAmxString;
+ public static delegate* unmanaged[Cdecl] g_fn_GetAmxString;
+ public static delegate* unmanaged[Cdecl] g_fn_GetAmxStringLen;
+ public static delegate* unmanaged[Cdecl] g_fn_FormatAmxString;
+ public static delegate* unmanaged[Cdecl] g_fn_CopyAmxMemory;
+ public static delegate* unmanaged[Cdecl] g_fn_Log;
+ public static delegate* unmanaged[Cdecl] g_fn_LogErrorFunc;
+ public static delegate* unmanaged[Cdecl] g_fn_RaiseAmxError;
+ public static delegate* unmanaged[Cdecl] g_fn_RegisterForward;
+ public static delegate* unmanaged[Cdecl] g_fn_ExecuteForward;
+ public static delegate* unmanaged[Cdecl] g_fn_PrepareCellArray;
+ public static delegate* unmanaged[Cdecl] g_fn_PrepareCharArray;
+ public static delegate* unmanaged[Cdecl] g_fn_PrepareCellArrayA;
+ public static delegate* unmanaged[Cdecl] g_fn_PrepareCharArrayA;
+ public static delegate* unmanaged[Cdecl] g_fn_IsPlayerValid;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerName;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerIP;
+ public static delegate* unmanaged[Cdecl] g_fn_IsPlayerIngame;
+ public static delegate* unmanaged[Cdecl] g_fn_IsPlayerBot;
+ public static delegate* unmanaged[Cdecl] g_fn_IsPlayerAuthorized;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerTime;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerPlayTime;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerFlags;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerCurweapon;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerTeam;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerTeamID;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerDeaths;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerMenu;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerKeys;
+ public static delegate* unmanaged[Cdecl] g_fn_IsPlayerAlive;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerFrags;
+ public static delegate* unmanaged[Cdecl] g_fn_IsPlayerConnecting;
+ public static delegate* unmanaged[Cdecl] g_fn_IsPlayerHLTV;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerArmor;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerHealth;
+ public static delegate* unmanaged[Cdecl] g_fn_AmxExec;
+ public static delegate* unmanaged[Cdecl] g_fn_AmxExecv;
+ public static delegate* unmanaged[Cdecl] g_fn_AmxAllot;
+ public static delegate* unmanaged[Cdecl] g_fn_AmxFindPublic;
+ public static delegate* unmanaged[Cdecl] g_fn_AmxFindNative;
+ public static delegate* unmanaged[Cdecl] g_fn_LoadAmxScript;
+ public static delegate* unmanaged[Cdecl] g_fn_UnloadAmxScript;
+ public static delegate* unmanaged[Cdecl] g_fn_RealToCell;
+ public static delegate* unmanaged[Cdecl] g_fn_CellToReal;
+ public static delegate* unmanaged[Cdecl] g_fn_RegisterSPForward;
+ public static delegate* unmanaged[Cdecl] g_fn_RegisterSPForwardByName;
+ public static delegate* unmanaged[Cdecl] g_fn_UnregisterSPForward;
+ public static delegate* unmanaged[Cdecl] g_fn_MergeDefinition_File;
+ public static delegate* unmanaged[Cdecl] g_fn_Format;
+ public static delegate* unmanaged[Cdecl] g_fn_RegisterFunction;
+ public static delegate* unmanaged[Cdecl] g_fn_AmxPush;
+ public static delegate* unmanaged[Cdecl] g_fn_SetTeamInfo;
+ public static delegate* unmanaged[Cdecl], void> g_fn_RegAuthFunc;
+ public static delegate* unmanaged[Cdecl], void> g_fn_UnregAuthFunc;
+ public static delegate* unmanaged[Cdecl] g_fn_FindLibrary;
+ public static delegate* unmanaged[Cdecl] g_fn_AddLibraries;
+ public static delegate* unmanaged[Cdecl] g_fn_RemoveLibraries;
+ public static delegate* unmanaged[Cdecl] g_fn_OverrideNatives;
+ public static delegate* unmanaged[Cdecl] g_fn_GetLocalInfo;
+ public static delegate* unmanaged[Cdecl] g_fn_AmxReRegister;
+ public static delegate* unmanaged[Cdecl] g_fn_RegisterFunctionEx;
+ public static delegate* unmanaged[Cdecl] g_fn_MessageBlock;
+ public static delegate* unmanaged[Cdecl] g_fn_GetPlayerEdict;
+ public static delegate* unmanaged[Cdecl] g_fn_PlayerPropAddr;
+}
diff --git a/Template/Amxmodx.Module.Template/Module.cs b/Template/Amxmodx.Module.Template/Module.cs
index 4d33de3..bf1c429 100644
--- a/Template/Amxmodx.Module.Template/Module.cs
+++ b/Template/Amxmodx.Module.Template/Module.cs
@@ -1,121 +1,497 @@
-using System.Runtime.CompilerServices;
+using GoldSrc.Amxmodx;
+using GoldSrc.Amxmodx.Native;
+using GoldSrc.HLSDK;
+using GoldSrc.HLSDK.Native;
+using GoldSrc.MetaMod;
+using GoldSrc.MetaMod.Native;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using static Module.Global;
namespace Module;
-public static class Module
+public unsafe static class Module
{
+ static Module()
+ {
+ g_MetaFunctions_Table.pfnGetEntityAPI2 = &GetEntityAPI2;
+ g_MetaFunctions_Table.pfnGetEntityAPI2_Post = &GetEntityAPI2_Post;
+ g_MetaFunctions_Table.pfnGetNewDLLFunctions = &GetNewDLLFunctions;
+ g_MetaFunctions_Table.pfnGetNewDLLFunctions_Post = &GetNewDLLFunctions_Post;
+ g_MetaFunctions_Table.pfnGetEngineFunctions = &GetEngineFunctions;
+ g_MetaFunctions_Table.pfnGetEngineFunctions_Post = &GetEngineFunctions_Post;
+ }
+
[UnmanagedCallersOnly(EntryPoint = "GetEntityAPI2", CallConvs = [typeof(CallConvCdecl)])]
- public static int GetEntityAPI2(nint pFunctionTable, nint interfaceVersion)
+ public static int GetEntityAPI2(DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion)
{
- return 1;
+ if (pFunctionTable == null)
+ return False;
+ if (*interfaceVersion != HLSDKInfo.INTERFACE_VERSION)
+ {
+ *interfaceVersion = HLSDKInfo.INTERFACE_VERSION;
+ return False;
+ }
+ *pFunctionTable = g_EntityAPI_Table;
+ g_pFunctionTable = pFunctionTable;
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "GetEntityAPI2_Post", CallConvs = [typeof(CallConvCdecl)])]
- public static int GetEntityAPI2_Post(nint pFunctionTable, nint interfaceVersion)
+ public static int GetEntityAPI2_Post(DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion)
{
- return 1;
+ if (pFunctionTable == null)
+ return False;
+ if (*interfaceVersion != HLSDKInfo.INTERFACE_VERSION)
+ {
+ *interfaceVersion = HLSDKInfo.INTERFACE_VERSION;
+ return False;
+ }
+ *pFunctionTable = g_EntityAPI_Post_Table;
+ g_pFunctionTable_Post = pFunctionTable;
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "GetEngineFunctions", CallConvs = [typeof(CallConvCdecl)])]
- public static int GetEngineFunctions(nint pFunctionTable, nint interfaceVersion)
+ public static int GetEngineFunctions(enginefuncs_t* pengfuncsFromEngine, int* interfaceVersion)
{
- return 1;
+ if (pengfuncsFromEngine == null)
+ return False;
+ if (*interfaceVersion != MetaModInfo.ENGINE_INTERFACE_VERSION)
+ {
+ *interfaceVersion = MetaModInfo.ENGINE_INTERFACE_VERSION;
+ return False;
+ }
+ *pengfuncsFromEngine = g_EngineFuncs_Table;
+ g_pengfuncsTable = pengfuncsFromEngine;
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "GetEngineFunctions_Post", CallConvs = [typeof(CallConvCdecl)])]
- public static int GetEngineFunctions_Post(nint pFunctionTable, nint interfaceVersion)
+ public static int GetEngineFunctions_Post(enginefuncs_t* pengfuncsFromEngine, int* interfaceVersion)
{
- return 1;
+ if (pengfuncsFromEngine == null)
+ return False;
+ if (*interfaceVersion != MetaModInfo.ENGINE_INTERFACE_VERSION)
+ {
+ *interfaceVersion = MetaModInfo.ENGINE_INTERFACE_VERSION;
+ return False;
+ }
+ *pengfuncsFromEngine = g_EngineFuncs_Post_Table;
+ g_pEngineFuncs_Post = pengfuncsFromEngine;
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "GetNewDLLFunctions", CallConvs = [typeof(CallConvCdecl)])]
- public static int GetNewDLLFunctions(nint pNewFunctionTable, nint interfaceVersion)
+ public static int GetNewDLLFunctions(NEW_DLL_FUNCTIONS* pNewFunctionTable, int* interfaceVersion)
{
- return 1;
+ if (pNewFunctionTable == null)
+ return False;
+ if (*interfaceVersion != HLSDKInfo.NEW_DLL_FUNCTIONS_VERSION)
+ {
+ *interfaceVersion = HLSDKInfo.NEW_DLL_FUNCTIONS_VERSION;
+ return False;
+ }
+ *pNewFunctionTable = g_NewFuncs_Table;
+ g_pNewFunctionsTable = pNewFunctionTable;
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "GetNewDLLFunctions_Post", CallConvs = [typeof(CallConvCdecl)])]
- public static int GetNewDLLFunctions_Post(nint pNewFunctionTable, nint interfaceVersion)
+ public static int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS* pNewFunctionTable, int* interfaceVersion)
{
- return 1;
+ if (pNewFunctionTable == null)
+ return False;
+ if (*interfaceVersion != HLSDKInfo.NEW_DLL_FUNCTIONS_VERSION)
+ {
+ *interfaceVersion = HLSDKInfo.NEW_DLL_FUNCTIONS_VERSION;
+ return False;
+ }
+ *pNewFunctionTable = g_NewFuncs_Post_Table;
+ g_pNewFunctionsTable_Post = pNewFunctionTable;
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "Meta_Query", CallConvs = [typeof(CallConvCdecl)])]
- public static int Meta_Query(nint ifvers, nint pPlugInfo, nint pMetaUtilFuncs)
+ public static int Meta_Query(sbyte* ifvers, plugin_info_t** pPlugInfo, mutil_funcs_t* pMetaUtilFuncs)
{
- return 1;
+ if (pMetaUtilFuncs == null)
+ {
+ return False;
+ }
+ gpMetaUtilFuncs = pMetaUtilFuncs;
+ *pPlugInfo = Plugin_info;
+
+ var frameVersion = Marshal.PtrToStringAnsi((nint)ifvers)!;
+ var list = frameVersion.Split(":");
+ var mmajor = int.Parse(list[0]);
+ var mminor = int.Parse(list[1]);
+
+ list = MetaModInfo.META_INTERFACE_VERSION.Split(":");
+ var pmajor = int.Parse(list[0]);
+ var pminor = int.Parse(list[1]);
+
+ if (pmajor > mmajor || (pmajor == mmajor && pminor > mminor))
+ return False;
+ else if (pmajor < mmajor)
+ return False;
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "Meta_Attach", CallConvs = [typeof(CallConvCdecl)])]
- public static int Meta_Attach(PLUG_LOADTIME now, nint pFunctionTable, nint pMGlobals, nint pGamedllFuncs)
+ public static int Meta_Attach(PLUG_LOADTIME now, META_FUNCTIONS* pFunctionTable, meta_globals_t* pMGlobals, gamedll_funcs_t* pGamedllFuncs)
{
- return 1;
+ if ((int)now > (int)Plugin_info->loadable)
+ return False;
+ if (pMGlobals == null)
+ return False;
+ gpMetaGlobals = pMGlobals;
+ if (pFunctionTable == null)
+ return False;
+ *pFunctionTable = g_MetaFunctions_Table;
+ gpGamedllFuncs = pGamedllFuncs;
+ Plugin.FN_META_ATTACH();
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "Meta_Detach", CallConvs = [typeof(CallConvCdecl)])]
public static int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
{
- return 1;
+ if (now > Plugin_info->unloadable && reason != PL_UNLOAD_REASON.PNL_CMD_FORCED)
+ return False;
+ Plugin.FN_META_DETACH();
+ return True;
}
[UnmanagedCallersOnly(EntryPoint = "GiveFnptrsToDll", CallConvs = [typeof(CallConvStdcall)])]
- public static void GiveFnptrsToDll(nint pengfuncsFromEngine, nint pGlobals)
+ public static void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t* pGlobals)
{
-
+ g_engfuncs = *pengfuncsFromEngine;
+ gpGlobals = pGlobals;
}
[UnmanagedCallersOnly(EntryPoint = "AMXX_Query", CallConvs = [typeof(CallConvCdecl)])]
- public static int AMXX_Query(nint interfaceVersion, nint moduleInfo)
+ public static int AMXX_Query(int* interfaceVersion, amxx_module_info_t* moduleInfo)
{
- return 1;
+ if (interfaceVersion == null || moduleInfo == null)
+ return AMXX_PARAM;
+ if (*interfaceVersion != AmxxInfo.AMXX_INTERFACE_VERSION)
+ {
+ *interfaceVersion = AmxxInfo.AMXX_INTERFACE_VERSION;
+ return AMXX_IFVERS;
+ }
+ *moduleInfo = g_ModuleInfo;
+ Plugin.FN_AMXX_QUERY();
+ return AMXX_OK;
}
[UnmanagedCallersOnly(EntryPoint = "AMXX_CheckGame", CallConvs = [typeof(CallConvCdecl)])]
public static int AMXX_CheckGame(nint game)
{
- return 1;
+ Plugin.FN_AMXX_CHECKGAME((sbyte*)game);
+ return AMXX_GAME_OK;
}
[UnmanagedCallersOnly(EntryPoint = "AMXX_Attach", CallConvs = [typeof(CallConvCdecl)])]
- public static int AMXX_Attach(nint reqFnptrFunc)
- {
- return 1;
+ public static int AMXX_Attach(delegate* unmanaged[Cdecl] reqFnptrFunc)
+ {
+ if (reqFnptrFunc == null)
+ return AMXX_PARAM;
+ var size = sizeof(AMX);
+ g_fn_RequestFunction = reqFnptrFunc;
+ using (var funName = "BuildPathname".GetNativeString())
+ {
+ g_fn_BuildPathname = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "BuildPathnameR".GetNativeString())
+ {
+ g_fn_BuildPathnameR = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "PrintSrvConsole".GetNativeString())
+ {
+ g_fn_PrintSrvConsole = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetModname".GetNativeString())
+ {
+ g_fn_GetModname = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "Log".GetNativeString())
+ {
+ g_fn_Log = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "LogError".GetNativeString())
+ {
+ g_fn_LogErrorFunc = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "MergeDefinitionFile".GetNativeString())
+ {
+ g_fn_MergeDefinition_File = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "Format".GetNativeString())
+ {
+ g_fn_Format = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RegisterFunction".GetNativeString())
+ {
+ g_fn_RegisterFunction = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RegisterFunctionEx".GetNativeString())
+ {
+ g_fn_RegisterFunctionEx = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetAmxScript".GetNativeString())
+ {
+ g_fn_GetAmxScript = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "FindAmxScriptByAmx".GetNativeString())
+ {
+ g_fn_FindAmxScriptByAmx = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "FindAmxScriptByName".GetNativeString())
+ {
+ g_fn_FindAmxScriptByName = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "LoadAmxScript".GetNativeString())
+ {
+ g_fn_LoadAmxScript = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "UnloadAmxScript".GetNativeString())
+ {
+ g_fn_UnloadAmxScript = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetAmxScriptName".GetNativeString())
+ {
+ g_fn_GetAmxScriptName = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "SetAmxString".GetNativeString())
+ {
+ g_fn_SetAmxString = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetAmxString".GetNativeString())
+ {
+ g_fn_GetAmxString = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetAmxStringLen".GetNativeString())
+ {
+ g_fn_GetAmxStringLen = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "FormatAmxString".GetNativeString())
+ {
+ g_fn_FormatAmxString = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "CopyAmxMemory".GetNativeString())
+ {
+ g_fn_CopyAmxMemory = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetAmxAddr".GetNativeString())
+ {
+ g_fn_GetAmxAddr = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "AddNatives".GetNativeString())
+ {
+ g_fn_AddNatives = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "AddNewNatives".GetNativeString())
+ {
+ g_fn_AddNewNatives = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RaiseAmxError".GetNativeString())
+ {
+ g_fn_RaiseAmxError = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RegisterForward".GetNativeString())
+ {
+ g_fn_RegisterForward = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RegisterSPForward".GetNativeString())
+ {
+ g_fn_RegisterSPForward = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RegisterSPForwardByName".GetNativeString())
+ {
+ g_fn_RegisterSPForwardByName = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "UnregisterSPForward".GetNativeString())
+ {
+ g_fn_UnregisterSPForward = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "ExecuteForward".GetNativeString())
+ {
+ g_fn_ExecuteForward = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "PrepareCharArray".GetNativeString())
+ {
+ g_fn_PrepareCharArray = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "PrepareCellArrayA".GetNativeString())
+ {
+ g_fn_PrepareCellArrayA = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "PrepareCharArrayA".GetNativeString())
+ {
+ g_fn_PrepareCharArrayA = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "IsPlayerValid".GetNativeString())
+ {
+ g_fn_IsPlayerValid = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerName".GetNativeString())
+ {
+ g_fn_GetPlayerName = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerIP".GetNativeString())
+ {
+ g_fn_GetPlayerIP = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "IsPlayerInGame".GetNativeString())
+ {
+ g_fn_IsPlayerIngame = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "IsPlayerBot".GetNativeString())
+ {
+ g_fn_IsPlayerBot = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "IsPlayerAuthorized".GetNativeString())
+ {
+ g_fn_IsPlayerAuthorized = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerTime".GetNativeString())
+ {
+ g_fn_GetPlayerTime = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerPlayTime".GetNativeString())
+ {
+ g_fn_GetPlayerPlayTime = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerCurweapon".GetNativeString())
+ {
+ g_fn_GetPlayerCurweapon = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerTeam".GetNativeString())
+ {
+ g_fn_GetPlayerTeam = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerDeaths".GetNativeString())
+ {
+ g_fn_GetPlayerDeaths = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerMenu".GetNativeString())
+ {
+ g_fn_GetPlayerMenu = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerKeys".GetNativeString())
+ {
+ g_fn_GetPlayerKeys = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "IsPlayerAlive".GetNativeString())
+ {
+ g_fn_IsPlayerAlive = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerFrags".GetNativeString())
+ {
+ g_fn_GetPlayerFrags = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "IsPlayerConnecting".GetNativeString())
+ {
+ g_fn_IsPlayerConnecting = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "IsPlayerHLTV".GetNativeString())
+ {
+ g_fn_IsPlayerHLTV = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerArmor".GetNativeString())
+ {
+ g_fn_GetPlayerArmor = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerHealth".GetNativeString())
+ {
+ g_fn_GetPlayerHealth = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerFlags".GetNativeString())
+ {
+ g_fn_GetPlayerFlags = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetPlayerEdict".GetNativeString())
+ {
+ g_fn_GetPlayerEdict = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "amx_Push".GetNativeString())
+ {
+ g_fn_AmxPush = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "SetPlayerTeamInfo".GetNativeString())
+ {
+ g_fn_SetTeamInfo = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "PlayerPropAddr".GetNativeString())
+ {
+ g_fn_PlayerPropAddr = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RegAuthFunc".GetNativeString())
+ {
+ g_fn_RegAuthFunc = (delegate* unmanaged[Cdecl], void>)reqFnptrFunc(funName);
+ }
+ using (var funName = "UnregAuthFunc".GetNativeString())
+ {
+ g_fn_UnregAuthFunc = (delegate* unmanaged[Cdecl], void>)reqFnptrFunc(funName);
+ }
+ using (var funName = "FindLibrary".GetNativeString())
+ {
+ g_fn_FindLibrary = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "AddLibraries".GetNativeString())
+ {
+ g_fn_AddLibraries = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "RemoveLibraries".GetNativeString())
+ {
+ g_fn_RemoveLibraries = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "OverrideNatives".GetNativeString())
+ {
+ g_fn_OverrideNatives = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "GetLocalInfo".GetNativeString())
+ {
+ g_fn_GetLocalInfo = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "AmxReregister".GetNativeString())
+ {
+ g_fn_AmxReRegister = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ using (var funName = "MessageBlock".GetNativeString())
+ {
+ g_fn_MessageBlock = (delegate* unmanaged[Cdecl])reqFnptrFunc(funName);
+ }
+ Plugin.FN_AMXX_ATTACH();
+ return AMXX_OK;
}
[UnmanagedCallersOnly(EntryPoint = "AMXX_Detach", CallConvs = [typeof(CallConvCdecl)])]
public static int AMXX_Detach()
{
- return 1;
+ Plugin.FN_AMXX_DETACH();
+ return AMXX_OK;
}
[UnmanagedCallersOnly(EntryPoint = "AMXX_PluginsLoaded", CallConvs = [typeof(CallConvCdecl)])]
public static int AMXX_PluginsLoaded()
{
- return 1;
+ Plugin.FN_AMXX_PLUGINSLOADED();
+ return AMXX_OK;
}
[UnmanagedCallersOnly(EntryPoint = "AMXX_PluginsUnloaded", CallConvs = [typeof(CallConvCdecl)])]
public static void AMXX_PluginsUnloaded()
{
+ Plugin.FN_AMXX_PLUGINSUNLOADED();
}
[UnmanagedCallersOnly(EntryPoint = "AMXX_PluginsUnloading", CallConvs = [typeof(CallConvCdecl)])]
public static void AMXX_PluginsUnloading()
{
-
+ Plugin.FN_AMXX_PLUGINSUNLOADING();
}
}
-
-
-public struct PLUG_LOADTIME
-{
-
-}
-
-public struct PL_UNLOAD_REASON
-{
-
-}
\ No newline at end of file
diff --git a/Template/Amxmodx.Module.Template/Plugin.cs b/Template/Amxmodx.Module.Template/Plugin.cs
new file mode 100644
index 0000000..a810207
--- /dev/null
+++ b/Template/Amxmodx.Module.Template/Plugin.cs
@@ -0,0 +1,86 @@
+using GoldSrc.Amxmodx.Native;
+using GoldSrc.HLSDK;
+using GoldSrc.HLSDK.Native;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using static Module.Global;
+#pragma warning disable CS8981
+using cell = int;
+#pragma warning restore CS8981
+
+
+namespace Module;
+
+public unsafe class Plugin
+{
+ public static AMX_NATIVE_INFO* nativeInfo = null;
+ static Plugin()
+ {
+ nativeInfo = (AMX_NATIVE_INFO*)Marshal.AllocHGlobal(sizeof(AMX_NATIVE_INFO) * 2);
+
+ nativeInfo[0].name = "TestHelloModule".GetNativeString();
+ nativeInfo[0].func = (nint)(delegate* unmanaged[Cdecl])&Plugin.TestHelloModule;
+
+
+ nativeInfo[1].name = null;
+ nativeInfo[1].func = nint.Zero;
+ }
+
+ public static void FN_META_QUERY()
+ {
+
+ }
+
+ public static void FN_META_ATTACH()
+ {
+
+ }
+
+ public static void FN_META_DETACH()
+ {
+
+ }
+
+ public static void FN_AMXX_QUERY()
+ {
+
+ }
+
+ public static int FN_AMXX_CHECKGAME(sbyte* game)
+ {
+ return AMXX_GAME_OK;
+ }
+
+ public static void FN_AMXX_ATTACH()
+ {
+ // 测试注册函数
+ g_fn_AddNatives(Plugin.nativeInfo);
+ }
+
+ public static void FN_AMXX_DETACH()
+ {
+ }
+
+ public static void FN_AMXX_PLUGINSLOADED()
+ {
+ }
+
+ public static void FN_AMXX_PLUGINSUNLOADING()
+ {
+
+ }
+ public static void FN_AMXX_PLUGINSUNLOADED()
+ {
+
+ }
+
+
+
+ [UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])]
+ public static cell TestHelloModule(AMX* amx, cell* @params)
+ {
+ using var s = "TestHelloModule\n".GetNativeString();
+ g_engfuncs.pfnServerPrint(s);
+ return 1;
+ }
+}
diff --git a/Template/Metahook.Plugin.Template/Metahook.Plugin.Template.csproj b/Template/Metahook.Plugin.Template/Metahook.Plugin.Template.csproj
index 8fc18ec..dbb6063 100644
--- a/Template/Metahook.Plugin.Template/Metahook.Plugin.Template.csproj
+++ b/Template/Metahook.Plugin.Template/Metahook.Plugin.Template.csproj
@@ -10,7 +10,7 @@
-
+
| | | | |