problems with adding callbacks
#1

Hello all. Sorry for my bad english. But i'll try to speak it.

After several failed attempts to add a callback (OnPlayerConnect) in a project using sampgdk (for writing a plugin), I decided to ask a question in this forum.

How to add OnPlayerConnect in the project?

In main.cpp added:

PHP код:
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerConnect (int playerid)
{
     
logprintf ("* Player connected!");
     return 
1;

And export.def:
PHP код:
OnPlayerConnect 
The problem is that these functions do not work when you connect the player to the console writes nothing
Reply
#2

The define needs to be like:
Код:
EXPORTS
    <callback name>
Basically, every callback you have in the dll, which is going to be called from the server, needs to be written in the define.
Reply
#3

Quote:
Originally Posted by Kikito
Посмотреть сообщение
The define needs to be like:
Код:
EXPORTS
    <callback name>
Basically, every callback you have in the dll, which is going to be called from the server, needs to be written in the define.
If I understand correctly, that's all I announced export.def and connected in the layout

EXPORTS
Supports
Load
Unload
ProcessTick
OnPlayerConnect
OnPlayerDisconnect
Reply
#4

Can you show the code?
Reply
#5

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
Can you show the code?
Yes.
Project: http://www.solidfiles.com/d/fffd8dec13/TheMode.rar
VirusTotal (just in case): https://www.virustotal.com/ru/file/3...is/1405949376/
Reply
#6

However, in such public as "Load", "Unload" and "ProcessTick" logprintf operates and outputs the result to the console
Reply
#7

You're not starting the sampgdk.

Basically, you're missing this:
PHP код:
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
    return 
sampgdk::Load(ppData);
}
PLUGIN_EXPORT void PLUGIN_CALL Unload() {
    
sampgdk::Unload();
}
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
    return 
sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
}
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
    
sampgdk::ProcessTick();

Next time, read the sampgdk thread(the plugin code).
Reply
#8

Quote:
Originally Posted by Kikito
Посмотреть сообщение
You're not starting the sampgdk.

Basically, you're missing this:
PHP код:
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData) {
    return 
sampgdk::Load(ppData);
}
PLUGIN_EXPORT void PLUGIN_CALL Unload() {
    
sampgdk::Unload();
}
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {
    return 
sampgdk::Supports() | SUPPORTS_PROCESS_TICK;
}
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
    
sampgdk::ProcessTick();

Next time, read the sampgdk thread(the plugin code).
Ох, спасибо! Все работает.
Reply
#9

Quote:
Originally Posted by VaReNiX
Посмотреть сообщение
Ох, спасибо! Все работает.
English please.
Reply
#10

OK, if that's your real code I have another question: have you actually looked at the example plugin linked from the first post of the official thread (helloworld)? Because your code is missing all the important bits needed to make it work with the GDK, it doesn't even incldue the required headers.

Also, I released a new version yesterday (GDK 4.0), it looks like you may have missed it as you're using 3.7 so I'll just leave this link here: https://github.com/Zeex/sampgdk/releases/tag/v4.0

BTW I fixed your include/library paths, if you don't mind: http://www.solidfiles.com/d/8f23d48dd5/TheMode.zip
Reply
#11

Quote:
Originally Posted by Kikito
Посмотреть сообщение
English please.
Oh, thank you! Everything works. (Sorry)
Reply
#12

Quote:
Originally Posted by xeeZ
Посмотреть сообщение
OK, if that's your real code I have another question: have you actually looked at the example plugin linked from the first post of the official thread (helloworld)? Becase your code is missing all the important bits needed to make it work with the GDK, it doesn't even incldue the required headers.

Also, I released a new version yesterday (GDK 4.0), it looks like you may have missed it as you're using 3.7 so I'll just leave this link here: https://github.com/Zeex/sampgdk/releases/tag/v4.0

BTW I fixed your include/library paths, if you don't mind: http://www.solidfiles.com/d/8f23d48dd5/TheMode.zip
I'm starting to get acquainted with the library, and not all understand.
Thanks for the help, xeeZ. Helped me with this issue.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)