SA-MP Forums Archive
Gamemode SDK for C/C++ (GDK) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: Gamemode SDK for C/C++ (GDK) (/showthread.php?tid=421090)

Pages: 1 2 3 4 5 6 7 8 9 10 11


Re: Gamemode SDK for C/C++ (GDK) - iggy1 - 01.12.2014

I used this
pawn Код:
#include <sampgdk/sampgdk.h>

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) { return sampgdk::Load(ppData); }
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() { return sampgdk::Supports() | SUPPORTS_PROCESS_TICK; }
PLUGIN_EXPORT void PLUGIN_CALL Unload() { sampgdk::Unload(); }
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() { sampgdk::ProcessTick();
As soon as i connect to the server (even though OnPlayerConnect isn't defined)
Код:
[14:24:56] [debug] Run time error 20: "Invalid index parameter (bad entry point)"
Only happened since updating to 4.2 i was wrong earlier this happens when linking to the dynamic libs too, i hadnt updated them to 4.2 at that point just the static libs.

PS, I use visual studio so the 'SAMPGDK_AMALGAMATION' definition is in my preprocessor definitions in project properties.


Re: Gamemode SDK for C/C++ (GDK) - GWMPT - 01.12.2014

Well, I'm out of possible fixes then.


Re: Gamemode SDK for C/C++ (GDK) - iggy1 - 01.12.2014

Went back to 4.1 and it's fine. Just wondering if there are any additional steps to setup 4.2 compared to 4.1?


Re: Gamemode SDK for C/C++ (GDK) - xeeZ - 01.12.2014

iggy1: You can safely ignore this error or turn crashdetect off if it bothers you. It's not a bug or something, just need to update crasdhetect to support the new callback system in GDK 4.2. I've already committed a fix for this but haven't released it yet (edit: https://github.com/Zeex/samp-plugin-...es/tag/v4.15.1).

BTW callbacks are bugged in 4.2, you don't want to update to it unless you're not using an empty gamemode because there's a bug where if a callback exists in the gamemode it won't work in the plugin. This will be fixed in 4.2.1 (it's already fixed in git in case you want to check).

diclofoss: I think you need to install a 32-bit libstdc++. I'm not sure how would you do this in CentOS but in Debian-based distrois you would install gcc-multilib and g++-multilib.


Re: Gamemode SDK for C/C++ (GDK) - iggy1 - 01.12.2014

Thanks for the reply, the problem i had would have been the callback bug. When i saw the runtime error in the log i thought that is what was causing it. Will update to 4.2.1 now nice1.


Re: Gamemode SDK for C/C++ (GDK) - Baltazar - 24.12.2014

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Define SAMPGDK_AMALGAMATION globally, not just for one file (in compiler options / project properties). Or you can define it in sampgdk.c but I wouldn't recommend doing this as you'd have to edit the file with each sampgdk update.
[project properties] -> C/C++ -> Preprocessor -> Preprocessor definitions. Is this the field to add samgdk constant? If yes, it doesnt help . Neither helps defining this inside the samgdk.h


Re: Gamemode SDK for C/C++ (GDK) - GWMPT - 24.12.2014

This is the preprocessor definitions of my plugin, SAMPHP.
https://imgur.com/swry8UU
Remove the
Код:
#define SAMPGDK_AMALGAMATION
From your code, and add it on your preprocessor definitions.
Clean up the project, and build it.


Re: Gamemode SDK for C/C++ (GDK) - Baltazar - 24.12.2014

Quote:
Originally Posted by GWMPT
Посмотреть сообщение
This is the preprocessor definitions of my plugin, SAMPHP.
https://imgur.com/swry8UU
Remove the
Код:
#define SAMPGDK_AMALGAMATION
From your code, and add it on your preprocessor definitions.
Clean up the project, and build it.
Done. Same...
Tried to leave this constant not defined. Getting compile-time warnings, though it compiles and gives no different result at run-time.


Re: Gamemode SDK for C/C++ (GDK) - xeeZ - 24.12.2014

Can you show your project (with all files)?


Re: Gamemode SDK for C/C++ (GDK) - Baltazar - 24.12.2014

Here is an example source code I've just made. It gives the same error:

Код:
#include ".\SDK\plugin.h"
#include ".\sampgdk\sampgdk.h"

//
extern void * pAMXFunctions;

//
typedef void (*logprintf_t)(char* format, ...);
logprintf_t logprintf;

cell AMX_NATIVE_CALL test(AMX * amx, cell * params){
  char test[] = "test message";
  SendClientMessage(params[1], 0xFFFFFFFF, test);

  return 0;
}

AMX_NATIVE_INFO PluginNatives[] = {
  {"test", test},
  {0, 0}
};

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports(){

  return sampgdk::Supports() | SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES | SUPPORTS_PROCESS_TICK;
}

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData){
  pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
  logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];

  return sampgdk::Load(ppData);
}

PLUGIN_EXPORT void PLUGIN_CALL Unload(){
  sampgdk::Unload();
}

PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx){

  return amx_Register(amx, PluginNatives, -1);
}


PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx){

  return AMX_ERR_NONE;
}

PLUGIN_EXPORT void PLUGIN_CALL ProcessTick(){
  sampgdk::ProcessTick();
}
http://s27.postimg.org/pkclb06iq/example_plugin.jpg

Using project settings:
SAMPGDK_AMALGAMATION is globally defined
.def file is defined
additional include directories defined


Re: Gamemode SDK for C/C++ (GDK) - GWMPT - 24.12.2014

Quote:
Originally Posted by Baltazar
Посмотреть сообщение
Here is an example source code I've just made. It gives the same error:

Код:
#include ".\SDK\plugin.h"
#include ".\sampgdk\sampgdk.h"

//
extern void * pAMXFunctions;

//
typedef void (*logprintf_t)(char* format, ...);
logprintf_t logprintf;

cell AMX_NATIVE_CALL test(AMX * amx, cell * params){
  char test[] = "test message";
  SendClientMessage(params[1], 0xFFFFFFFF, test);

  return 0;
}

AMX_NATIVE_INFO PluginNatives[] = {
  {"test", test},
  {0, 0}
};

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports(){

  return sampgdk::Supports() | SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES | SUPPORTS_PROCESS_TICK;
}

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData){
  pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
  logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];

  return sampgdk::Load(ppData);
}

PLUGIN_EXPORT void PLUGIN_CALL Unload(){
  sampgdk::Unload();
}

PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx){

  return amx_Register(amx, PluginNatives, -1);
}


PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx){

  return AMX_ERR_NONE;
}

PLUGIN_EXPORT void PLUGIN_CALL ProcessTick(){
  sampgdk::ProcessTick();
}
http://s27.postimg.org/pkclb06iq/example_plugin.jpg

Using project settings:
SAMPGDK_AMALGAMATION is globally defined
.def file is defined
additional include directories defined
Try this code:
pawn Код:
#include <SDK/plugincommon.h>
#include <SDK/amx/amx.h>
#include <sampgdk/sampgdk.h>

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
    return sampgdk::Load(ppData);
}

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
    sampgdk::logprintf(" Hello there!");
    return sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
}

PLUGIN_EXPORT void PLUGIN_CALL Unload() {
    sampgdk::Unload();
}

PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
    sampgdk::ProcessTick();
}

PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
    SendRconCommand("echo initialized.");
}
And give me a feedback.
(On def file, add OnGameModeInit, and remove AmxLoad & AmxUnload)
This is just a test.


Re: Gamemode SDK for C/C++ (GDK) - Baltazar - 24.12.2014

Код:
#include ".\SDK\plugincommon.h"
#include ".\SDK\amx\amx.h"
#include ".\sampgdk\sampgdk.h"

PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
    return sampgdk::Load(ppData);
}

PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
    sampgdk::logprintf(" Hello there!");
    return sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
}

PLUGIN_EXPORT void PLUGIN_CALL Unload() {
    sampgdk::Unload();
}

PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
    sampgdk::ProcessTick();
}

PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
    SendRconCommand("echo initialized.");

    return true;
}
Код:
EXPORTS
	Supports
	Load
	Unload
        OnGameModeInit
	ProcessTick
error message:
[24-12-2014, 18:13:58] [sampgdk:warning] Native function not found: SendRconCommand
[24-12-2014, 18:13:58] [sampgdk:warning] Native stub

it prints out "hello there" into console window. No such record in logfile.


Re: Gamemode SDK for C/C++ (GDK) - xeeZ - 25.12.2014

Your code worked perfectly fine for me. And by all files I mean _ALL_ files, inclding the project file.


Re: Gamemode SDK for C/C++ (GDK) - Baltazar - 25.12.2014

Here: http://www.solidfiles.com/d/5a7e4a29...le_project.rar


Re: Gamemode SDK for C/C++ (GDK) - xeeZ - 25.12.2014

Thanks, but it's still working. You must be doing something differently.

Can you just upload the whole server where you're experiencing this error, with the actual code that you're running (not some stripped down version of it)?


Re: Gamemode SDK for C/C++ (GDK) - BoPoH - 09.05.2015

I wanted to update my server to 0.3.7.
I used GDK (not amalgamation).
I've got this:
Код HTML:
[03:14:36] [sampgdk:warning] Index mismatch for OnIncomingConnection (-10005 != -10007)
[03:14:36] [join] BoPoH has joined the server (0:127.0.0.1)
[03:14:36] [sampgdk:warning] Index mismatch for OnPlayerConnect (-10012 != -10014)
[03:14:36] [sampgdk:warning] Index mismatch for OnPlayerRequestClass (-10029 != -10032)
[03:14:37] [sampgdk:warning] Index mismatch for OnPlayerRequestSpawn (-10030 != -10033)
[03:14:37] [sampgdk:warning] Index mismatch for OnPlayerStateChange (-10034 != -10037)
[03:14:37] [sampgdk:warning] Index mismatch for OnPlayerSpawn (-10033 != -10036)
[03:14:37] [sampgdk:warning] Index mismatch for OnPlayerStateChange (-10034 != -10037)
[03:14:37] [sampgdk:warning] Index mismatch for OnPlayerUpdate (-10039 != -10042)
[03:14:38] [sampgdk:warning] Index mismatch for OnPlayerUpdate (-10039 != -10042)
[03:14:38] [sampgdk:warning] Index mismatch for OnPlayerUpdate (-10039 != -10042)
I tried to use amalgamation, but the result was the same.
I use also two plugins: crashdetect and streamer.
On 0.3z-R4 everything worked perfectly.


Respuesta: Gamemode SDK for C/C++ (GDK) - Axxe - 24.05.2015

Hello Zeex, everything works perfect. How do i compile for linux ?

I asked half a world and no response, I hope you can help me.

I am trying to get a file .so on Linux, don't know how to do it. thank you.


Re: Gamemode SDK for C/C++ (GDK) - kurta999 - 24.05.2015

It's fucking easy.. Here I makefile what I'm using:

https://github.com/kurta999/YSF/blob/YSF_/makefile

cd your/folder/location/here
make


Re: Gamemode SDK for C/C++ (GDK) - SoNikMells - 24.05.2015

Delete


Re: Gamemode SDK for C/C++ (GDK) - ReDKiiL - 27.05.2015

I'm in trouble, I'm trying to create a test function in my plugin.
When I run my server it crashes and I get this error in the log:

Код:
[00:32:06] [debug] Server crashed due to an unknown error
[00:32:06] [debug] Native backtrace:
[00:32:06] [debug] #0 0fa72f5a in amx_Register () from plugins\helloworld.DLL
[00:32:06] [debug] #1 0fa737e3 in AmxLoad () from plugins\helloworld.DLL
[00:32:06] [debug] #2 00469a75 in ?? () from samp-server.exe
[00:32:06] [debug] #3 65646f6d in ?? () from samp-server.exe
[00:32:06] [debug] #4 61622f73 in ?? () from samp-server.exe
[00:32:06] [debug] #5 612e6573 in ?? () from samp-server.exe
My source:

http://pastebin.com/REwswUUY

I'm using samp gdk amalgamation


Solved! i put
Код:
pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
to Load function