SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 20/07/2014, 06:28 PM   #1
VaReNiX
Big Clucker
 
Join Date: Oct 2013
Posts: 55
Reputation: 0
Default problems with adding callbacks

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 Code:
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerConnect (int playerid)
{
     
logprintf ("* Player connected!");
     return 
1;

And export.def:
PHP Code:
OnPlayerConnect 
The problem is that these functions do not work when you connect the player to the console writes nothing
VaReNiX is offline   Reply With Quote
Old 21/07/2014, 11:38 AM   #2
GWMPT
High-roller
 
Join Date: Nov 2012
Location: Portugal.
Posts: 1,023
Reputation: 286
Default Re: problems with adding callbacks

The define needs to be like:
Code:
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.
GWMPT is offline   Reply With Quote
Old 21/07/2014, 12:26 PM   #3
VaReNiX
Big Clucker
 
Join Date: Oct 2013
Posts: 55
Reputation: 0
Default Re: problems with adding callbacks

Quote:
Originally Posted by Kikito View Post
The define needs to be like:
Code:
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
VaReNiX is offline   Reply With Quote
Old 21/07/2014, 01:45 PM   #4
xeeZ
Huge Clucker
 
Join Date: Feb 2013
Posts: 316
Reputation: 380
Default Re: problems with adding callbacks

Can you show the code?
xeeZ is offline   Reply With Quote
Old 21/07/2014, 02:01 PM   #5
VaReNiX
Big Clucker
 
Join Date: Oct 2013
Posts: 55
Reputation: 0
Default Re: problems with adding callbacks

Quote:
Originally Posted by xeeZ View Post
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/
VaReNiX is offline   Reply With Quote
Old 21/07/2014, 02:06 PM   #6
VaReNiX
Big Clucker
 
Join Date: Oct 2013
Posts: 55
Reputation: 0
Default Re: problems with adding callbacks

However, in such public as "Load", "Unload" and "ProcessTick" logprintf operates and outputs the result to the console
VaReNiX is offline   Reply With Quote
Old 21/07/2014, 02:06 PM   #7
GWMPT
High-roller
 
Join Date: Nov 2012
Location: Portugal.
Posts: 1,023
Reputation: 286
Default Re: problems with adding callbacks

You're not starting the sampgdk.

Basically, you're missing this:
PHP Code:
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).
GWMPT is offline   Reply With Quote
Old 21/07/2014, 02:30 PM   #8
VaReNiX
Big Clucker
 
Join Date: Oct 2013
Posts: 55
Reputation: 0
Default Re: problems with adding callbacks

Quote:
Originally Posted by Kikito View Post
You're not starting the sampgdk.

Basically, you're missing this:
PHP Code:
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).
Ох, спасибо! Все работает.
VaReNiX is offline   Reply With Quote
Old 21/07/2014, 02:36 PM   #9
GWMPT
High-roller
 
Join Date: Nov 2012
Location: Portugal.
Posts: 1,023
Reputation: 286
Default Re: problems with adding callbacks

Quote:
Originally Posted by VaReNiX View Post
Ох, спасибо! Все работает.
English please.
GWMPT is offline   Reply With Quote
Old 21/07/2014, 02:37 PM   #10
xeeZ
Huge Clucker
 
Join Date: Feb 2013
Posts: 316
Reputation: 380
Default Re: problems with adding callbacks

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

Last edited by xeeZ; 21/07/2014 at 03:32 PM. Reason: Fxied typo
xeeZ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] New SA-MP callbacks! Emmet_ Includes 263 25/05/2017 08:29 AM
What happens behind these callbacks we use? Hoborific Scripting Help 2 31/01/2014 02:00 PM
Using callbacks more then once Admigo Scripting Help 6 29/09/2013 03:32 PM
[Tutorial] Callbacks CONTROLA Salonul Scripturilor 2 24/05/2012 06:26 PM
Weapon adding problems (very weird) Andy_McKinley Help Archive 3 27/02/2010 08:20 PM


All times are GMT. The time now is 05:31 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.