是否有可能在C#中使用Pawn(语言)?我有一个应用程序,我想提供其他人用Pawn编写修改/插件。
我找到了JavaScript解释器Jint,但我找不到任何类似的Pawn库。
答案 0 :(得分:1)
您需要一个AMX机器库。首先,下载Pawn toolkit,然后从 amx32.dll 导入功能。请阅读Pawn Implementer Guide以获取文档。
我尝试过一次,我宁愿推荐Lua来添加其他脚本。还有更多的文档。但如果你坚持使用Pawn,这是我研究的遗迹:
const string amxlib = "amx32.dll";
[DllImport(amxlib)]
private static extern int amx_Init(IntPtr amx, IntPtr program);
[DllImport(amxlib)]
private static extern int amx_Exec(IntPtr amx, IntPtr retval, int index);
[DllImport(amxlib)]
private static extern int amx_Exec(IntPtr amx, out int retval, int index);
[DllImport(amxlib)]
private static extern int amx_Register(IntPtr amx, [MarshalAs(UnmanagedType.LPArray)] AMXNativeInfo[] list, int count);
[DllImport(amxlib)]
private static extern int amx_Register(IntPtr amx, IntPtr list, int count);
[DllImport(amxlib)]
private static extern int amx_NumNatives(IntPtr amx, out int number);
[DllImport(amxlib)]
private static extern int amx_GetNative(IntPtr amx, int index, System.Text.StringBuilder name);
[DllImport(amxlib)]
private static extern int amx_NameLength(IntPtr amx, out int length);
public delegate int AMXNativeCall(IntPtr amx, IntPtr args);
[StructLayout(LayoutKind.Sequential)]
public struct AMXNativeInfo
{
[MarshalAs(UnmanagedType.LPStr)]
public string Name;
[MarshalAs(UnmanagedType.FunctionPtr)]
public AMXNativeCall Function;
public AMXNativeInfo(string name, AMXNativeCall func)
{
Name = name;
Function = func;
}
}