callDotnetMethod - it calls the C# methodThe functions on the plugin side:
Code:Parameter's:methodName - name of the method split[] - key for parametersReturn's:i - int32 f - float s - string c - char{Float,_}:... - argumentsint32, boolean, floatcallDotnetMethodStr - An alternative to the previous function, but it records the text in variableQuote:
Due to the fact that AMX can not return a text value, it was necessary to create an alternative function based on the previous
Code:Parameter's:methodName - name of the method split[] - key for parametersAlways returns 1!i - int32 f - float s - string c - charstr[] - array for string length - array length {Float,_}:... - arguments
cpp.callRemoteCallback - It calls a function by name and passes parameters.An example of using these functions
cpp.logwrite - write message to consoleCode:Parameter's:string callback - callback name params object[] args - arguments
#include <a_samp>
native callDotnetMethod(methodName[], split[], {Float,_}:...);
native callDotnetMethodStr(methodName[], str[], len, split[], {Float,_}:...);
main(){
}
public OnGameModeInit() {
callDotnetMethod("onDotnetLoaded", "cf", 'v', 1.0);
new temp_int = callDotnetMethod("kernel.testINT", "ii", 10, 24);
printf("testINT returned: %i", temp_int);
new temp_bool = callDotnetMethod("kernel.testBOOL", "isi", 1, "boolean=)", 0);
printf("testBOOL returned: %i", temp_bool);
new temp_float = callDotnetMethod("kernel.testFLOAT", "ifcf", 10, 1.432, 'c', 242);
printf("testFLOAT returned: %f", temp_float);
new temp_str[ 16 ] ;
callDotnetMethodStr("kernel.testSTRING", temp_str, sizeof temp_str, "sss", "by", "Seregamil", "dotNET v1.0");
printf("testSTRING returned: %s", temp_str);
return true ;
}
forward onDotnetWasLoaded(str[]);
public onDotnetWasLoaded(str[]){
print(str);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace c_sharp
{
public class kernel
{
public static object onDotnetLoaded(params object[] args)
{
cpp.logwrite("dotnet-> onDotnetLoaded was called. ARGS:");
foreach (object arg in args)
{
cpp.logwrite(arg.ToString());
}
cpp.callRemoteCallback("onDotnetWasLoaded", "Hello! =)");
return true;
}
public static object testINT(params object[] args)
{
cpp.logwrite("dotnet-> testINT was called");
int a = Convert.ToInt32(args[0]);
int b = Convert.ToInt32(args[1]);
return a + b ;
}
public static object testBOOL(params object[] args)
{
cpp.logwrite("dotnet-> testBOOL was called.");
return false;
}
public static object testSTRING(params object[] args)
{
cpp.logwrite("dotnet-> testSTRING was called." );
foreach (object arg in args)
{
cpp.logwrite(string.Format("{0}: {1}",arg.GetType(), arg.ToString()));
}
return "blackJack prod.";
}
public static object testFLOAT(params object[] args)
{
cpp.logwrite("dotnet-> testFLOAT was called. ARGS:");
float result = 13.228f;
return result;
}
}
}
#define regex_match(%0,%1) callDotnetMethod("regex.Match", "ss", %0, %1)
#define regex_is_match(%0,%1) callDotnetMethod("regex.IsMatch", "ss", %0, %1)
#define regex_replace(%0,%1,%2) callDotnetMethodStr("regex.Replace", %0, sizeof(%0), "sss", %0, %1, %2)
Well... I know what it is and I can see why it's useful but could someone explain me, how is it different from creating a plugin in C++ and calling the natives in PAWN?
|
Another being we don't have the assembly key for something. |
Basically you should make the source more distributable. You should also give us a step by step instruction on building it. |
Ah sweet! I was writing random plugins like all day yesterday.
When you rewrite it could you add some AMX functions to the native side? Like the ability to execute natives. |