04.03.2014, 17:28
(
Последний раз редактировалось [ESC]Walter_Wolf; 04.03.2014 в 18:00.
)
Thanks a lot Gamer_Z, but I was rethinking the issue, and concluded I don't need the exact address of the class. The fabulous 'sampgdk' finds and calls the (other plugin) desired functions for me, initializes the variables etc.
This is the way I did it:
... in case any other noobs like me wish to try it.
This is the way I did it:
Код:
cell mysql_connect(string * hst, string * usr, string * db, string * pass) { return (cell)sampgdk_invoke_native(sampgdk_find_native("mysql_connect"), "ssss", hst, usr, db, pass); } cell mysql_ping(cell *connectionHandle) { return (cell) sampgdk_invoke_native(sampgdk_find_native("mysql_ping"), "i", connectionHandle); } cell mysql_errno(cell *connectionHandle) { return (cell)sampgdk_invoke_native(sampgdk_find_native("mysql_errno"), "i", connectionHandle); }
Код:
PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() { ... cell i; i = mysql_connect (&SQL_HOST, &SQL_USER, &SQL_DB, &SQL_PASS); mysql_ping (&i); if(mysql_errno(&i) == 0) ServerLog::Printf("Connected"); else ServerLog::Printf("Connection failed!"); ... return true; }