Zeex/sampgdk — pull request #86 by ikkentim (2014-07-05 16:02:48+00:00)
Title: Add sampgdk_InvokeNativeArray

while creating my own plugin i noticed it is in no way possible to call a native with an array of parameters. therefore i added a function. It does practically the same as sampgdk_InvokeNative, but without the use of a va_list.

sampgdk_InvokeNativeArray allows you to call a native function with an array of parameters.

Here follow a couple of example usages:
char *info = new char[100];
int len = strlen(info);

void *args[2];
args[0] = info;
args[1] = &len;

AMX_NATIVE getNetworkStats = sampgdk::FindNative("GetNetworkStats");
sampgdk::InvokeNativeArray(getNetworkStats, "Sd", args);

sampgdk::logprintf("stats: %s", info);

// ...

float gravity = 0.8;

void *args2[1];
args2[0] = &gravity;

AMX_NATIVE setGravity = sampgdk::FindNative("SetGravity");
sampgdk::InvokeNativeArray(setGravity, "f", args2);

// ...

char *gamemode = "sampgdk";

void *args3[1];
args3[0] = gamemode;

AMX_NATIVE setGameModeText = sampgdk::FindNative("SetGameModeText");
sampgdk::InvokeNativeArray(setGameModeText, "s", args3);