Skip to content

Commit 17f9c85

Browse files
committed
added threading callbacks
1 parent 684b73e commit 17f9c85

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
#include "pysamp/pysamp.h"
77
#include "bindings/callbacks.h"
88
#include "test/callbackstest.h"
9+
#include <thread>
910

11+
std::thread threading;
12+
bool threadingInitialized = false;
1013

1114
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
1215
{
@@ -21,7 +24,13 @@ PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
2124
return false;
2225
}
2326

24-
return sampgdk::Load(ppData);
27+
bool sgdk = sampgdk::Load(ppData);
28+
if (sgdk) {
29+
PySAMP::callback("OnThreadingInit", NULL);
30+
threading = std::thread([] { PySAMP::callback("OnThreadingInit", NULL); });
31+
32+
}
33+
return false;
2534
}
2635

2736
PLUGIN_EXPORT void PLUGIN_CALL Unload()
@@ -31,6 +40,8 @@ PLUGIN_EXPORT void PLUGIN_CALL Unload()
3140

3241
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick()
3342
{
43+
PySAMP::callback("OnThreadingStopSignal", NULL);
44+
threading.join();
3445
sampgdk::ProcessTick();
3546
PySAMP::callback("OnProcessTick", NULL);
3647
}

0 commit comments

Comments
 (0)