mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-17 22:23:03 +00:00
Lua: Call onInit properly
This commit is contained in:
+5
-5
@@ -40,11 +40,11 @@ void TLuaEngine::operator()() {
|
|||||||
// lua engine main thread
|
// lua engine main thread
|
||||||
CollectAndInitPlugins();
|
CollectAndInitPlugins();
|
||||||
// now call all onInit's
|
// now call all onInit's
|
||||||
for (const auto& Pair : mLuaStates) {
|
auto Futures = TriggerEvent("onInit");
|
||||||
auto Res = EnqueueFunctionCall(Pair.first, "onInit", {});
|
WaitForAll(Futures);
|
||||||
Res->WaitUntilReady(); // FIXME this dumb, dont do this, this is smelly!
|
for (const auto& Future : Futures) {
|
||||||
if (Res->Error && Res->ErrorMessage != TLuaEngine::BeamMPFnNotFoundError) {
|
if (Future->Error) {
|
||||||
beammp_lua_error("Calling \"onInit\" on \"" + Pair.first + "\" failed: " + Res->ErrorMessage);
|
beammp_lua_error("Calling \"onInit\" on \"" + Future->StateId + "\" failed: " + Future->ErrorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// this thread handles timers
|
// this thread handles timers
|
||||||
|
|||||||
Reference in New Issue
Block a user