Gamemode SDK for C/C++ (GDK)

how to connect to the project CLR(.NET)?
Reply

For some reason SetTimer does not want to work. I'm using the latest amalgamation and the following code:
Код:
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
{
	return sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
}

void SAMPGDK_CALL PrintTickCountTimer2(int timerid, void *params) {
	sampgdk::logprintf("Tick count: %d", GetTickCount());
}

PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit()
{
	sampgdk::logprintf("GameModeInit");
	SetTimer(1000, true, PrintTickCountTimer2, 0);
	return true;
}

PLUGIN_EXPORT void PLUGIN_CALL ProcessTick()
{
	sampgdk::ProcessTick();
}
OnGameModeInit and ProcessTick are called, but the function defined in SetTimer won't.
Is there something that i miss or did wrong or it's just don't work for some reason.
Reply

Gamemode on C++ faster than Gamemode on Pawn?
Reply

Yes! Gamemode in C++ is much faster than PAWN!

Everything you write in PAWN is executed in an abstract machine whereas the code written in C++ executes directly on the host machine.
Reply

Quote:
Originally Posted by kaZax
Посмотреть сообщение
Gamemode on C++ faster than Gamemode on Pawn?
Yes.

edit: w/e yashas is everywhere :/
Reply

I don't know it a good place or not, but I think this crash was caused by GDK. If I reload one filterscript multiple times, after 5-6 server will crash.

Код:
[debug] #0 00401696 in ?? () from samp-server.exe
[debug] #1 020126c6 in _sampgdk_amxhooks_FindPublic () from plugins\YSF.dll
[debug] #2 0046bd6b in ?? () from samp-server.exe
[debug] #3 0048f859 in ?? () from samp-server.exe
[debug] #4 5d1a2db3 in ?? () from plugins\mysql.dll
[debug] #5 0048d46b in ?? () from samp-server.exe
[debug] #6 5c8b01f8 in ?? () from samp-server.exe
[debug] #7 61750824 in ?? () from samp-server.exe
Код:
SA-MP Server: 0.3.7-R2



Exception At Address: 0x61750824 Module: (Unknown)



Registers:

EAX: 0x02172CD8	EBX: 0x00000000	ECX: 0x00000000	EDX: 0x5CC7F6A8

ESI: 0x00000004	EDI: 0x04250010	EBP: 0x5C8B01F8	ESP: 0x004911F8

EFLAGS: 0x00010212



Stack:

+0000: 0x85084E8B   0x530674C9   0xFD554BE8   0x0C4E8BFF

+0010: 0x0674C985   0x635EE853   0x4E8BFFFD   0x74C98514

+0020: 0x31E85306   0x8BFFFD43   0x74C9850E   0x05E85306

+0030: 0x57FFFDC6   0x853C7E8B   0xD91774FF   0xD80C2444

+0040: 0x4B898C0D   0x89CEE800   0x8B500000   0x16D6E8CF

+0050: 0x4E8BFFFF   0x5FC98538   0x79E83074   0xEBFFFEF9

+0060: 0x02F88329   0x05D92475   0x00515BF8   0x082444D8

+0070: 0x5BF815D9   0x1DD80051   0x004B9F58   0xC4F6E0DF

+0080: 0x8B077541   0xF8FEE8CE   0x0D8BFFFF   0x004F5EBC

+0090: 0x4B987468   0xA2EEE800   0xC084FFFF   0x8B530874

+00A0: 0xCDE2E8CE   0x0D8BFFFF   0x004F5EC0   0xC4835B5E

+00B0: 0x8772E904   0xCCCCFFFD   0x8B08EC83   0x830C2444

+00C0: 0xC88B08C0   0x8B66118B   0x14890449   0xB8158B24

+00D0: 0x53004F5E   0x244C8966   0x5E7A8308   0x0F575601

+00E0: 0x00010285   0x8B388B00   0x515C040D   0x408B6600

+00F0: 0x83118B04   0xF48B08EC   0x89663E89   0x92FF0446

+0100: 0x000000E4   0x8166F88B   0x0F03E8FF   0x0000D683

+0110: 0xB80D8B00   0x8B004F5E   0xB70F0841   0xB08C8BF7

+0120: 0x000249FC   0x840FC985   0x000000BB   0x9CB08C8B

+0130: 0x85000259   0xAC840FC9   0x8B000000   0x002C2B91



--------------------------



Loaded Modules:

samp-server.exe	A: 0x00400000 - 0x00519000	(C:\Users\Ati\Desktop\SERVER\samp-server.exe)

ntdll.dll	A: 0x76F40000 - 0x770AE000	(C:\Windows\SYSTEM32\ntdll.dll)

KERNEL32.DLL	A: 0x76530000 - 0x76670000	(C:\Windows\SYSTEM32\KERNEL32.DLL)

KERNELBASE.dll	A: 0x75FA0000 - 0x76077000	(C:\Windows\SYSTEM32\KERNELBASE.dll)

apphelp.dll	A: 0x71E70000 - 0x71F10000	(C:\Windows\system32\apphelp.dll)

AcGenral.DLL	A: 0x65200000 - 0x65466000	(C:\Windows\AppPatch\AcGenral.DLL)

msvcrt.dll	A: 0x76120000 - 0x761E3000	(C:\Windows\SYSTEM32\msvcrt.dll)

sechost.dll	A: 0x75F40000 - 0x75F81000	(C:\Windows\SYSTEM32\sechost.dll)

SspiCli.dll	A: 0x74740000 - 0x7475E000	(C:\Windows\SYSTEM32\SspiCli.dll)

SHLWAPI.dll	A: 0x767F0000 - 0x76835000	(C:\Windows\SYSTEM32\SHLWAPI.dll)

UxTheme.dll	A: 0x71370000 - 0x7145D000	(C:\Windows\SYSTEM32\UxTheme.dll)

USER32.dll	A: 0x763D0000 - 0x76523000	(C:\Windows\SYSTEM32\USER32.dll)

GDI32.dll	A: 0x76D20000 - 0x76E2E000	(C:\Windows\SYSTEM32\GDI32.dll)

WINMM.dll	A: 0x70D60000 - 0x70D83000	(C:\Windows\SYSTEM32\WINMM.dll)

samcli.dll	A: 0x68950000 - 0x68963000	(C:\Windows\SYSTEM32\samcli.dll)

OLEAUT32.dll	A: 0x76080000 - 0x76115000	(C:\Windows\SYSTEM32\OLEAUT32.dll)

MSACM32.dll	A: 0x70720000 - 0x70737000	(C:\Windows\SYSTEM32\MSACM32.dll)

VERSION.dll	A: 0x746C0000 - 0x746C8000	(C:\Windows\SYSTEM32\VERSION.dll)

SHELL32.dll	A: 0x74760000 - 0x75A0D000	(C:\Windows\SYSTEM32\SHELL32.dll)

USERENV.dll	A: 0x71A00000 - 0x71A1B000	(C:\Windows\SYSTEM32\USERENV.dll)

dwmapi.dll	A: 0x70F50000 - 0x70F6A000	(C:\Windows\SYSTEM32\dwmapi.dll)

urlmon.dll	A: 0x6EF30000 - 0x6F07A000	(C:\Windows\SYSTEM32\urlmon.dll)

ADVAPI32.dll	A: 0x76C90000 - 0x76D0C000	(C:\Windows\SYSTEM32\ADVAPI32.dll)

WINSPOOL.DRV	A: 0x74650000 - 0x746B5000	(C:\Windows\SYSTEM32\WINSPOOL.DRV)

MPR.dll	A: 0x71AC0000 - 0x71AD6000	(C:\Windows\SYSTEM32\MPR.dll)

RPCRT4.dll	A: 0x76A50000 - 0x76B0A000	(C:\Windows\SYSTEM32\RPCRT4.dll)

CRYPTBASE.dll	A: 0x74730000 - 0x7473A000	(C:\Windows\SYSTEM32\CRYPTBASE.dll)

combase.dll	A: 0x76670000 - 0x767ED000	(C:\Windows\SYSTEM32\combase.dll)

WINMMBASE.dll	A: 0x6E7E0000 - 0x6E803000	(C:\Windows\SYSTEM32\WINMMBASE.dll)

profapi.dll	A: 0x743C0000 - 0x743CF000	(C:\Windows\SYSTEM32\profapi.dll)

iertutil.dll	A: 0x704E0000 - 0x70712000	(C:\Windows\SYSTEM32\iertutil.dll)

WININET.dll	A: 0x70F70000 - 0x71154000	(C:\Windows\SYSTEM32\WININET.dll)

bcryptPrimitives.dll	A: 0x746D0000 - 0x74724000	(C:\Windows\SYSTEM32\bcryptPrimitives.dll)

cfgmgr32.dll	A: 0x76E30000 - 0x76E6C000	(C:\Windows\SYSTEM32\cfgmgr32.dll)

DEVOBJ.dll	A: 0x74620000 - 0x74641000	(C:\Windows\SYSTEM32\DEVOBJ.dll)

SHCORE.DLL	A: 0x743D0000 - 0x7445B000	(C:\Windows\SYSTEM32\SHCORE.DLL)

IMM32.DLL	A: 0x76A10000 - 0x76A37000	(C:\Windows\system32\IMM32.DLL)

MSCTF.dll	A: 0x76200000 - 0x76312000	(C:\Windows\SYSTEM32\MSCTF.dll)

WSOCK32.dll	A: 0x71A30000 - 0x71A38000	(C:\Windows\SYSTEM32\WSOCK32.dll)

WS2_32.dll	A: 0x76C40000 - 0x76C90000	(C:\Windows\SYSTEM32\WS2_32.dll)

NSI.dll	A: 0x76D10000 - 0x76D17000	(C:\Windows\SYSTEM32\NSI.dll)

dbghelp.dll	A: 0x71560000 - 0x716A1000	(C:\Windows\SYSTEM32\dbghelp.dll)

MSVCP100.dll	A: 0x71A50000 - 0x71AB9000	(C:\Windows\SYSTEM32\MSVCP100.dll)

MSVCR100.dll	A: 0x71AE0000 - 0x71B9F000	(C:\Windows\SYSTEM32\MSVCR100.dll)

mysql.dll	A: 0x5D1A0000 - 0x5D1DE000	(C:\Users\Ati\Desktop\SERVER\plugins\mysql.dll)

libmysql.dll	A: 0x5CC90000 - 0x5D19C000	(C:\Users\Ati\Desktop\SERVER\libmysql.dll)

MSVCR120.dll	A: 0x67ED0000 - 0x67FBE000	(C:\Windows\SYSTEM32\MSVCR120.dll)

MSVCP120.dll	A: 0x67E50000 - 0x67EC1000	(C:\Windows\SYSTEM32\MSVCP120.dll)

Secur32.dll	A: 0x6E8B0000 - 0x6E8BA000	(C:\Windows\SYSTEM32\Secur32.dll)

napinsp.dll	A: 0x6AC50000 - 0x6AC61000	(C:\Windows\system32\napinsp.dll)

pnrpnsp.dll	A: 0x6AC30000 - 0x6AC46000	(C:\Windows\system32\pnrpnsp.dll)

NLAapi.dll	A: 0x6AC10000 - 0x6AC24000	(C:\Windows\system32\NLAapi.dll)

mswsock.dll	A: 0x74370000 - 0x743BB000	(C:\Windows\System32\mswsock.dll)

DNSAPI.dll	A: 0x6DA70000 - 0x6DAEE000	(C:\Windows\SYSTEM32\DNSAPI.dll)

winrnr.dll	A: 0x6AC00000 - 0x6AC0A000	(C:\Windows\System32\winrnr.dll)

rasadhlp.dll	A: 0x6DA60000 - 0x6DA68000	(C:\Windows\System32\rasadhlp.dll)

streamer.dll	A: 0x5CC40000 - 0x5CC90000	(C:\Users\Ati\Desktop\SERVER\plugins\streamer.dll)

sscanf.dll	A: 0x10000000 - 0x1000D000	(C:\Users\Ati\Desktop\SERVER\plugins\sscanf.dll)

GeoIP_Plugin.dll	A: 0x60010000 - 0x60019000	(C:\Users\Ati\Desktop\SERVER\plugins\GeoIP_Plugin.dll)

mapandreas.dll	A: 0x5CC20000 - 0x5CC3B000	(C:\Users\Ati\Desktop\SERVER\plugins\mapandreas.dll)

MFR.dll	A: 0x00360000 - 0x0036C000	(C:\Users\Ati\Desktop\SERVER\plugins\MFR.dll)

converter.dll	A: 0x60000000 - 0x6000F000	(C:\Users\Ati\Desktop\SERVER\plugins\converter.dll)

timerfix.dll	A: 0x5CC10000 - 0x5CC19000	(C:\Users\Ati\Desktop\SERVER\plugins\timerfix.dll)

YSF.dll	A: 0x02010000 - 0x020D3000	(C:\Users\Ati\Desktop\SERVER\plugins\YSF.dll)

IPHLPAPI.DLL	A: 0x718F0000 - 0x71910000	(C:\Windows\SYSTEM32\IPHLPAPI.DLL)

WINNSI.DLL	A: 0x71550000 - 0x71558000	(C:\Windows\SYSTEM32\WINNSI.DLL)

kernel.appcore.dll	A: 0x74460000 - 0x74469000	(C:\Windows\SYSTEM32\kernel.appcore.dll)

RTSSHooks.dll	A: 0x05BD0000 - 0x05C2E000	(C:\Program Files (x86)\RivaTuner Statistics Server\RTSSHooks.dll)

MSVCR90.dll	A: 0x74470000 - 0x74513000	(C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.8387_none_5094ca96bcb6b2bb\MSVCR90.dll)

FRAPS32.DLL	A: 0x69650000 - 0x69697000	(C:\Fraps\FRAPS32.DLL)

PROPSYS.dll	A: 0x69820000 - 0x6995A000	(C:\Windows\SYSTEM32\PROPSYS.dll)

SETUPAPI.dll	A: 0x76840000 - 0x769F1000	(C:\Windows\SYSTEM32\SETUPAPI.dll)

CRYPTSP.dll	A: 0x74350000 - 0x74369000	(C:\Windows\SYSTEM32\CRYPTSP.dll)

bcrypt.dll	A: 0x74300000 - 0x7431E000	(C:\Windows\SYSTEM32\bcrypt.dll)
Reply

How to create my natives on sampgdk?
Reply

why i cant use amx_Register ?

it show me linker error
Код:
error LNK2019: unresolved external symbol _amx_Register referenced in function _AmxLoad@4
edit: got it, forget to add amxplugin.cpp to project

but what is the meaning of this:

using crashdetect
Код:
[16:17:34] [debug] #0 7705fd91 in ?? () from CENCORED\SysWOW64\ntdll.dll
[16:17:34] [debug] #1 76c04498 in ?? () from CENCORED\syswow64\KERNELBASE.dll
[16:17:34] [debug] #2 0048d53c in ?? () from samp-server.exe
[16:17:34] [debug] #3 0049b4a1 in ?? () from samp-server.exe
[16:17:34] [debug] #4 0049b4b1 in ?? () from samp-server.exe
Reply

Hi, how should I set C++ to version 11? I tried adding

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
or
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

but in both cases the Load function is not called resulting in plugin not being initialized and crashing.

Compiling on Ubuntu by:
cmake CMakeLists.txt -DCMAKE_CXX_COMPILER=g++
make
Reply

How to call my callback with sampgdk plugin?
Reply

why sampgdk::logprintf didnt write to log file server_log.txt?
Reply

Because you called it before sampgdk::Load().
Reply

i can use streamer for objects on my c++ gamemode?
Reply

Yes, see at https://github.com/grasmanek94/eXe

Thanks for Incognito for rewriting this.
Reply

Hello,

I want to leave a response here about Streamer with SAMPGDK. You can use it as xeeZ said here, but you don't need to invoke Streamer_CallbackHook since it is deprecated in version 2.7.8.

Why?
Because Incognito decided to use SAMPGDK for OnPlayerConnect and OnPlayerDisconnect.

All you need to do is to invoke CreateDynamicObject as xeeZ do in his gist.
Код:
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.0, float drawdistance = 0.0)
{
  static AMX_NATIVE native = sampgdk::FindNative("CreateDynamicObject");
  return sampgdk::InvokeNative(native, "iffffffiiiff", modelid, x, y, z, rx, ry, rz, worldid, interiorid, playerid, streamdistance, drawdistance);
}
And then call it.

Now, I want to know your opinion. If we want to use Streamer with SAMPGDK it is better to invoke a native (like the method above) or to combine streamer plugin with our project (which will be a pain in the a** with plugin updates and with the combination)?

By the way, can we register a Streamer's callback in our plugins?
I tried this
Код:
SAMPGDK_CALLBACK(bool, OnPlayerEditDynamicObject(int playerid, int  objectid, int  response, float x, float y, float z, float rx, float ry, float rz));
SAMPGDK_CALLBACK(bool, OnPlayerSelectDynamicObject(int playerid, int objectid, int modelid, float x, float y, float z));

PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerEditDynamicObject(int playerid, int  objectid, int  response, float x, float y, float z, float rx, float ry, float rz)
{
	sampgdk::logprintf("OnPlayerEditDynamicObject: %i | %f | %f | %f", objectid, x, y, z);
	return true;
}

PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerSelectDynamicObject(int playerid, int objectid, int modelid, float x, float y, float z)
{
	sampgdk::logprintf("OnPlayerSelectDynamicObject: %i | %f | %f | %f", objectid, x, y, z);
	return true;
}
And this functions aren't called, instead OnPlayerEditObject is called. If I edit an object.
Reply

I keep getting these messages.

Код:
[sampgdk:warning] Index mismatch for OnCameraLeaveNode (-10007 != -10002)
[sampgdk:warning] Index mismatch for OnCameraReachNode (-10008 != -10003)
[sampgdk:warning] Index mismatch for OnCameraLeaveNode (-10007 != -10002)
[sampgdk:warning] Index mismatch for OnCameraReachNode (-10008 != -10003)
[sampgdk:warning] Index mismatch for OnCameraLeaveNode (-10007 != -10002)
[sampgdk:warning] Index mismatch for OnPlayerEnterDynamicArea (-10026 != -10020)
[sampgdk:warning] Index mismatch for OnPlayerLeaveDynamicArea (-10035 != -10030)
What does that mean? and how can I fix it?
Reply

It says the plugin failed to load, doesn't say why, is there a way to find out why?
Quote:

----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team

[01:42:44] filterscripts = "" (string)
[01:42:44]
[01:42:44] Server Plugins
[01:42:44] --------------
[01:42:44] Loading plugin: CopsAndRobbers.dll
[01:42:44] Failed.
[01:42:44] Loaded 0 plugins.

[01:42:44]
[01:42:44] Filterscripts
[01:42:44] ---------------
[01:42:44] Loaded 0 filterscripts.

[01:42:44] Number of vehicle models: 0

Quote:

1>------ Build started: Project: CopsAndRobbers, Configuration: Release Win32 ------
1> CopsAndRobbers.cpp
1> Creating library C:\Users\MikeK\OneDrive\San Andreas Multiplayer\plugins\CopsAndRobbers.lib and object C:\Users\MikeK\OneDrive\San Andreas Multiplayer\plugins\CopsAndRobbers.exp
1> Generating code
1> 0 of 74 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
1> 0 functions were new in current compilation
1> 0 functions had inline decision re-evaluated but remain unchanged
1> Finished generating code
1> CopsAndRobbers.vcxproj -> C:\Users\MikeK\OneDrive\San Andreas Multiplayer\plugins\CopsAndRobbers.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Windows 10 64-bit.
Latest Visual Studio Community 2015.
C/C++ -> Pre-processor -> Definitions:
Quote:

HAVE_STDINT_H;

Linker -> Input -> Add. Deps.:
Quote:

SAMP_GDK/sampgdk4.lib;

Code is exact same as the code in the main thread.
Reply

I have a problem with making a function work when is used in PAWN script.
pawn Код:
static cell AMX_NATIVE_CALL PrintFunc(AMX *amx, cell *params)
{
    logprintf("PrintFunc is working.");
    return 1;
}

AMX_NATIVE_INFO PluginNatives[] =
{
    {"PrintFunc", PrintFunc},
    {0, 0}
};
and yes, I do have SUPPORTS_AMX_NATIVES defined in Supports() function. It gives run time error 19 for function "PrintFunc" not found.

I use amalgamation version.
Reply

Have you defined the "native PrintFunc();" in your include or pwn file?
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I have a problem with making a function work when is used in PAWN script.
and yes, I do have SUPPORTS_AMX_NATIVES defined in Supports() function. It gives run time error 19 for function "PrintFunc" not found.

I use amalgamation version.
Reply

@Konstantinos
Did you register the natives in AmxLoad? The script will be aware of the natives only when you register them. The register process basically fills the native functions table (the PAWN compiler leaves the address field as 0) with the correct addresses. If there is one or more function whose address isn't set, you'll get that error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)