Gamemode SDK for C/C++ (GDK)
#81

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Replace SAMPGDK_TIMER_CALL with SAMPGDK_CALL.
Fixed the error but now it gives follow although i've added the sampgdk library
Код:
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetGameModeText referenced in function "bool __cdecl SetGameModeText(char const *)" (?SetGameModeText@@YA_NPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_AddPlayerClass referenced in function "int __cdecl AddPlayerClass(int,float,float,float,float,int,int,int,int,int,int)" (?AddPlayerClass@@YAHHMMMMHHHHHH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetTimer referenced in function "int __cdecl SetTimer(int,bool,void (__cdecl*)(int,void *),void *)" (?SetTimer@@YAHH_NP6AXHPAX@Z1@Z)
1>main.obj : error LNK2001: unresolved external symbol __imp__sampgdk_vlogprintf
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SendClientMessage referenced in function "bool __cdecl SendClientMessage(int,int,char const *)" (?SendClientMessage@@YA_NHHPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerPos referenced in function "bool __cdecl SetPlayerPos(int,float,float,float)" (?SetPlayerPos@@YA_NHMMM@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerCameraPos referenced in function "bool __cdecl SetPlayerCameraPos(int,float,float,float)" (?SetPlayerCameraPos@@YA_NHMMM@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerCameraLookAt referenced in function "bool __cdecl SetPlayerCameraLookAt(int,float,float,float,int)" (?SetPlayerCameraLookAt@@YA_NHMMMH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_GetPlayerPos referenced in function "bool __cdecl GetPlayerPos(int,float *,float *,float *)" (?GetPlayerPos@@YA_NHPAM00@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_init_plugin referenced in function "public: int __thiscall Plugin::Load(void * *)" (?Load@Plugin@@QAEHPAPAX@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_cleanup_plugin referenced in function "public: int __thiscall Plugin::Unload(void)" (?Unload@Plugin@@QAEHXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_process_plugin_timers referenced in function "public: void __thiscall Plugin::ProcessTimers(void)" (?ProcessTimers@Plugin@@QAEXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_GetPlayerName referenced in function "bool __cdecl GetPlayerName(int,char *,int)" (?GetPlayerName@@YA_NHPADH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_get_plugin_handle referenced in function "public: __thiscall ThisPlugin::ThisPlugin(void)" (??0ThisPlugin@@QAE@XZ)
Reply
#82

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
seems you need to link to the dynamic, not the static library.
Thank you, this fixed it. But how do I create a static sampgdk plugin that does not require this additional sampgdk3.dll file in the server directory?
Reply
#83

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
link to the static library and enable the definition for static compiling
And whats the definition for static compiling?
Reply
#84

Quote:
Originally Posted by Mellnik
Посмотреть сообщение
And whats the definition for static compiling?
AFAIK you just need to download the static library and link it instead of the library the normal download ships with.
Reply
#85

I'm getting the same issue as the above user however I've tried both dynamic and static and still getting same issues. Any ideas?

Код:
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SendClientMessage referenced in function "bool __cdecl SendClientMessage(int,int,char const *)" (?SendClientMessage@@YA_NHHPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetGameModeText referenced in function "bool __cdecl SetGameModeText(char const *)" (?SetGameModeText@@YA_NPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_AddPlayerClass referenced in function "int __cdecl AddPlayerClass(int,float,float,float,float,int,int,int,int,int,int)" (?AddPlayerClass@@YAHHMMMMHHHHHH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetTimer referenced in function "int __cdecl SetTimer(int,bool,void (__cdecl*)(int,void *),void *)" (?SetTimer@@YAHH_NP6AXHPAX@Z1@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerPos referenced in function "bool __cdecl SetPlayerPos(int,float,float,float)" (?SetPlayerPos@@YA_NHMMM@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_GetPlayerPos referenced in function "bool __cdecl GetPlayerPos(int,float *,float *,float *)" (?GetPlayerPos@@YA_NHPAM00@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_GetPlayerName referenced in function "bool __cdecl GetPlayerName(int,char *,int)" (?GetPlayerName@@YA_NHPADH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerCameraPos referenced in function "bool __cdecl SetPlayerCameraPos(int,float,float,float)" (?SetPlayerCameraPos@@YA_NHMMM@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerCameraLookAt referenced in function "bool __cdecl SetPlayerCameraLookAt(int,float,float,float,int)" (?SetPlayerCameraLookAt@@YA_NHMMMH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_init_plugin referenced in function "public: int __thiscall Plugin::Load(void * *)" (?Load@Plugin@@QAEHPAPAX@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_cleanup_plugin referenced in function "public: int __thiscall Plugin::Unload(void)" (?Unload@Plugin@@QAEHXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_get_plugin_handle referenced in function "public: __thiscall ThisPlugin::ThisPlugin(void)" (??0ThisPlugin@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_process_plugin_timers referenced in function "public: void __thiscall Plugin::ProcessTimers(void)" (?ProcessTimers@Plugin@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol __imp__sampgdk_vlogprintf
Using the helloworld example with static package.

I've even tried using an older GDK however still no improvements.
Reply
#86

Good job.

Surely I will develop a Game Mode using SDK C/C++ (GDK), initially for studies and later will use in my Game Mode.
Reply
#87

This is fully compatible with linux right? If so how would I go about compiling the plugin into .so? I'm using centos 6
Reply
#88

How i'm supossed to fix this error?

pawn Код:
error C2664: 'SetTimer' : no se puede convertir el parбmetro 3 de 'int (__cdecl *)(int,void *)' a 'TimerCallback'
I used the helloworld example but it doesnt seem to work.
Reply
#89

Quote:
Originally Posted by JustBored
Посмотреть сообщение
How i'm supossed to fix this error?

pawn Код:
error C2664: 'SetTimer' : no se puede convertir el parбmetro 3 de 'int (__cdecl *)(int,void *)' a 'TimerCallback'
I used the helloworld example but it doesnt seem to work.
Timer functions return "void", not "int". In C++ if you don't specify the return type it defaults to "int".

Quote:
Originally Posted by Isolated
Посмотреть сообщение
I'm getting the same issue as the above user however I've tried both dynamic and static and still getting same issues. Any ideas?

Код:
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SendClientMessage referenced in function "bool __cdecl SendClientMessage(int,int,char const *)" (?SendClientMessage@@YA_NHHPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetGameModeText referenced in function "bool __cdecl SetGameModeText(char const *)" (?SetGameModeText@@YA_NPBD@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_AddPlayerClass referenced in function "int __cdecl AddPlayerClass(int,float,float,float,float,int,int,int,int,int,int)" (?AddPlayerClass@@YAHHMMMMHHHHHH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetTimer referenced in function "int __cdecl SetTimer(int,bool,void (__cdecl*)(int,void *),void *)" (?SetTimer@@YAHH_NP6AXHPAX@Z1@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerPos referenced in function "bool __cdecl SetPlayerPos(int,float,float,float)" (?SetPlayerPos@@YA_NHMMM@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_GetPlayerPos referenced in function "bool __cdecl GetPlayerPos(int,float *,float *,float *)" (?GetPlayerPos@@YA_NHPAM00@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_GetPlayerName referenced in function "bool __cdecl GetPlayerName(int,char *,int)" (?GetPlayerName@@YA_NHPADH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerCameraPos referenced in function "bool __cdecl SetPlayerCameraPos(int,float,float,float)" (?SetPlayerCameraPos@@YA_NHMMM@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_SetPlayerCameraLookAt referenced in function "bool __cdecl SetPlayerCameraLookAt(int,float,float,float,int)" (?SetPlayerCameraLookAt@@YA_NHMMMH@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_init_plugin referenced in function "public: int __thiscall Plugin::Load(void * *)" (?Load@Plugin@@QAEHPAPAX@Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_cleanup_plugin referenced in function "public: int __thiscall Plugin::Unload(void)" (?Unload@Plugin@@QAEHXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_get_plugin_handle referenced in function "public: __thiscall ThisPlugin::ThisPlugin(void)" (??0ThisPlugin@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__sampgdk_process_plugin_timers referenced in function "public: void __thiscall Plugin::ProcessTimers(void)" (?ProcessTimers@Plugin@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol __imp__sampgdk_vlogprintf
Using the helloworld example with static package.

I've even tried using an older GDK however still no improvements.
When using the static library you additionally have to define SAMPGDK_STATIC in your project so that SAMPGDK_EXPORT will be defined accordingly.

Quote:
Originally Posted by thefatshizms
Посмотреть сообщение
This is fully compatible with linux right? If so how would I go about compiling the plugin into .so? I'm using centos 6
You have to create a makefile or use a build system that generates one for you (like CMake). Take a look at how it's done in other plugins, e.g. here.
Reply
#90

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Timer functions return "void", not "int". In C++ if you don't specify the return type it defaults to "int".
Could you please answer to Isolated's question?
Reply
#91

OK, fixed the link.

Quote:
Originally Posted by Mellnik
Посмотреть сообщение
Could you please answer to Isolated's question?
See my previous post.
Reply
#92

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Timer functions return "void", not "int". In C++ if you don't specify the return type it defaults to "int".
Thank u very much xeez. Btw i the fixed line is this:

pawn Код:
SetTimer(tasa, true, (void)ComprobaciondeVehiculos, NULL);
Reply
#93

Is there a x64 version? or How I can do to compile my code in x64?

PS: When I try to compile it tells me sampgdk not support x64.
Reply
#94

If anyone cares I released a new version of this (3.6).

What's new:
  • Added SAMPGDK_TIMER_CALL macro for timer callbacks (expands to SAMPGDK_CALL)
  • Added several new functions for calling SA-MP and other plugins' natives dynamically:
    Код:
    sampgdk_find_native(const char *name)
    sampgdk_call_native(AMX_NATIVE native, cell *params)
    sampgdk_invoke_native(AMX_NATIVE, const char *format, ...)
  • Minor code and build system improvements
The new sampgdk_invoke_native() function is useful e.g. for calling other plugins' native functions (like streamer). The format argument is similar to that of SetTimerEx, i.e. it's a string where each character denotes the type of the associated parameter, and the following types (specifiers) are supported:

pawn Код:
'i', 'd' - int
'b' - bool
'f' - float
'r' - const reference ('const cell *' in C)
'R' - non-const reference (output argument) (the C type is 'cell *')
's' - input string ('const char *' in C)
'S' - output string ('char *'), size must be passed in next argument
For example, in order to call GetPlayerName you would do:

Код:
char name[MAX_PLAYER_NAME};
AMX_NATIVE native = sampgdk_find_native("GetPlayerName");
sampgdk_invoke_native(native, "iSi", playerid, name, sizeof(name));
For GetPlayerPos:

Код:
float x, y, z;
AMX_NATIVE native = sampgdk_find_native("GetPlayerPos");
sampgdk_invoke_native(native, "iRRR", playerid, &x, &y, &z);
Reply
#95

This update makes many things easier. Thank's.
Reply
#96

oh, now is more simple use this

Thank's
Reply
#97

Excellent update Zeex, exactly what I needed! Thank you!
EDIT: Note to everyone linking against the static library, you have to build subhook and add it to your project!
Reply
#98

Can somebody figure out why this doesn't work?
(CreateDynamicObject from Incognito's Streamer Plugin)

Код:
int CreateDynamicObject(int modelid, float x, float y, float z, float rx, float ry, float rz, int worldid = -1, int interiorid = -1, int playerid = -1, float streamdistance = 200.0f)
{
	return (int)sampgdk_invoke_native(sampgdk_find_native("CreateDynamicObject"), "iffffffiiif", modelid, x, y, z, rx, ry, rz, worldid, interiorid, playerid, streamdistance);
}
Streamer plugin is loaded before gamemode (that uses SAMPGDK).
Reply
#99

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
If anyone cares I released a new version of this (3.6).

What's new:
  • Added several new functions for calling SA-MP and other plugins' natives dynamically:
Thank you! That's grate!


Quote:
Originally Posted by Pupak
Посмотреть сообщение
Can somebody figure out why this doesn't work?
(CreateDynamicObject from Incognito's Streamer Plugin)

Код:
int CreateDynamicObject(int modelid, float x, float y, float z, float rx, float ry, float rz, int worldid = -1, int interiorid = -1, int playerid = -1, float streamdistance = 200.0f)
{
	return (int)sampgdk_invoke_native(sampgdk_find_native("CreateDynamicObject"), "iffffffiiif", modelid, x, y, z, rx, ry, rz, worldid, interiorid, playerid, streamdistance);
}
Streamer plugin is loaded before gamemode (that uses SAMPGDK).
Check what is returned on following code to debug it better.
sampgdk_find_native("CreateDynamicObject")
Reply

Quote:
Originally Posted by Pupak
Посмотреть сообщение
Can somebody figure out why this doesn't work?
(CreateDynamicObject from Incognito's Streamer Plugin)

Код:
int CreateDynamicObject(int modelid, float x, float y, float z, float rx, float ry, float rz, int worldid = -1, int interiorid = -1, int playerid = -1, float streamdistance = 200.0f)
{
	return (int)sampgdk_invoke_native(sampgdk_find_native("CreateDynamicObject"), "iffffffiiif", modelid, x, y, z, rx, ry, rz, worldid, interiorid, playerid, streamdistance);
}
Streamer plugin is loaded before gamemode (that uses SAMPGDK).
What do you mean doesn't work? Looks good to me. Where do you call it? In OnGameModeInit?
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)