25.03.2017, 18:13
I pretty much hate asking questions, but here we go, I'm searching for alternatives for these things for a few weeks already (well, since I started migrating my gamemode to C++ using sampGDK):
We can use sampgdk::InvokeNative to access functions called by other plugins. Is there any easy way to add a callback called by that plugin too ?
Using something similar to this (from sampgdk.c, amalgamation) is pretty long:
I want something which auto generates the code, or something similar (I'll also add a macro for the InvokeNative native "generation", even if it takes ~5 lines anyway).
I want to be able to add external plugins easier, as close as possible to an actual Pawn .inc file.
Also, I tried to search for this, but I didn't find anything. A tool to automatically generate a .h and .cpp from a .idl file ( https://github.com/Zeex/sampgdk/tree/master/lib/sampgdk ) without trying to compile the whole plugin would be great. Compiling sampGDK looks pretty hard. Also, I read this topic: https://sampforum.blast.hk/showthread.php?tid=574029 and I remember that I failed to use the .lib version of sampGDK, I don't remember what was the problem more exactly (I tried this few weeks ago). It's a lot easier to use the amalgamated version, even if it isn't recommended.
For example, I can use these callbacks/natives things for the MySQL and Streamer plugins, to make something like a simple .inc file for each of them. I don't want to include them in my plugin (or using C++ MySQL connector with additional libraries, maddinat0r's MySQL has all I want) because it will make updating in the future harder.
We can use sampgdk::InvokeNative to access functions called by other plugins. Is there any easy way to add a callback called by that plugin too ?
Using something similar to this (from sampgdk.c, amalgamation) is pretty long:
pawn Код:
typedef bool (SAMPGDK_CALLBACK_CALL *OnPlayerEditObject_callback)(int playerid, bool playerobject, int objectid, int response, float fX, float fY, float fZ, float fRotX, float fRotY, float fRotZ);
static bool _OnPlayerEditObject(AMX *amx, void *callback, cell *retval) {
bool retval_;
int playerid;
bool playerobject;
int objectid;
int response;
float fX;
float fY;
float fZ;
float fRotX;
float fRotY;
float fRotZ;
sampgdk_param_get_cell(amx, 0, (cell *)&playerid);
sampgdk_param_get_bool(amx, 1, (bool *)&playerobject);
sampgdk_param_get_cell(amx, 2, (cell *)&objectid);
sampgdk_param_get_cell(amx, 3, (cell *)&response);
sampgdk_param_get_float(amx, 4, (float *)&fX);
sampgdk_param_get_float(amx, 5, (float *)&fY);
sampgdk_param_get_float(amx, 6, (float *)&fZ);
sampgdk_param_get_float(amx, 7, (float *)&fRotX);
sampgdk_param_get_float(amx, 8, (float *)&fRotY);
sampgdk_param_get_float(amx, 9, (float *)&fRotZ);
sampgdk_log_debug("OnPlayerEditObject(%d, %d, %d, %d, %f, %f, %f, %f, %f, %f)", playerid, playerobject, objectid, response, fX, fY, fZ, fRotX, fRotY, fRotZ);
retval_ = ((OnPlayerEditObject_callback)callback)(playerid, playerobject, objectid, response, fX, fY, fZ, fRotX, fRotY, fRotZ);
if (retval != NULL) {
*retval = (cell)retval_;
}
return !!retval_ != true;
}
<and some more lines in other parts>
I want to be able to add external plugins easier, as close as possible to an actual Pawn .inc file.
Also, I tried to search for this, but I didn't find anything. A tool to automatically generate a .h and .cpp from a .idl file ( https://github.com/Zeex/sampgdk/tree/master/lib/sampgdk ) without trying to compile the whole plugin would be great. Compiling sampGDK looks pretty hard. Also, I read this topic: https://sampforum.blast.hk/showthread.php?tid=574029 and I remember that I failed to use the .lib version of sampGDK, I don't remember what was the problem more exactly (I tried this few weeks ago). It's a lot easier to use the amalgamated version, even if it isn't recommended.
For example, I can use these callbacks/natives things for the MySQL and Streamer plugins, to make something like a simple .inc file for each of them. I don't want to include them in my plugin (or using C++ MySQL connector with additional libraries, maddinat0r's MySQL has all I want) because it will make updating in the future harder.